@@ -435,6 +435,8 @@ struct SLightSample
435435 }
436436 scalar_type getNdotL2 () NBL_CONST_MEMBER_FUNC { return NdotL2; }
437437
438+ bool isValid () NBL_CONST_MEMBER_FUNC { return !hlsl::all <vector <bool , 3 > >(hlsl::glsl::equal (L.getDirection (), hlsl::promote<vector3_type>(0.0 ))); }
439+
438440
439441 RayDirInfo L;
440442
@@ -509,16 +511,17 @@ struct SIsotropicMicrofacetCache
509511 // always valid because its specialized for the reflective case
510512 static this_t createForReflection (const scalar_type NdotV, const scalar_type NdotL, const scalar_type VdotL, NBL_REF_ARG (scalar_type) LplusV_rcpLen)
511513 {
512- LplusV_rcpLen = rsqrt<scalar_type>(2.0 + 2.0 * VdotL);
514+ scalar_type unoriented_LplusV_rcpLen = rsqrt<scalar_type>(2.0 + 2.0 * VdotL);
513515
514516 this_t retval;
515517 retval.VdotL = VdotL;
516- scalar_type NdotLVdotL = NdotL + NdotV;
517- LplusV_rcpLen = ieee754::flipSign<scalar_type>(LplusV_rcpLen, NdotLVdotL < scalar_type (0.0 ));
518- retval.VdotH = LplusV_rcpLen * VdotL + LplusV_rcpLen ;
518+ scalar_type NdotLplusVdotL = NdotL + NdotV;
519+ scalar_type oriented_LplusV_rcpLen = ieee754::flipSign<scalar_type>(unoriented_LplusV_rcpLen, NdotLplusVdotL < scalar_type (0.0 ));
520+ retval.VdotH = oriented_LplusV_rcpLen * VdotL + oriented_LplusV_rcpLen ;
519521 retval.LdotH = retval.VdotH;
520- retval.absNdotH = NdotLVdotL * LplusV_rcpLen ;
522+ retval.absNdotH = NdotLplusVdotL * oriented_LplusV_rcpLen ;
521523 retval.NdotH2 = retval.absNdotH * retval.absNdotH;
524+ LplusV_rcpLen = oriented_LplusV_rcpLen;
522525
523526 return retval;
524527 }
@@ -976,8 +979,6 @@ NBL_CONCEPT_END(
976979 ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((bxdf.eval (_sample, iso, isocache)), ::nbl::hlsl::is_same_v, typename T::spectral_type))
977980 ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((bxdf.pdf (iso, isocache)), ::nbl::hlsl::is_same_v, typename T::scalar_type))
978981 ((NBL_CONCEPT_REQ_EXPR_RET_TYPE)((bxdf.quotient_and_pdf (_sample, iso, isocache)), ::nbl::hlsl::is_same_v, typename T::quotient_pdf_type))
979- ((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(LightSample, typename T::sample_type))
980- ((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(concepts::FloatingPointLikeVectorial, typename T::spectral_type))
981982 ((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(surface_interactions::Isotropic, typename T::isotropic_interaction_type))
982983 ((NBL_CONCEPT_REQ_TYPE_ALIAS_CONCEPT)(CreatableIsotropicMicrofacetCache, typename T::isocache_type))
983984);
0 commit comments