Skip to content

Commit a77d59b

Browse files
committed
minor fixes to ndf
1 parent a08fdfc commit a77d59b

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -353,8 +353,8 @@ struct SCookTorrance
353353
fresnel_type _f = impl::getOrientedFresnel<fresnel_type, IsBSDF>::__call(fresnel, interaction.getNdotV());
354354

355355
const bool valid = impl::checkValid<fresnel_type, IsBSDF>::template __call<sample_type, Interaction, MicrofacetCache>(_f, _sample, interaction, cache);
356-
// assert(valid);
357-
356+
assert(valid);
357+
358358
scalar_type G2_over_G1 = scalar_type(1.0);
359359
if (_pdf < bit_cast<scalar_type>(numeric_limits<scalar_type>::infinity))
360360
{

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ struct BeckmannGenerateH
178178
scalar_type sample_x = hlsl::max(u.x, scalar_type(1e-6));
179179
scalar_type theta = hlsl::acos(cosTheta);
180180
scalar_type fit = 1.0 + theta * (-0.876 + theta * (0.4265 - 0.0594*theta));
181-
scalar_type b = c - (1.0 + c) * hlsl::pow(1.0-sample_x, fit);
181+
scalar_type b = c - (1.0 + c) * hlsl::pow(scalar_type(1.0)-sample_x, fit);
182182

183183
scalar_type normalization = 1.0 / (1.0 + c + numbers::inv_sqrtpi<scalar_type> * tanTheta * hlsl::exp(-cotTheta*cotTheta));
184184

@@ -208,8 +208,8 @@ struct BeckmannGenerateH
208208
}
209209

210210
scalar_type sinTheta = hlsl::sqrt(1.0 - V.z*V.z);
211-
scalar_type cosPhi = sinTheta==0.0 ? 1.0 : hlsl::clamp(V.x/sinTheta, -1.0, 1.0);
212-
scalar_type sinPhi = sinTheta==0.0 ? 0.0 : hlsl::clamp(V.y/sinTheta, -1.0, 1.0);
211+
scalar_type cosPhi = sinTheta==0.0 ? 1.0 : hlsl::clamp<scalar_type>(V.x/sinTheta, -1.0, 1.0);
212+
scalar_type sinPhi = sinTheta==0.0 ? 0.0 : hlsl::clamp<scalar_type>(V.y/sinTheta, -1.0, 1.0);
213213
//rotate
214214
scalar_type tmp = cosPhi*slope.x - sinPhi*slope.y;
215215
slope.y = sinPhi*slope.x + cosPhi*slope.y;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ struct GGXGenerateH
156156
scalar_type t1 = r * hlsl::cos(phi);
157157
scalar_type t2 = r * hlsl::sin(phi);
158158
scalar_type s = scalar_type(0.5) * (scalar_type(1.0) + V.z);
159-
t2 = hlsl::mix(hlsl::sqrt(scalar_type(1.0) - t1*t1), t2, s);
159+
t2 = (1-s) * hlsl::sqrt(scalar_type(1.0) - t1*t1) + t2 * s;
160160

161161
//reprojection onto hemisphere
162162
//found cases where t1*t1+t2*t2>1.0 due to fp32 precision issues, hence the max

0 commit comments

Comments
 (0)