Skip to content

Commit b993e47

Browse files
committed
pdf should return inf when smooth cook torrance bxdf
1 parent 2a08728 commit b993e47

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ struct SCookTorrance
139139

140140
quant_type D = ndf.template D<sample_type, Interaction, MicrofacetCache>(qq, _sample, interaction, cache);
141141
scalar_type DG = D.projectedLightMeasure;
142-
if (D.microfacetMeasure < numeric_limits<scalar_type>::infinity)
142+
if (D.microfacetMeasure < bit_cast<scalar_type>(numeric_limits<scalar_type>::infinity))
143143
{
144144
g2g1_query_type gq = ndf.template createG2G1Query<sample_type, Interaction>(_sample, interaction);
145145
DG *= ndf.template correlated<sample_type, Interaction>(gq, _sample, interaction);

include/nbl/builtin/hlsl/bxdf/ndf/beckmann.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ struct BeckmannCommon<T,false NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar<
9090
scalar_type NdotH2 = cache.getNdotH2();
9191
scalar_type nom = exp2<scalar_type>((NdotH2 - scalar_type(1.0)) / (log<scalar_type>(2.0) * a2 * NdotH2));
9292
scalar_type denom = a2 * NdotH2 * NdotH2;
93-
return numbers::inv_pi<scalar_type> * nom / denom;
93+
return hlsl::mix(bit_cast<scalar_type>(numeric_limits<scalar_type>::infinity), numbers::inv_pi<scalar_type> * nom / denom, a2 > numeric_limits<scalar_type>::min);
9494
}
9595

9696
template<class Query NBL_FUNC_REQUIRES(beckmann_concepts::DG1Query<Query>)
@@ -146,7 +146,7 @@ struct BeckmannCommon<T,true NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar<T
146146
scalar_type NdotH2 = cache.getNdotH2();
147147
scalar_type nom = exp<scalar_type>(-(cache.getTdotH2() / ax2 + cache.getBdotH2() / ay2) / NdotH2);
148148
scalar_type denom = a2 * NdotH2 * NdotH2;
149-
return numbers::inv_pi<scalar_type> * nom / denom;
149+
return hlsl::mix(bit_cast<scalar_type>(numeric_limits<scalar_type>::infinity), numbers::inv_pi<scalar_type> * nom / denom, a2 > numeric_limits<scalar_type>::min);
150150
}
151151

152152
template<class Query NBL_FUNC_REQUIRES(beckmann_concepts::DG1Query<Query>)

include/nbl/builtin/hlsl/bxdf/ndf/ggx.hlsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct GGXCommon<T,IsBSDF,false NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScala
9191
scalar_type D(NBL_CONST_REF_ARG(MicrofacetCache) cache)
9292
{
9393
scalar_type denom = scalar_type(1.0) - one_minus_a2 * cache.getNdotH2();
94-
return a2 * numbers::inv_pi<scalar_type> / (denom * denom);
94+
return hlsl::mix(bit_cast<scalar_type>(numeric_limits<scalar_type>::infinity), a2 * numbers::inv_pi<scalar_type> / (denom * denom), a2 > numeric_limits<scalar_type>::min);
9595
}
9696

9797
template<class Query NBL_FUNC_REQUIRES(ggx_concepts::DG1Query<Query>)
@@ -173,7 +173,7 @@ struct GGXCommon<T,IsBSDF,true NBL_PARTIAL_REQ_BOT(concepts::FloatingPointScalar
173173
scalar_type D(NBL_CONST_REF_ARG(MicrofacetCache) cache)
174174
{
175175
scalar_type denom = cache.getTdotH2() / ax2 + cache.getBdotH2() / ay2 + cache.getNdotH2();
176-
return numbers::inv_pi<scalar_type> / (a2 * denom * denom);
176+
return hlsl::mix(bit_cast<scalar_type>(numeric_limits<scalar_type>::infinity), numbers::inv_pi<scalar_type> / (a2 * denom * denom), a2 > numeric_limits<scalar_type>::min);
177177
}
178178

179179
// TODO: potential idea for making GGX spin using covariance matrix of sorts: https://www.desmos.com/3d/weq2ginq9o

0 commit comments

Comments
 (0)