Skip to content

Commit cb20f6b

Browse files
dielectric beckmann evaluation functions
1 parent bdf0d02 commit cb20f6b

File tree

10 files changed

+126
-96
lines changed

10 files changed

+126
-96
lines changed

examples_tests/42.FragmentShaderPathTracer/common.glsl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ BSDFNode bsdfs[BSDF_COUNT] = {
203203
{{uvec4(floatBitsToUint(vec3(1.02,1.02,1.3)),CONDUCTOR_OP),floatBitsToUint(vec4(1.0,1.0,2.0,0.0))}},
204204
{{uvec4(floatBitsToUint(vec3(1.02,1.3,1.02)),CONDUCTOR_OP),floatBitsToUint(vec4(1.0,2.0,1.0,0.0))}},
205205
{{uvec4(floatBitsToUint(vec3(1.02,1.3,1.02)),CONDUCTOR_OP),floatBitsToUint(vec4(1.0,2.0,1.0,0.15))}},
206-
{{uvec4(floatBitsToUint(vec3(1.4,1.45,1.5)),DIELECTRIC_OP),floatBitsToUint(vec4(0.0,0.0,0.0,0.125))}}
206+
{{uvec4(floatBitsToUint(vec3(1.4,1.45,1.5)),DIELECTRIC_OP),floatBitsToUint(vec4(0.0,0.0,0.0,0.0625))}}
207207
};
208208

209209

@@ -281,7 +281,7 @@ bool anyHitProgram(in ImmutableRay_t _immutable)
281281
}
282282

283283

284-
#define INTERSECTION_ERROR_BOUND_LOG2 (-9.0)
284+
#define INTERSECTION_ERROR_BOUND_LOG2 (-8.0)
285285
float getTolerance_common(in int depth)
286286
{
287287
float depthRcp = 1.0/float(depth);
@@ -398,7 +398,7 @@ vec3 irr_glsl_bsdf_cos_remainder_and_pdf(out float pdf, in irr_glsl_LightSample
398398
remainder = irr_glsl_ggx_cos_remainder_and_pdf_wo_clamps(pdf,irr_glsl_ggx_trowbridge_reitz(a2,_cache.isotropic.NdotH2),clampedNdotL,_sample.NdotL2,clampedNdotV,interaction.isotropic.NdotV_squared,reflectance,a2);
399399
break;
400400
default:
401-
remainder = vec3(irr_glsl_beckmann_dielectric_cos_remainder_and_pdf(pdf, _sample, interaction.isotropic, _cache.isotropic, monochromeEta, a2));
401+
remainder = vec3(irr_glsl_beckmann_aniso_cos_remainder_and_pdf(pdf, _sample, interaction, _cache, monochromeEta, a,a));
402402
break;
403403
}
404404
}

include/irr/builtin/glsl/bxdf/brdf/specular/beckmann.glsl

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ vec3 irr_glsl_beckmann_cos_generate_wo_clamps(in vec3 localV, in vec2 u, in floa
5959

6060
b -= value/derivative;
6161
}
62+
// TODO: investigate if we can replace these two erf^-1 calls with a box muller transform
6263
slope.x = irr_glsl_erfInv(b);
6364
slope.y = irr_glsl_erfInv(2.0 * max(u.y,1.0e-6) - 1.0);
6465
}
@@ -77,6 +78,7 @@ vec3 irr_glsl_beckmann_cos_generate_wo_clamps(in vec3 localV, in vec2 u, in floa
7778
return normalize(vec3(-slope, 1.0));
7879
}
7980

81+
// TODO: unifty the two following functions into `irr_glsl_microfacet_BRDF_cos_generate_wo_clamps(vec3 H,...)` and `irr_glsl_microfacet_BRDF_cos_generate` or at least a auto declaration macro in lieu of a template
8082
irr_glsl_LightSample irr_glsl_beckmann_cos_generate_wo_clamps(in vec3 localV, in mat3 m, in vec2 u, in float ax, in float ay, out irr_glsl_AnisotropicMicrofacetCache _cache)
8183
{
8284
const vec3 H = irr_glsl_beckmann_cos_generate_wo_clamps(localV,u,ax,ay);
@@ -193,24 +195,21 @@ vec3 irr_glsl_beckmann_aniso_cos_remainder_and_pdf(out float pdf, in irr_glsl_Li
193195

194196

195197

196-
float irr_glsl_beckmann_height_correlated_cos_eval_DG_wo_clamps(in float NdotH2, in float NdotL2, in float maxNdotV, in float NdotV2, in float a2)
198+
float irr_glsl_beckmann_height_correlated_cos_eval_DG_wo_clamps(in float NdotH2, in float NdotL2, in float NdotV2, in float a2)
197199
{
198-
float ndf = irr_glsl_beckmann(a2, NdotH2);
199-
float scalar_part = ndf / (4.0 * maxNdotV);
200+
float NG = irr_glsl_beckmann(a2, NdotH2);
200201
if (a2>FLT_MIN)
201-
{
202-
float g = irr_glsl_beckmann_smith_correlated(NdotV2, NdotL2, a2);
203-
scalar_part *= g;
204-
}
202+
NG *= irr_glsl_beckmann_smith_correlated(NdotV2, NdotL2, a2);
205203

206-
return scalar_part;
204+
return NG;
207205
}
208206
vec3 irr_glsl_beckmann_height_correlated_cos_eval_wo_clamps(in float NdotH2, in float NdotL2, in float maxNdotV, in float NdotV2, in float VdotH, in mat2x3 ior, in float a2)
209207
{
210-
float scalar_part = irr_glsl_beckmann_height_correlated_cos_eval_DG_wo_clamps(NdotH2, NdotL2, maxNdotV, NdotV2, a2);
211-
vec3 fr = irr_glsl_fresnel_conductor(ior[0], ior[1], VdotH);
212-
213-
return scalar_part*fr;
208+
const float scalar_part = irr_glsl_beckmann_height_correlated_cos_eval_DG_wo_clamps(NdotH2, NdotL2, NdotV2, a2);
209+
210+
const vec3 fr = irr_glsl_fresnel_conductor(ior[0], ior[1], VdotH);
211+
212+
return fr*irr_glsl_microfacet_to_light_measure_transform(scalar_part,maxNdotV);
214213
}
215214
vec3 irr_glsl_beckmann_height_correlated_cos_eval(in irr_glsl_LightSample _sample, in irr_glsl_IsotropicViewSurfaceInteraction interaction, in irr_glsl_IsotropicMicrofacetCache _cache, in mat2x3 ior, in float a2)
216215
{
@@ -220,24 +219,21 @@ vec3 irr_glsl_beckmann_height_correlated_cos_eval(in irr_glsl_LightSample _sampl
220219
return vec3(0.0);
221220
}
222221

223-
float irr_glsl_beckmann_aniso_height_correlated_cos_eval_DG_wo_clamps(in float NdotH2, in float TdotH2, in float BdotH2, in float NdotL2, in float TdotL2, in float BdotL2, in float maxNdotV, in float NdotV2, in float TdotV2, in float BdotV2, in float ax, in float ax2, in float ay, in float ay2)
222+
float irr_glsl_beckmann_aniso_height_correlated_cos_eval_DG_wo_clamps(in float NdotH2, in float TdotH2, in float BdotH2, in float NdotL2, in float TdotL2, in float BdotL2, in float NdotV2, in float TdotV2, in float BdotV2, in float ax, in float ax2, in float ay, in float ay2)
224223
{
225-
float ndf = irr_glsl_beckmann(ax, ay, ax2, ay2, TdotH2, BdotH2, NdotH2);
226-
float scalar_part = ndf / (4.0 * maxNdotV);
224+
float NG = irr_glsl_beckmann(ax, ay, ax2, ay2, TdotH2, BdotH2, NdotH2);
227225
if (ax>FLT_MIN || ay>FLT_MIN)
228-
{
229-
float g = irr_glsl_beckmann_smith_correlated(TdotV2, BdotV2, NdotV2, TdotL2, BdotL2, NdotL2, ax2, ay2);
230-
scalar_part *= g;
231-
}
226+
NG *= irr_glsl_beckmann_smith_correlated(TdotV2, BdotV2, NdotV2, TdotL2, BdotL2, NdotL2, ax2, ay2);
232227

233-
return scalar_part;
228+
return NG;
234229
}
235230
vec3 irr_glsl_beckmann_aniso_height_correlated_cos_eval_wo_clamps(in float NdotH2, in float TdotH2, in float BdotH2, in float NdotL2, in float TdotL2, in float BdotL2, in float maxNdotV, in float NdotV2, in float TdotV2, in float BdotV2, in float VdotH, in mat2x3 ior, in float ax, in float ax2, in float ay, in float ay2)
236231
{
237-
float scalar_part = irr_glsl_beckmann_aniso_height_correlated_cos_eval_DG_wo_clamps(NdotH2,TdotH2,BdotH2, NdotL2,TdotL2,BdotL2, maxNdotV,NdotV2,TdotV2,BdotV2, ax, ax2, ay, ay2);
238-
vec3 fr = irr_glsl_fresnel_conductor(ior[0], ior[1], VdotH);
232+
const float scalar_part = irr_glsl_beckmann_aniso_height_correlated_cos_eval_DG_wo_clamps(NdotH2,TdotH2,BdotH2, NdotL2,TdotL2,BdotL2, NdotV2,TdotV2,BdotV2, ax, ax2, ay, ay2);
233+
234+
const vec3 fr = irr_glsl_fresnel_conductor(ior[0], ior[1], VdotH);
239235

240-
return scalar_part*fr;
236+
return fr*irr_glsl_microfacet_to_light_measure_transform(scalar_part,maxNdotV);
241237
}
242238
vec3 irr_glsl_beckmann_aniso_height_correlated_cos_eval(in irr_glsl_LightSample _sample, in irr_glsl_AnisotropicViewSurfaceInteraction interaction, in irr_glsl_AnisotropicMicrofacetCache _cache, in mat2x3 ior, in float ax, in float ay)
243239
{

include/irr/builtin/glsl/bxdf/bsdf/specular/beckmann.glsl

Lines changed: 86 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,9 @@ float irr_glsl_beckmann_dielectric_cos_remainder_and_pdf(out float pdf, in irr_g
6767
{
6868
const float ndf = irr_glsl_beckmann(a2,_cache.NdotH2);
6969

70-
float orientedEta, rcpOrientedEta;
71-
const bool backside = irr_glsl_getOrientedEtas(orientedEta, rcpOrientedEta, _cache.VdotH, eta);
70+
float orientedEta, dummy;
71+
const bool backside = irr_glsl_getOrientedEtas(orientedEta, dummy, _cache.VdotH, eta);
7272
const float orientedEta2 = orientedEta*orientedEta;
73-
const float rcpOrientedEta2 = rcpOrientedEta*rcpOrientedEta;
7473

7574
const float VdotHLdotH = _cache.VdotH*_cache.LdotH;
7675
const bool transmitted = VdotHLdotH<0.0;
@@ -81,78 +80,115 @@ float irr_glsl_beckmann_dielectric_cos_remainder_and_pdf(out float pdf, in irr_g
8180
return irr_glsl_beckmann_dielectric_cos_remainder_and_pdf_wo_clamps(pdf, ndf, transmitted, _sample.NdotL2, absNdotV, interaction.NdotV_squared, _cache.VdotH, _cache.LdotH, VdotHLdotH, reflectance, orientedEta, a2);
8281
}
8382

84-
#if 0
85-
// TODO
86-
vec3 irr_glsl_beckmann_aniso_cos_remainder_and_pdf_wo_clamps(out float pdf, in float ndf, in float maxNdotL, in float NdotL2, in float TdotL2, in float BdotL2, in float maxNdotV, in float TdotV2, in float BdotV2, in float NdotV2, in float VdotH, in mat2x3 ior, in float ax2, in float ay2)
87-
{
88-
float c2 = irr_glsl_smith_beckmann_C2(TdotV2, BdotV2, NdotV2, ax2, ay2);
89-
float lambda_V = irr_glsl_smith_beckmann_Lambda(c2);
90-
float onePlusLambda_V = 1.0 + lambda_V;
91-
92-
float G1 = 1.0 / onePlusLambda_V;
93-
pdf = ndf * G1 * 0.25 / maxNdotV;
9483

95-
float G2_over_G1 = irr_glsl_beckmann_smith_G2_over_G1(onePlusLambda_V, maxNdotL, TdotL2, BdotL2, NdotL2, ax2, ay2);
96-
97-
vec3 fr = irr_glsl_fresnel_conductor(ior[0], ior[1], VdotH);
98-
return fr * G2_over_G1;
99-
}
100-
vec3 irr_glsl_beckmann_aniso_cos_remainder_and_pdf(out float pdf, in irr_glsl_BSDFSample s, in irr_glsl_AnisotropicViewSurfaceInteraction interaction, in mat2x3 ior, in float ax, in float ax2, in float ay, in float ay2)
84+
float irr_glsl_beckmann_aniso_dielectric_cos_remainder_and_pdf_wo_clamps(out float pdf, in float ndf, in bool transmitted, in float NdotL2, in float TdotL2, in float BdotL2, in float absNdotV, in float TdotV2, in float BdotV2, in float NdotV2, in float VdotH, in float LdotH, in float VdotHLdotH, in float reflectance, in float orientedEta, in float ax2, in float ay2)
10185
{
102-
const float NdotH2 = s.NdotH * s.NdotH;
103-
const float TdotH2 = s.TdotH * s.TdotH;
104-
const float BdotH2 = s.BdotH * s.BdotH;
86+
float onePlusLambda_V;
87+
pdf = irr_glsl_beckmann_dielectric_pdf_wo_clamps(transmitted,reflectance, ndf,absNdotV,TdotV2,BdotV2,NdotV2, VdotH,LdotH,VdotHLdotH, ax2,ay2,orientedEta,onePlusLambda_V);
10588

106-
const float NdotL2 = s.NdotL * s.NdotL;
107-
const float TdotL2 = s.TdotL * s.TdotL;
108-
const float BdotL2 = s.BdotL * s.BdotL;
89+
return irr_glsl_beckmann_smith_G2_over_G1(onePlusLambda_V, TdotL2, BdotL2, NdotL2, ax2, ay2);
90+
}
91+
float irr_glsl_beckmann_aniso_cos_remainder_and_pdf(out float pdf, in irr_glsl_LightSample _sample, in irr_glsl_AnisotropicViewSurfaceInteraction interaction, in irr_glsl_AnisotropicMicrofacetCache _cache, in float eta, in float ax, in float ay)
92+
{
93+
const float ax2 = ax*ax;
94+
const float ay2 = ay*ay;
95+
const float TdotH2 = _cache.TdotH*_cache.TdotH;
96+
const float BdotH2 = _cache.BdotH*_cache.BdotH;
97+
const float ndf = irr_glsl_beckmann(ax,ay,ax2,ay2, TdotH2,BdotH2,_cache.isotropic.NdotH2);
98+
99+
const float NdotL2 = _sample.NdotL*_sample.NdotL;
100+
const float TdotL2 = _sample.TdotL*_sample.TdotL;
101+
const float BdotL2 = _sample.BdotL*_sample.BdotL;
109102

110-
const float TdotV2 = interaction.TdotV * interaction.TdotV;
111-
const float BdotV2 = interaction.BdotV * interaction.BdotV;
103+
const float TdotV2 = interaction.TdotV*interaction.TdotV;
104+
const float BdotV2 = interaction.BdotV*interaction.BdotV;
112105

113-
const float ndf = irr_glsl_beckmann(ax, ay, ax2, ay2, TdotH2, BdotH2, NdotH2);
106+
const float VdotH = _cache.isotropic.VdotH;
114107

115-
return irr_glsl_beckmann_aniso_cos_remainder_and_pdf_wo_clamps(pdf, ndf, max(s.NdotL,0.0), NdotL2,TdotL2,BdotL2, max(interaction.isotropic.NdotV,0.0),TdotV2,BdotV2, interaction.isotropic.NdotV_squared, s.VdotH, ior, ax2, ay2);
108+
float orientedEta, dummy;
109+
const bool backside = irr_glsl_getOrientedEtas(orientedEta, dummy, VdotH, eta);
110+
const float orientedEta2 = orientedEta*orientedEta;
111+
112+
const float VdotHLdotH = VdotH*_cache.isotropic.LdotH;
113+
const bool transmitted = VdotHLdotH<0.0;
114+
115+
const float reflectance = irr_glsl_fresnel_dielectric_common(orientedEta2,abs(VdotH));
116+
return irr_glsl_beckmann_aniso_dielectric_cos_remainder_and_pdf_wo_clamps(pdf, ndf, transmitted, NdotL2,TdotL2,BdotL2, abs(interaction.isotropic.NdotV),TdotV2,BdotV2, interaction.isotropic.NdotV_squared, VdotH,_cache.isotropic.LdotH,VdotHLdotH, reflectance,orientedEta, ax2,ay2);
116117
}
117118

118119

119120

120-
vec3 irr_glsl_beckmann_smith_height_correlated_cos_eval_wo_clamps(in float NdotH2, in float NdotL2, in float maxNdotV, in float NdotV2, in float VdotH, in mat2x3 ior, in float a2)
121+
float irr_glsl_beckmann_smith_height_correlated_dielectric_cos_eval_wo_clamps(
122+
in float NdotH2, in float NdotL2, in float absNdotV, in float NdotV2,
123+
in bool transmitted, in float VdotH, in float LdotH, in float VdotHLdotH,
124+
in float orientedEta, in float orientedEta2, in float a2)
121125
{
122-
float scalar_part = irr_glsl_beckmann_smith_height_correlated_cos_eval_DG_wo_clamps(NdotH2, NdotL2, maxNdotV, NdotV2, a2);
123-
vec3 fr = irr_glsl_fresnel_conductor(ior[0], ior[1], VdotH);
126+
const float scalar_part = irr_glsl_beckmann_height_correlated_cos_eval_DG_wo_clamps(NdotH2, NdotL2, NdotV2, a2);
124127

125-
return scalar_part*fr;
128+
const float reflectance = irr_glsl_fresnel_dielectric_common(orientedEta2,abs(VdotH));
129+
130+
return reflectance*irr_glsl_microfacet_to_light_measure_transform(scalar_part,absNdotV,transmitted,VdotH,LdotH,VdotHLdotH,orientedEta);
126131
}
127-
vec3 irr_glsl_beckmann_smith_height_correlated_cos_eval(in irr_glsl_BSDFIsotropicParams params, in irr_glsl_IsotropicViewSurfaceInteraction interaction, in mat2x3 ior, in float a2)
132+
133+
// before calling you must ensure that `irr_glsl_AnisotropicMicrofacetCache` is valid (if a given V vector can "see" the L vector)
134+
float irr_glsl_beckmann_smith_height_correlated_dielectric_cos_eval_wo_cache_validation(in irr_glsl_LightSample _sample, in irr_glsl_IsotropicViewSurfaceInteraction interaction, in irr_glsl_IsotropicMicrofacetCache _cache, in float eta, in float a2)
128135
{
129-
const float NdotH2 = params.NdotH * params.NdotH;
136+
float orientedEta, dummy;
137+
const bool backside = irr_glsl_getOrientedEtas(orientedEta, dummy, _cache.VdotH, eta);
138+
const float orientedEta2 = orientedEta*orientedEta;
139+
140+
const float VdotHLdotH = _cache.VdotH*_cache.LdotH;
141+
const bool transmitted = VdotHLdotH<0.0;
130142

131-
return irr_glsl_beckmann_smith_height_correlated_cos_eval_wo_clamps(NdotH2,params.NdotL_squared,max(interaction.NdotV,0.0),interaction.NdotV_squared,params.VdotH,ior,a2);
143+
return irr_glsl_beckmann_smith_height_correlated_dielectric_cos_eval_wo_clamps(
144+
_cache.NdotH2,_sample.NdotL2,abs(interaction.NdotV),interaction.NdotV_squared,
145+
transmitted,_cache.VdotH,_cache.LdotH,VdotHLdotH,
146+
orientedEta,orientedEta2,a2);
132147
}
133148

134149

135-
vec3 irr_glsl_beckmann_aniso_smith_height_correlated_cos_eval_wo_clamps(in float NdotH2, in float TdotH2, in float BdotH2, in float NdotL2, in float TdotL2, in float BdotL2, in float maxNdotV, in float NdotV2, in float TdotV2, in float BdotV2, in float VdotH, in mat2x3 ior, in float ax, in float ax2, in float ay, in float ay2)
150+
float irr_glsl_beckmann_aniso_smith_height_correlated_dielectric_cos_eval_wo_clamps(
151+
in float NdotH2, in float TdotH2, in float BdotH2,
152+
in float NdotL2, in float TdotL2, in float BdotL2,
153+
in float absNdotV, in float NdotV2, in float TdotV2, in float BdotV2,
154+
in bool transmitted, in float VdotH, in float LdotH, in float VdotHLdotH,
155+
in float orientedEta, in float orientedEta2,
156+
in float ax, in float ax2, in float ay, in float ay2)
136157
{
137-
float scalar_part = irr_glsl_beckmann_aniso_smith_height_correlated_cos_eval_DG_wo_clamps(NdotH2,TdotH2,BdotH2, NdotL2,TdotL2,BdotL2, maxNdotV,NdotV2,TdotV2,BdotV2, ax, ax2, ay, ay2);
138-
vec3 fr = irr_glsl_fresnel_conductor(ior[0], ior[1], VdotH);
158+
const float scalar_part = irr_glsl_beckmann_aniso_height_correlated_cos_eval_DG_wo_clamps(NdotH2,TdotH2,BdotH2, NdotL2,TdotL2,BdotL2, NdotV2,TdotV2,BdotV2, ax, ax2, ay, ay2);
159+
160+
const float reflectance = irr_glsl_fresnel_dielectric_common(orientedEta2,abs(VdotH));
139161

140-
return scalar_part*fr;
162+
return reflectance*irr_glsl_microfacet_to_light_measure_transform(scalar_part,absNdotV,transmitted,VdotH,LdotH,VdotHLdotH,orientedEta);
141163
}
142-
vec3 irr_glsl_beckmann_aniso_smith_height_correlated_cos_eval(in irr_glsl_BSDFAnisotropicParams params, in irr_glsl_AnisotropicViewSurfaceInteraction interaction, in mat2x3 ior, in float ax, in float ax2, in float ay, in float ay2)
164+
165+
// before calling you must ensure that `irr_glsl_AnisotropicMicrofacetCache` is valid (if a given V vector can "see" the L vector)
166+
float irr_glsl_beckmann_aniso_smith_height_correlated_cos_eval_wo_cache_validation(in irr_glsl_LightSample _sample, in irr_glsl_AnisotropicViewSurfaceInteraction interaction, in irr_glsl_AnisotropicMicrofacetCache _cache, in float eta, in float ax, in float ax2, in float ay, in float ay2)
143167
{
144-
const float NdotH2 = params.isotropic.NdotH * params.isotropic.NdotH;
145-
const float TdotH2 = params.TdotH * params.TdotH;
146-
const float BdotH2 = params.BdotH * params.BdotH;
168+
const float TdotH2 = _cache.TdotH*_cache.TdotH;
169+
const float BdotH2 = _cache.BdotH*_cache.BdotH;
170+
171+
const float TdotL2 = _sample.TdotL*_sample.TdotL;
172+
const float BdotL2 = _sample.BdotL*_sample.BdotL;
147173

148-
const float TdotL2 = params.TdotL * params.TdotL;
149-
const float BdotL2 = params.BdotL * params.BdotL;
174+
const float TdotV2 = interaction.TdotV*interaction.TdotV;
175+
const float BdotV2 = interaction.BdotV*interaction.BdotV;
150176

151-
const float TdotV2 = interaction.TdotV * interaction.TdotV;
152-
const float BdotV2 = interaction.BdotV * interaction.BdotV;
177+
const float VdotH = _cache.isotropic.VdotH;
153178

154-
return irr_glsl_beckmann_aniso_smith_height_correlated_cos_eval_wo_clamps(NdotH2,TdotH2,BdotH2, params.isotropic.NdotL_squared,TdotL2,BdotL2, max(interaction.isotropic.NdotV,0.0),interaction.isotropic.NdotV_squared,TdotV2,BdotV2, params.isotropic.VdotH, ior,ax,ax2,ay,ay2);
179+
float orientedEta, dummy;
180+
const bool backside = irr_glsl_getOrientedEtas(orientedEta, dummy, VdotH, eta);
181+
const float orientedEta2 = orientedEta*orientedEta;
182+
183+
const float VdotHLdotH = VdotH*_cache.isotropic.LdotH;
184+
const bool transmitted = VdotHLdotH<0.0;
185+
186+
return irr_glsl_beckmann_aniso_smith_height_correlated_dielectric_cos_eval_wo_clamps(
187+
_cache.isotropic.NdotH2,TdotH2,BdotH2,
188+
_sample.NdotL2,TdotL2,BdotL2,
189+
abs(interaction.isotropic.NdotV),interaction.isotropic.NdotV_squared,TdotV2,BdotV2,
190+
transmitted,VdotH,_cache.isotropic.LdotH,VdotHLdotH,
191+
orientedEta,orientedEta2,ax,ax*ax,ay,ay*ay);
155192
}
156-
#endif
157193

158194
#endif

include/irr/builtin/glsl/bxdf/bsdf/specular/common.glsl

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,4 @@
77
#include <irr/builtin/glsl/bxdf/fresnel.glsl>
88

99

10-
float irr_glsl_smith_VNDF_pdf_wo_clamps(in float ndf, in float lambda_V, in float absNdotV, in bool transmitted, in float VdotH, in float LdotH, in float VdotHLdotH, in float orientedEta, in float reflectance, out float onePlusLambda_V)
11-
{
12-
onePlusLambda_V = 1.0+lambda_V;
13-
14-
float denominator = absNdotV*onePlusLambda_V;
15-
if (transmitted)
16-
{
17-
const float VdotH_etaLdotH = (VdotH+orientedEta*LdotH);
18-
denominator *= VdotH_etaLdotH*VdotH_etaLdotH;
19-
}
20-
// VdotHLdotH is negative under transmission, so thats why fresnel transmission has a negative form
21-
return ndf*(transmitted ? VdotHLdotH:0.25)*(transmitted ? (reflectance-1.0):reflectance)/denominator;
22-
}
23-
2410
#endif

include/irr/builtin/glsl/bxdf/geom/smith/common.glsl

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
#ifndef _IRR_BXDF_GEOM_SMITH_COMMON_INCLUDED_
2-
#define _IRR_BXDF_GEOM_SMITH_COMMON_INCLUDED_
1+
#ifndef _IRR_BUILTIN_GLSL_BXDF_GEOM_SMITH_COMMON_INCLUDED_
2+
#define _IRR_BUILTIN_GLSL_BXDF_GEOM_SMITH_COMMON_INCLUDED_
3+
4+
#include <irr/builtin/glsl/bxdf/ndf/common.glsl>
35

46
float irr_glsl_smith_G1(in float lambda)
57
{
@@ -13,4 +15,11 @@ float irr_glsl_smith_VNDF_pdf_wo_clamps(in float ndf, in float lambda_V, in floa
1315
return ndf*0.25/(maxNdotV*onePlusLambda_V);
1416
}
1517

18+
float irr_glsl_smith_VNDF_pdf_wo_clamps(in float ndf, in float lambda_V, in float absNdotV, in bool transmitted, in float VdotH, in float LdotH, in float VdotHLdotH, in float orientedEta, in float reflectance, out float onePlusLambda_V)
19+
{
20+
onePlusLambda_V = 1.0+lambda_V;
21+
22+
return irr_glsl_microfacet_to_light_measure_transform((transmitted ? (1.0-reflectance):reflectance)*ndf/onePlusLambda_V,absNdotV,transmitted,VdotH,LdotH,VdotHLdotH,orientedEta);
23+
}
24+
1625
#endif

include/irr/builtin/glsl/bxdf/geom/smith/ggx.glsl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
#ifndef _IRR_BXDF_GEOM_SMITH_GGX_INCLUDED_
2-
#define _IRR_BXDF_GEOM_SMITH_GGX_INCLUDED_
3-
1+
#ifndef _IRR_BUILTIN_GLSL_BXDF_GEOM_SMITH_GGX_INCLUDED_
2+
#define _IRR_BUILTIN_GLSL_BXDF_GEOM_SMITH_GGX_INCLUDED_
43

54
float irr_glsl_smith_ggx_devsh_part(in float NdotX2, in float a2, in float one_minus_a2)
65
{

0 commit comments

Comments
 (0)