Skip to content

Commit ee864a6

Browse files
committed
fixes ggx G2 using beta
1 parent c172b19 commit ee864a6

File tree

1 file changed

+6
-5
lines changed
  • include/nbl/builtin/hlsl/bxdf/ndf

1 file changed

+6
-5
lines changed

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ struct GGX
200200
return retval;
201201
}
202202

203+
// numerator is 2 * NdotV
203204
static scalar_type G1_wo_numerator(scalar_type NdotX, scalar_type devsh_part)
204205
{
205206
return scalar_type(1.0) / (NdotX + devsh_part);
@@ -296,9 +297,9 @@ struct GGX
296297
{
297298
if (NdotV < 1e-7 || NdotL < 1e-7)
298299
return 0.0;
299-
scalar_type onePlusLambda_V = scalar_type(0.5) * (devsh_v / NdotV + scalar_type(1.0));
300-
scalar_type onePlusLambda_L = scalar_type(0.5) * (devsh_l / NdotL + scalar_type(1.0));
301-
return bxdf::beta_wo_check<scalar_type>(onePlusLambda_L, onePlusLambda_V);
300+
scalar_type onePlusLambda_V = scalar_type(0.5) * (devsh_v + NdotV) / NdotV;
301+
scalar_type onePlusLambda_L = scalar_type(0.5) * (devsh_l + NdotL) / NdotL;
302+
return bxdf::beta_wo_check<scalar_type>(onePlusLambda_L, onePlusLambda_V) / (scalar_type(4.0) * NdotV * NdotL);
302303
}
303304
else
304305
{
@@ -352,8 +353,8 @@ struct GGX
352353
{
353354
if (NdotV < 1e-7 || NdotL < 1e-7)
354355
return 0.0;
355-
scalar_type onePlusLambda_V = scalar_type(0.5) * (devsh_v / NdotV + scalar_type(1.0));
356-
scalar_type onePlusLambda_L = scalar_type(0.5) * (devsh_l / NdotL + scalar_type(1.0));
356+
scalar_type onePlusLambda_V = scalar_type(0.5) * (devsh_v + NdotV) / NdotV;
357+
scalar_type onePlusLambda_L = scalar_type(0.5) * (devsh_l + NdotL) / NdotL;
357358
G2_over_G1 = bxdf::beta_wo_check<scalar_type>(onePlusLambda_L, onePlusLambda_V) * onePlusLambda_V;
358359
}
359360
else

0 commit comments

Comments
 (0)