@@ -141,41 +141,41 @@ float irr_glsl_ggx_pdf_wo_clamps(in float ndf, in float devsh_v, in float maxNdo
141
141
}
142
142
float irr_glsl_ggx_pdf_wo_clamps(in float NdotH2, in float maxNdotV, in float NdotV2, in float a2)
143
143
{
144
- float ndf = irr_glsl_ggx_trowbridge_reitz(a2, NdotH2);
145
- float devsh_v = irr_glsl_smith_ggx_devsh_part(NdotV2, a2, 1.0 - a2);
144
+ const float ndf = irr_glsl_ggx_trowbridge_reitz(a2, NdotH2);
145
+ const float devsh_v = irr_glsl_smith_ggx_devsh_part(NdotV2, a2, 1.0 - a2);
146
146
147
147
return irr_glsl_ggx_pdf_wo_clamps(ndf, devsh_v, maxNdotV);
148
148
}
149
149
150
150
float irr_glsl_ggx_pdf_wo_clamps(in float NdotH2, in float TdotH2, in float BdotH2, in float maxNdotV, in float NdotV2, in float TdotV2, in float BdotV2, in float ax, in float ay, in float ax2, in float ay2)
151
151
{
152
- float ndf = irr_glsl_ggx_aniso(TdotH2,BdotH2,NdotH2, ax, ay, ax2, ay2);
153
- float devsh_v = irr_glsl_smith_ggx_devsh_part(TdotV2, BdotV2, NdotV2, ax2, ay2);
152
+ const float ndf = irr_glsl_ggx_aniso(TdotH2,BdotH2,NdotH2, ax, ay, ax2, ay2);
153
+ const float devsh_v = irr_glsl_smith_ggx_devsh_part(TdotV2, BdotV2, NdotV2, ax2, ay2);
154
154
155
155
return irr_glsl_ggx_pdf_wo_clamps(ndf, devsh_v, maxNdotV);
156
156
}
157
157
158
158
159
159
160
- vec3 irr_glsl_ggx_cos_remainder_and_pdf_wo_clamps(out float pdf, in float ndf, in float maxNdotL, in float NdotL2, in float maxNdotV, in float NdotV2, in float VdotH, in mat2x3 ior , in float a2)
160
+ vec3 irr_glsl_ggx_cos_remainder_and_pdf_wo_clamps(out float pdf, in float ndf, in float maxNdotL, in float NdotL2, in float maxNdotV, in float NdotV2, in float VdotH, in vec3 reflectance , in float a2)
161
161
{
162
162
float one_minus_a2 = 1.0 - a2;
163
163
float devsh_v = irr_glsl_smith_ggx_devsh_part(NdotV2, a2, one_minus_a2);
164
164
pdf = irr_glsl_ggx_pdf_wo_clamps(ndf, devsh_v, maxNdotV);
165
165
166
166
float G2_over_G1 = irr_glsl_ggx_smith_G2_over_G1_devsh(maxNdotL, NdotL2, maxNdotV, devsh_v, a2, one_minus_a2);
167
167
168
- vec3 fr = irr_glsl_fresnel_conductor(ior[0 ], ior[1 ], VdotH);
169
- return fr * G2_over_G1;
168
+ return reflectance * G2_over_G1;
170
169
}
171
170
172
171
vec3 irr_glsl_ggx_cos_remainder_and_pdf(out float pdf, in irr_glsl_LightSample _sample, in irr_glsl_IsotropicViewSurfaceInteraction interaction, in irr_glsl_IsotropicMicrofacetCache _cache, in mat2x3 ior, in float a2)
173
172
{
174
173
if (_sample.NdotL> FLT_MIN && interaction.NdotV> FLT_MIN)
175
174
{
176
175
const float ndf = irr_glsl_ggx_trowbridge_reitz(a2, _cache.NdotH2);
176
+ const vec3 reflectance = irr_glsl_fresnel_conductor(ior[0 ], ior[1 ], _cache.VdotH);
177
177
178
- return irr_glsl_ggx_cos_remainder_and_pdf_wo_clamps(pdf, ndf, max (_sample.NdotL,0.0 ), _sample.NdotL2, max (interaction.NdotV,0.0 ), interaction.NdotV_squared, _cache.VdotH, ior , a2);
178
+ return irr_glsl_ggx_cos_remainder_and_pdf_wo_clamps(pdf, ndf, max (_sample.NdotL,0.0 ), _sample.NdotL2, max (interaction.NdotV,0.0 ), interaction.NdotV_squared, _cache.VdotH, reflectance , a2);
179
179
}
180
180
else
181
181
{
@@ -185,19 +185,18 @@ vec3 irr_glsl_ggx_cos_remainder_and_pdf(out float pdf, in irr_glsl_LightSample _
185
185
}
186
186
187
187
188
- vec3 irr_glsl_ggx_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)
188
+ vec3 irr_glsl_ggx_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 vec3 reflectance , in float ax2,in float ay2)
189
189
{
190
- float devsh_v = irr_glsl_smith_ggx_devsh_part(TdotV2, BdotV2, NdotV2, ax2, ay2);
190
+ const float devsh_v = irr_glsl_smith_ggx_devsh_part(TdotV2, BdotV2, NdotV2, ax2, ay2);
191
191
pdf = irr_glsl_ggx_pdf_wo_clamps(ndf, devsh_v, maxNdotV);
192
192
193
- float G2_over_G1 = irr_glsl_ggx_smith_G2_over_G1_devsh(
193
+ const float G2_over_G1 = irr_glsl_ggx_smith_G2_over_G1_devsh(
194
194
maxNdotL, TdotL2,BdotL2,NdotL2,
195
195
maxNdotV, devsh_v,
196
196
ax2, ay2
197
197
);
198
198
199
- vec3 fr = irr_glsl_fresnel_conductor(ior[0 ], ior[1 ], VdotH);
200
- return fr * G2_over_G1;
199
+ return reflectance * G2_over_G1;
201
200
}
202
201
203
202
vec3 irr_glsl_ggx_aniso_cos_remainder_and_pdf(out float pdf, in irr_glsl_LightSample _sample, in irr_glsl_AnisotropicViewSurfaceInteraction interaction, in irr_glsl_AnisotropicMicrofacetCache _cache, in mat2x3 ior, in float ax, in float ay)
@@ -213,12 +212,12 @@ vec3 irr_glsl_ggx_aniso_cos_remainder_and_pdf(out float pdf, in irr_glsl_LightSa
213
212
const float TdotV2 = interaction.TdotV* interaction.TdotV;
214
213
const float BdotV2 = interaction.BdotV* interaction.BdotV;
215
214
216
- float ax2 = ax* ax;
217
- float ay2 = ay* ay;
218
- float ndf = irr_glsl_ggx_aniso(TdotH2,BdotH2,_cache.isotropic.NdotH2, ax, ay, ax2, ay2);
219
-
220
- // ggx doesn't need the special `if` guards because
221
- return irr_glsl_ggx_aniso_cos_remainder_and_pdf_wo_clamps(pdf, ndf, max (_sample.NdotL, 0.0 ), _sample.NdotL2, TdotL2, BdotL2, max (interaction.isotropic.NdotV, 0.0 ), TdotV2, BdotV2, interaction.isotropic.NdotV_squared, _cache.isotropic.VdotH, ior , ax2, ay2);
215
+ const float ax2 = ax* ax;
216
+ const float ay2 = ay* ay;
217
+ const float ndf = irr_glsl_ggx_aniso(TdotH2,BdotH2,_cache.isotropic.NdotH2, ax, ay, ax2, ay2);
218
+
219
+ const vec3 reflectance = irr_glsl_fresnel_conductor(ior[ 0 ], ior[ 1 ], _cache.isotropic.VdotH);
220
+ return irr_glsl_ggx_aniso_cos_remainder_and_pdf_wo_clamps(pdf, ndf, max (_sample.NdotL, 0.0 ), _sample.NdotL2, TdotL2, BdotL2, max (interaction.isotropic.NdotV, 0.0 ), TdotV2, BdotV2, interaction.isotropic.NdotV_squared, _cache.isotropic.VdotH, reflectance , ax2, ay2);
222
221
}
223
222
else
224
223
{
0 commit comments