@@ -67,10 +67,9 @@ float irr_glsl_beckmann_dielectric_cos_remainder_and_pdf(out float pdf, in irr_g
67
67
{
68
68
const float ndf = irr_glsl_beckmann(a2,_cache.NdotH2);
69
69
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);
72
72
const float orientedEta2 = orientedEta* orientedEta;
73
- const float rcpOrientedEta2 = rcpOrientedEta* rcpOrientedEta;
74
73
75
74
const float VdotHLdotH = _cache.VdotH* _cache.LdotH;
76
75
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
81
80
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);
82
81
}
83
82
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;
94
83
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)
101
85
{
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);
105
88
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;
109
102
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;
112
105
113
- const float ndf = irr_glsl_beckmann(ax, ay, ax2, ay2, TdotH2, BdotH2, NdotH2) ;
106
+ const float VdotH = _cache.isotropic.VdotH ;
114
107
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);
116
117
}
117
118
118
119
119
120
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)
121
125
{
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);
124
127
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);
126
131
}
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)
128
135
{
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 ;
130
142
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);
132
147
}
133
148
134
149
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)
136
157
{
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));
139
161
140
- return scalar_part * fr ;
162
+ return reflectance * irr_glsl_microfacet_to_light_measure_transform(scalar_part,absNdotV,transmitted,VdotH,LdotH,VdotHLdotH,orientedEta) ;
141
163
}
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)
143
167
{
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;
147
173
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 ;
150
176
151
- const float TdotV2 = interaction.TdotV * interaction.TdotV;
152
- const float BdotV2 = interaction.BdotV * interaction.BdotV;
177
+ const float VdotH = _cache.isotropic.VdotH;
153
178
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);
155
192
}
156
- #endif
157
193
158
194
#endif
0 commit comments