Skip to content

Commit 79aea6d

Browse files
committed
minor fixes to cook torrance generate
1 parent 2a7cf4b commit 79aea6d

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

include/nbl/builtin/hlsl/bxdf/base/cook_torrance_base.hlsl

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ struct SCookTorrance
194194
const scalar_type NdotV = interaction.getNdotV();
195195
if (NdotV < numeric_limits<scalar_type>::min)
196196
return sample_type::createInvalid();
197-
assert(NdotV != bit_cast<scalar_type>(numeric_limits<scalar_type>::quiet_NaN));
197+
assert(!hlsl::isnan(NdotV));
198198
}
199199

200200
const vector3_type localV = interaction.getTangentSpaceV();
@@ -263,11 +263,11 @@ struct SCookTorrance
263263
const scalar_type NdotL = localH.z * (VdotH * viewShortenFactor + LdotH) - NdotV * viewShortenFactor;
264264
// VNDF sampling guarantees that `VdotH` has same sign as `NdotV`
265265
// and `transmitted` controls the sign of `LdotH` relative to `VdotH` by construction (reflect -> same sign, or refract -> opposite sign)
266-
if ((ComputeMicrofacetNormal<scalar_type>::isTransmissionPath(NdotV, NdotL) != transmitted))
266+
if (ComputeMicrofacetNormal<scalar_type>::isTransmissionPath(NdotV, NdotL) != transmitted)
267267
return sample_type::createInvalid(); // should check if sample direction is invalid
268268

269269
cache = anisocache_type::createPartial(VdotH, LdotH, localH.z, transmitted, rcpEta);
270-
assert(cache.isValid());
270+
// assert(cache.isValid(fresnel.getRefractionOrientedEta())); TODO get clarification on case NdotV<0, transmitted=false (technically not TIR?)
271271

272272
struct reflect_refract_wrapper // so we don't recalculate LdotH
273273
{
@@ -287,9 +287,6 @@ struct SCookTorrance
287287

288288
const vector3_type T = interaction.getT();
289289
const vector3_type B = interaction.getB();
290-
291-
fresnel::OrientedEtas<monochrome_type> orientedEta = fresnel::OrientedEtas<monochrome_type>::create(scalar_type(1.0), hlsl::promote<monochrome_type>(fresnel.getRefractionOrientedEta()));
292-
assert(ComputeMicrofacetNormal::isValidMicrofacet(transmitted,cache.getVdotL(),localH.z,orientedEta));
293290
cache.fillTangents(T, B, H);
294291

295292
return sample_type::create(L, T, B, NdotL);

include/nbl/builtin/hlsl/bxdf/common.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,7 @@ struct SAnisotropicMicrofacetCache
828828
this_t retval;
829829
retval.iso_cache.VdotH = VdotH;
830830
retval.iso_cache.LdotH = LdotH;
831-
retval.iso_cache.VdotL = hlsl::mix(scalar_type(2.0) * retval.iso_cache.VdotH * retval.iso_cache.VdotH - scalar_type(1.0),
831+
retval.iso_cache.VdotL = hlsl::mix(scalar_type(2.0) * VdotH * VdotH - scalar_type(1.0),
832832
VdotH * (LdotH - rcpOrientedEta.value[0] + VdotH * rcpOrientedEta.value[0]), transmitted);
833833
assert(NdotH > scalar_type(0.0));
834834
retval.iso_cache.absNdotH = hlsl::abs(NdotH);

0 commit comments

Comments
 (0)