@@ -99,7 +99,7 @@ struct Unidirectional
9999
100100 scalar_type getLuma (NBL_CONST_REF_ARG (vector3_type) col)
101101 {
102- return nbl:: hlsl::dot (nbl:: hlsl::transpose (colorspace::scRGBtoXYZ)[1 ], col);
102+ return hlsl::dot<vector3_type>( hlsl::transpose (colorspace::scRGBtoXYZ)[1 ], col);
103103 }
104104
105105 // TODO: probably will only work with procedural shapes, do the other ones
@@ -123,8 +123,8 @@ struct Unidirectional
123123 bsdfLightIDs = scene.getBsdfLightIDs (objectID);
124124 vector3_type N = scene.getNormal (objectID, intersection);
125125 N = nbl::hlsl::normalize (N);
126- typename isotropic_type:: ray_dir_info_type V;
127- V.direction = nbl::hlsl:: normalize ( -ray.direction) ;
126+ ray_dir_info_type V;
127+ V.direction = -ray.direction;
128128 isotropic_type iso_interaction = isotropic_type::create (V, N);
129129 interaction = anisotropic_type::create (iso_interaction);
130130 }
@@ -143,8 +143,6 @@ struct Unidirectional
143143 ray.payload.accumulation += nee.deferredEvalAndPdf (_pdf, scene.lights[lightID], ray, scene.toNextEvent (lightID)) * throughput / (1.0 + _pdf * _pdf * ray.payload.otherTechniqueHeuristic);
144144 }
145145
146- return false ; // emissive only
147-
148146 const uint32_t bsdfID = glsl::bitfieldExtract (bsdfLightIDs, 0 , 16 );
149147 if (bsdfID == bxdfnode_type::INVALID_ID)
150148 return false ;
@@ -163,9 +161,9 @@ struct Unidirectional
163161 // thresholds
164162 const scalar_type bxdfPdfThreshold = 0.0001 ;
165163 const scalar_type lumaContributionThreshold = getLuma (colorspace::eotf::sRGB<vector3_type>((vector3_type)1.0 / 255.0 )); // OETF smallest perceptible value
166- const vector3_type throughputCIE_Y = nbl:: hlsl::transpose (colorspace::sRGBtoXYZ)[1 ] * throughput; // TODO: this only works if spectral_type is dim 3
164+ const vector3_type throughputCIE_Y = hlsl::transpose (colorspace::sRGBtoXYZ)[1 ] * throughput; // TODO: this only works if spectral_type is dim 3
167165 const measure_type eta = bxdf.params.ior0 / bxdf.params.ior1; // assume it's real, not imaginary?
168- const scalar_type monochromeEta = nbl:: hlsl::dot (throughputCIE_Y, eta) / (throughputCIE_Y.r + throughputCIE_Y.g + throughputCIE_Y.b); // TODO: imaginary eta?
166+ const scalar_type monochromeEta = hlsl::dot<vector3_type> (throughputCIE_Y, eta) / (throughputCIE_Y.r + throughputCIE_Y.g + throughputCIE_Y.b); // TODO: imaginary eta?
169167
170168 // sample lights
171169 const scalar_type neeProbability = 1.0 ; // BSDFNode_getNEEProb(bsdf);
@@ -185,7 +183,6 @@ struct Unidirectional
185183 // but if we allowed non-watertight transmitters (single water surface), it would make sense just to apply this line by itself
186184 anisocache_type _cache;
187185 validPath = validPath && anisocache_type::template compute<ray_dir_info_type, ray_dir_info_type>(_cache, interaction, nee_sample, monochromeEta);
188- bxdf.params.A = nbl::hlsl::max (bxdf.params.A, vector <scalar_type, 2 >(0 ,0 ));
189186 bxdf.params.eta = monochromeEta;
190187
191188 if (neeContrib_pdf.pdf < numeric_limits<scalar_type>::max )
@@ -231,7 +228,7 @@ struct Unidirectional
231228 }
232229
233230 quotient_pdf_type bsdf_quotient_pdf = materialSystem.quotient_and_pdf (material, bxdf.params, params);
234- bsdf_quotient_pdf.quotient *= throughput;
231+ bsdf_quotient_pdf.quotient *= bxdf.albedo * throughput;
235232 neeContrib_pdf.quotient *= bsdf_quotient_pdf.quotient;
236233 const scalar_type otherGenOverChoice = bsdf_quotient_pdf.pdf * rcpChoiceProb;
237234 // const scalar_type otherGenOverLightAndChoice = otherGenOverChoice / bsdf_quotient_pdf.pdf;
@@ -268,30 +265,30 @@ struct Unidirectional
268265 {
269266 params = params_type::template create<sample_type, isotropic_type>(bsdf_sample, iso_interaction, bxdf::BCM_MAX);
270267 }
271- else if (!isBSDF && bxdf.materialType != ext::MaterialSystem::Material::DIFFUSE)
272- {
273- if (bxdf.params.is_aniso)
274- params = params_type::template create<sample_type, anisotropic_type, anisocache_type>(bsdf_sample, interaction, _cache, bxdf::BCM_MAX);
275- else
276- {
277- isocache_type isocache = _cache.iso_cache;
278- params = params_type::template create<sample_type, isotropic_type, isocache_type>(bsdf_sample, iso_interaction, isocache, bxdf::BCM_MAX);
279- }
280- }
281- else if (isBSDF && bxdf.materialType == ext::MaterialSystem::Material::DIFFUSE)
282- {
283- params = params_type::template create<sample_type, isotropic_type>(bsdf_sample, iso_interaction, bxdf::BCM_ABS);
284- }
285- else if (isBSDF && bxdf.materialType != ext::MaterialSystem::Material::DIFFUSE)
286- {
287- if (bxdf.params.is_aniso)
288- params = params_type::template create<sample_type, anisotropic_type, anisocache_type>(bsdf_sample, interaction, _cache, bxdf::BCM_ABS);
289- else
290- {
291- isocache_type isocache = _cache.iso_cache;
292- params = params_type::template create<sample_type, isotropic_type, isocache_type>(bsdf_sample, iso_interaction, isocache, bxdf::BCM_ABS);
293- }
294- }
268+ // else if (!isBSDF && bxdf.materialType != ext::MaterialSystem::Material::DIFFUSE)
269+ // {
270+ // if (bxdf.params.is_aniso)
271+ // params = params_type::template create<sample_type, anisotropic_type, anisocache_type>(bsdf_sample, interaction, _cache, bxdf::BCM_MAX);
272+ // else
273+ // {
274+ // isocache_type isocache = _cache.iso_cache;
275+ // params = params_type::template create<sample_type, isotropic_type, isocache_type>(bsdf_sample, iso_interaction, isocache, bxdf::BCM_MAX);
276+ // }
277+ // }
278+ // else if (isBSDF && bxdf.materialType == ext::MaterialSystem::Material::DIFFUSE)
279+ // {
280+ // params = params_type::template create<sample_type, isotropic_type>(bsdf_sample, iso_interaction, bxdf::BCM_ABS);
281+ // }
282+ // else if (isBSDF && bxdf.materialType != ext::MaterialSystem::Material::DIFFUSE)
283+ // {
284+ // if (bxdf.params.is_aniso)
285+ // params = params_type::template create<sample_type, anisotropic_type, anisocache_type>(bsdf_sample, interaction, _cache, bxdf::BCM_ABS);
286+ // else
287+ // {
288+ // isocache_type isocache = _cache.iso_cache;
289+ // params = params_type::template create<sample_type, isotropic_type, isocache_type>(bsdf_sample, iso_interaction, isocache, bxdf::BCM_ABS);
290+ // }
291+ // }
295292
296293 // the value of the bsdf divided by the probability of the sample being generated
297294 quotient_pdf_type bsdf_quotient_pdf = materialSystem.quotient_and_pdf (material, bxdf.params, params);
@@ -353,11 +350,7 @@ struct Unidirectional
353350
354351 hit = ray.objectID.id != -1 ;
355352 if (hit)
356- {
357- // float pp = float(ray.objectID.id) / 10.0;
358- // ray.payload.accumulation = measure_type(pp, 1.0-pp, 0.3);
359353 rayAlive = closestHitProgram (1 , i, ray, scene);
360- }
361354
362355 }
363356 if (!hit)
0 commit comments