|
7 | 7 | #include <irr/builtin/glsl/bxdf/brdf/specular/ggx.glsl>
|
8 | 8 |
|
9 | 9 |
|
10 |
| -float irr_glsl_ggx_height_correlated_aniso_cos_eval_DG_wo_clamps(in float NdotH2, in float TdotH2, in float BdotH2, in float maxNdotL, 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) |
| 10 | +float irr_glsl_ggx_height_correlated_aniso_dielectric_cos_eval_wo_clamps( |
| 11 | + in float NdotH2, in float TdotH2, in float BdotH2, |
| 12 | + in float absNdotL, in float NdotL2, in float TdotL2, in float BdotL2, |
| 13 | + in float absNdotV, in float NdotV2, in float TdotV2, in float BdotV2, |
| 14 | + in bool transmitted, in float VdotH, in float LdotH, in float VdotHLdotH, |
| 15 | + in float orientedEta, in float orientedEta2, |
| 16 | + in float ax, in float ax2, in float ay, in float ay2) |
11 | 17 | {
|
12 |
| - float NG = irr_glsl_ggx_aniso(TdotH2,BdotH2,NdotH2, ax, ay, ax2, ay2); |
13 |
| - if (ax>FLT_MIN || ay>FLT_MIN) |
14 |
| - { |
15 |
| - NG *= irr_glsl_ggx_smith_correlated_wo_numerator( |
16 |
| - maxNdotV, TdotV2, BdotV2, NdotV2, |
17 |
| - maxNdotL, TdotL2, BdotL2, NdotL2, |
18 |
| - ax2, ay2 |
19 |
| - ); |
20 |
| - } |
21 |
| - |
22 |
| - return NG; |
23 |
| -} |
24 |
| - |
25 |
| -vec3 irr_glsl_ggx_height_correlated_aniso_cos_eval_wo_clamps(in float NdotH2, in float TdotH2, in float BdotH2, in float maxNdotL, 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) |
26 |
| -{ |
27 |
| - float NG_already_in_reflective_dL_measure = irr_glsl_ggx_height_correlated_aniso_cos_eval_DG_wo_clamps(NdotH2,TdotH2,BdotH2,maxNdotL,NdotL2,TdotL2,BdotL2,maxNdotV,NdotV2,TdotV2,BdotV2,ax,ax2,ay,ay2); |
| 18 | + float NG_already_in_reflective_dL_measure = irr_glsl_ggx_height_correlated_aniso_cos_eval_DG_wo_clamps(NdotH2,TdotH2,BdotH2,absNdotL,NdotL2,TdotL2,BdotL2,absNdotV,NdotV2,TdotV2,BdotV2,ax,ax2,ay,ay2); |
| 19 | + |
| 20 | + const float reflectance = irr_glsl_fresnel_dielectric_common(orientedEta2,abs(VdotH)); |
28 | 21 |
|
29 |
| - vec3 fr = irr_glsl_fresnel_conductor(ior[0], ior[1], VdotH); |
30 |
| - return fr*irr_glsl_ggx_microfacet_to_light_measure_transform(NG_already_in_reflective_dL_measure,maxNdotL); |
| 22 | + return reflectance*irr_glsl_ggx_microfacet_to_light_measure_transform(NG_already_in_reflective_dL_measure,absNdotL,transmitted,VdotH,LdotH,VdotHLdotH,orientedEta); |
31 | 23 | }
|
32 | 24 |
|
33 |
| -vec3 irr_glsl_ggx_height_correlated_aniso_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) |
| 25 | +// before calling you must ensure that `irr_glsl_AnisotropicMicrofacetCache` is valid (if a given V vector can "see" the L vector) |
| 26 | +float irr_glsl_ggx_height_correlated_aniso_dielectric_cos_eval(in irr_glsl_LightSample _sample, in irr_glsl_AnisotropicViewSurfaceInteraction interaction, in irr_glsl_AnisotropicMicrofacetCache _cache, in float eta, in float ax, in float ay) |
34 | 27 | {
|
35 |
| - if (_sample.NdotL>FLT_MIN && interaction.isotropic.NdotV>FLT_MIN) |
36 |
| - { |
37 |
| - const float TdotH2 = _cache.TdotH*_cache.TdotH; |
38 |
| - const float BdotH2 = _cache.BdotH*_cache.BdotH; |
39 |
| - |
40 |
| - const float TdotL2 = _sample.TdotL*_sample.TdotL; |
41 |
| - const float BdotL2 = _sample.BdotL*_sample.BdotL; |
42 |
| - |
43 |
| - const float TdotV2 = interaction.TdotV*interaction.TdotV; |
44 |
| - const float BdotV2 = interaction.BdotV*interaction.BdotV; |
45 |
| - return irr_glsl_ggx_height_correlated_aniso_cos_eval_wo_clamps(_cache.isotropic.NdotH2, TdotH2, BdotH2, _sample.NdotL,_sample.NdotL2,TdotL2,BdotL2, interaction.isotropic.NdotV,interaction.isotropic.NdotV_squared,TdotV2,BdotV2, _cache.isotropic.VdotH, ior, ax,ax*ax,ay,ay*ay); |
46 |
| - } |
47 |
| - else |
48 |
| - return vec3(0.0); |
49 |
| -} |
| 28 | + const float TdotH2 = _cache.TdotH*_cache.TdotH; |
| 29 | + const float BdotH2 = _cache.BdotH*_cache.BdotH; |
50 | 30 |
|
| 31 | + const float TdotL2 = _sample.TdotL*_sample.TdotL; |
| 32 | + const float BdotL2 = _sample.BdotL*_sample.BdotL; |
51 | 33 |
|
52 |
| -float irr_glsl_ggx_height_correlated_cos_eval_DG_wo_clamps(in float NdotH2, in float maxNdotL, in float NdotL2, in float maxNdotV, in float NdotV2, in float a2) |
53 |
| -{ |
54 |
| - float NG = irr_glsl_ggx_trowbridge_reitz(a2, NdotH2); |
55 |
| - if (a2>FLT_MIN) |
56 |
| - NG *= irr_glsl_ggx_smith_correlated_wo_numerator(maxNdotV, NdotV2, maxNdotL, NdotL2, a2); |
| 34 | + const float TdotV2 = interaction.TdotV*interaction.TdotV; |
| 35 | + const float BdotV2 = interaction.BdotV*interaction.BdotV; |
57 | 36 |
|
58 |
| - return NG; |
| 37 | + const float VdotH = _cache.isotropic.VdotH; |
| 38 | + |
| 39 | + float orientedEta, dummy; |
| 40 | + const bool backside = irr_glsl_getOrientedEtas(orientedEta, dummy, VdotH, eta); |
| 41 | + const float orientedEta2 = orientedEta*orientedEta; |
| 42 | + |
| 43 | + const float VdotHLdotH = VdotH*_cache.isotropic.LdotH; |
| 44 | + const bool transmitted = VdotHLdotH<0.0; |
| 45 | + |
| 46 | + return irr_glsl_ggx_height_correlated_aniso_dielectric_cos_eval_wo_clamps( |
| 47 | + _cache.isotropic.NdotH2,TdotH2,BdotH2, |
| 48 | + abs(_sample.NdotL),_sample.NdotL2,TdotL2,BdotL2, |
| 49 | + abs(interaction.isotropic.NdotV),interaction.isotropic.NdotV_squared,TdotV2,BdotV2, |
| 50 | + transmitted,VdotH,_cache.isotropic.LdotH,VdotHLdotH,orientedEta,orientedEta2, |
| 51 | + ax,ax*ax,ay,ay*ay |
| 52 | + ); |
59 | 53 | }
|
60 | 54 |
|
61 |
| -vec3 irr_glsl_ggx_height_correlated_cos_eval_wo_clamps(in float NdotH2, in float maxNdotL, in float NdotL2, in float maxNdotV, in float NdotV2, in float VdotH, in mat2x3 ior, in float a2) |
62 |
| -{ |
63 |
| - float NG_already_in_reflective_dL_measure = irr_glsl_ggx_height_correlated_cos_eval_DG_wo_clamps(NdotH2, maxNdotL, NdotL2, maxNdotV, NdotV2, a2); |
64 | 55 |
|
65 |
| - vec3 fr = irr_glsl_fresnel_conductor(ior[0], ior[1], VdotH); |
| 56 | +float irr_glsl_ggx_height_correlated_dielectric_cos_eval_wo_clamps( |
| 57 | + in float NdotH2, in float absNdotL, in float NdotL2, |
| 58 | + in float absNdotV, in float NdotV2, |
| 59 | + in bool transmitted, in float VdotH, in float LdotH, in float VdotHLdotH, |
| 60 | + in float orientedEta, in float orientedEta2, in float a2) |
| 61 | +{ |
| 62 | + const float NG_already_in_reflective_dL_measure = irr_glsl_ggx_height_correlated_cos_eval_DG_wo_clamps(NdotH2, absNdotL, NdotL2, absNdotV, NdotV2, a2); |
| 63 | + |
| 64 | + const float reflectance = irr_glsl_fresnel_dielectric_common(orientedEta2,abs(VdotH)); |
66 | 65 |
|
67 |
| - return fr*irr_glsl_ggx_microfacet_to_light_measure_transform(NG_already_in_reflective_dL_measure,maxNdotL); |
| 66 | + return reflectance*irr_glsl_ggx_microfacet_to_light_measure_transform(NG_already_in_reflective_dL_measure,absNdotL,transmitted,VdotH,LdotH,VdotHLdotH,orientedEta); |
68 | 67 | }
|
69 | 68 |
|
70 |
| -vec3 irr_glsl_ggx_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) |
| 69 | +// before calling you must ensure that `irr_glsl_AnisotropicMicrofacetCache` is valid (if a given V vector can "see" the L vector) |
| 70 | +float irr_glsl_ggx_height_correlated_dielectric_cos_eval(in irr_glsl_LightSample _sample, in irr_glsl_IsotropicViewSurfaceInteraction interaction, in irr_glsl_IsotropicMicrofacetCache _cache, in float eta, in float a2) |
71 | 71 | {
|
72 |
| - if (_sample.NdotL>FLT_MIN && interaction.NdotV>FLT_MIN) |
73 |
| - return irr_glsl_ggx_height_correlated_cos_eval_wo_clamps(_cache.NdotH2,max(_sample.NdotL,0.0),_sample.NdotL2, max(interaction.NdotV,0.0), interaction.NdotV_squared, _cache.VdotH,ior,a2); |
74 |
| - else |
75 |
| - return vec3(0.0); |
| 72 | + float orientedEta, dummy; |
| 73 | + const bool backside = irr_glsl_getOrientedEtas(orientedEta, dummy, _cache.VdotH, eta); |
| 74 | + const float orientedEta2 = orientedEta*orientedEta; |
| 75 | + |
| 76 | + const float VdotHLdotH = _cache.VdotH*_cache.LdotH; |
| 77 | + const bool transmitted = VdotHLdotH<0.0; |
| 78 | + |
| 79 | + return irr_glsl_ggx_height_correlated_dielectric_cos_eval_wo_clamps( |
| 80 | + _cache.NdotH2,abs(_sample.NdotL),_sample.NdotL2, |
| 81 | + abs(interaction.NdotV),interaction.NdotV_squared, |
| 82 | + transmitted,_cache.VdotH,_cache.LdotH,VdotHLdotH,orientedEta,orientedEta2,a2 |
| 83 | + ); |
76 | 84 | }
|
77 | 85 |
|
78 | 86 |
|
@@ -108,98 +116,96 @@ irr_glsl_LightSample irr_glsl_ggx_dielectric_cos_generate(in irr_glsl_Anisotropi
|
108 | 116 | return irr_glsl_ggx_dielectric_cos_generate_wo_clamps(localV,backside,upperHemisphereV,m, u,ax,ay, rcpOrientedEta,orientedEta*orientedEta,rcpOrientedEta*rcpOrientedEta,_cache);
|
109 | 117 | }
|
110 | 118 |
|
111 |
| -#if 0 |
112 |
| -// TODO |
113 |
| -float irr_glsl_ggx_pdf_wo_clamps(in float ndf, in float devsh_v, in float maxNdotV) |
| 119 | + |
| 120 | + |
| 121 | +float irr_glsl_ggx_dielectric_pdf_wo_clamps(in bool transmitted, in float reflectance, in float ndf, in float devsh_v, in float absNdotV, in float VdotH, in float LdotH, in float VdotHLdotH, in float orientedEta) |
114 | 122 | {
|
115 |
| - return irr_glsl_smith_VNDF_pdf_wo_clamps(ndf,irr_glsl_GGXSmith_G1_wo_numerator(maxNdotV,devsh_v),); |
| 123 | + return irr_glsl_smith_VNDF_pdf_wo_clamps(ndf,irr_glsl_GGXSmith_G1_wo_numerator(absNdotV,devsh_v),absNdotV,transmitted,VdotH,LdotH,VdotHLdotH,orientedEta,reflectance); |
116 | 124 | }
|
117 |
| -float irr_glsl_ggx_pdf_wo_clamps(in float NdotH2, in float maxNdotV, in float NdotV2, in float a2) |
| 125 | +float irr_glsl_ggx_dielectric_pdf_wo_clamps(in bool transmitted, in float reflectance, in float NdotH2, in float absNdotV, in float NdotV2, in float VdotH, in float LdotH, in float VdotHLdotH, in float a2, in float orientedEta) |
118 | 126 | {
|
119 | 127 | const float ndf = irr_glsl_ggx_trowbridge_reitz(a2, NdotH2);
|
120 | 128 | const float devsh_v = irr_glsl_smith_ggx_devsh_part(NdotV2, a2, 1.0-a2);
|
121 | 129 |
|
122 |
| - return irr_glsl_ggx_pdf_wo_clamps(ndf, devsh_v, maxNdotV); |
| 130 | + return irr_glsl_ggx_dielectric_pdf_wo_clamps(transmitted,reflectance, ndf,devsh_v, absNdotV, VdotH,LdotH,VdotHLdotH, orientedEta); |
123 | 131 | }
|
124 | 132 |
|
125 |
| -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) |
| 133 | +float irr_glsl_ggx_dielectric_pdf_wo_clamps(in bool transmitted, in float reflectance, in float NdotH2, in float TdotH2, in float BdotH2, in float absNdotV, in float NdotV2, in float TdotV2, in float BdotV2, in float VdotH, in float LdotH, in float VdotHLdotH, in float ax, in float ay, in float ax2, in float ay2, in float orientedEta) |
126 | 134 | {
|
127 | 135 | const float ndf = irr_glsl_ggx_aniso(TdotH2,BdotH2,NdotH2, ax, ay, ax2, ay2);
|
128 | 136 | const float devsh_v = irr_glsl_smith_ggx_devsh_part(TdotV2, BdotV2, NdotV2, ax2, ay2);
|
129 | 137 |
|
130 |
| - return irr_glsl_ggx_pdf_wo_clamps(ndf, devsh_v, maxNdotV); |
| 138 | + return irr_glsl_ggx_dielectric_pdf_wo_clamps(transmitted,reflectance, ndf,devsh_v, absNdotV, VdotH,LdotH,VdotHLdotH, orientedEta); |
131 | 139 | }
|
132 | 140 |
|
133 | 141 |
|
134 | 142 |
|
135 |
| -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 vec3 reflectance, in float a2) |
| 143 | +float irr_glsl_ggx_dielectric_cos_remainder_and_pdf_wo_clamps(out float pdf, in float ndf, in bool transmitted, in float absNdotL, in float NdotL2, in float absNdotV, in float NdotV2, in float VdotH, in float LdotH, in float VdotHLdotH, in float reflectance, in float orientedEta, in float a2) |
136 | 144 | {
|
137 | 145 | const float one_minus_a2 = 1.0 - a2;
|
138 | 146 | const float devsh_v = irr_glsl_smith_ggx_devsh_part(NdotV2, a2, one_minus_a2);
|
139 |
| - pdf = irr_glsl_ggx_pdf_wo_clamps(ndf, devsh_v, maxNdotV); |
140 |
| - |
141 |
| - const float G2_over_G1 = irr_glsl_ggx_smith_G2_over_G1_devsh(maxNdotL, NdotL2, maxNdotV, devsh_v, a2, one_minus_a2); |
| 147 | + pdf = irr_glsl_ggx_dielectric_pdf_wo_clamps(transmitted,reflectance, ndf,devsh_v, absNdotV, VdotH,LdotH,VdotHLdotH, orientedEta); |
142 | 148 |
|
143 |
| - return reflectance * G2_over_G1; |
| 149 | + return irr_glsl_ggx_smith_G2_over_G1_devsh(absNdotL, NdotL2, absNdotV, devsh_v, a2, one_minus_a2); |
144 | 150 | }
|
145 | 151 |
|
146 |
| -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) |
| 152 | +float irr_glsl_ggx_dielectric_cos_remainder_and_pdf(out float pdf, in irr_glsl_LightSample _sample, in irr_glsl_IsotropicViewSurfaceInteraction interaction, in irr_glsl_IsotropicMicrofacetCache _cache, in float eta, in float a2) |
147 | 153 | {
|
148 |
| - if (_sample.NdotL>FLT_MIN && interaction.NdotV>FLT_MIN) |
149 |
| - { |
150 |
| - const float ndf = irr_glsl_ggx_trowbridge_reitz(a2, _cache.NdotH2); |
151 |
| - const vec3 reflectance = irr_glsl_fresnel_conductor(ior[0], ior[1], _cache.VdotH); |
152 |
| - |
153 |
| - return irr_glsl_ggx_cos_remainder_and_pdf_wo_clamps(pdf, ndf, _sample.NdotL, _sample.NdotL2, interaction.NdotV, interaction.NdotV_squared, reflectance, a2); |
154 |
| - } |
155 |
| - else |
156 |
| - { |
157 |
| - pdf = 0.0; |
158 |
| - return vec3(0.0); |
159 |
| - } |
| 154 | + const float ndf = irr_glsl_ggx_trowbridge_reitz(a2, _cache.NdotH2); |
| 155 | + |
| 156 | + float orientedEta, dummy; |
| 157 | + const bool backside = irr_glsl_getOrientedEtas(orientedEta, dummy, _cache.VdotH, eta); |
| 158 | + const float orientedEta2 = orientedEta*orientedEta; |
| 159 | + |
| 160 | + const float VdotHLdotH = _cache.VdotH*_cache.LdotH; |
| 161 | + const bool transmitted = VdotHLdotH<0.0; |
| 162 | + |
| 163 | + const float reflectance = irr_glsl_fresnel_dielectric_common(orientedEta2,abs(_cache.VdotH)); |
| 164 | + |
| 165 | + const float absNdotV = abs(interaction.NdotV); |
| 166 | + return irr_glsl_ggx_dielectric_cos_remainder_and_pdf_wo_clamps(pdf,ndf,transmitted, abs(_sample.NdotL),_sample.NdotL2, absNdotV,interaction.NdotV_squared, _cache.VdotH,_cache.LdotH,VdotHLdotH, reflectance,orientedEta, a2); |
160 | 167 | }
|
161 | 168 |
|
162 | 169 |
|
163 |
| -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 vec3 reflectance, in float ax2,in float ay2) |
| 170 | +float irr_glsl_ggx_aniso_dielectric_cos_remainder_and_pdf_wo_clamps(out float pdf, in float ndf, in bool transmitted, in float absNdotL, 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) |
164 | 171 | {
|
165 | 172 | const float devsh_v = irr_glsl_smith_ggx_devsh_part(TdotV2, BdotV2, NdotV2, ax2, ay2);
|
166 |
| - pdf = irr_glsl_ggx_pdf_wo_clamps(ndf, devsh_v, maxNdotV); |
| 173 | + pdf = irr_glsl_ggx_dielectric_pdf_wo_clamps(transmitted,reflectance, ndf,devsh_v, absNdotV, VdotH,LdotH,VdotHLdotH, orientedEta); |
167 | 174 |
|
168 |
| - const float G2_over_G1 = irr_glsl_ggx_smith_G2_over_G1_devsh( |
169 |
| - maxNdotL, TdotL2,BdotL2,NdotL2, |
170 |
| - maxNdotV, devsh_v, |
| 175 | + return irr_glsl_ggx_smith_G2_over_G1_devsh( |
| 176 | + absNdotL, TdotL2,BdotL2,NdotL2, |
| 177 | + absNdotV, devsh_v, |
171 | 178 | ax2, ay2
|
172 | 179 | );
|
173 |
| - |
174 |
| - return reflectance * G2_over_G1; |
175 | 180 | }
|
176 | 181 |
|
177 |
| -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) |
| 182 | +float irr_glsl_ggx_aniso_dielectric_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) |
178 | 183 | {
|
179 |
| - if (_sample.NdotL>FLT_MIN && interaction.isotropic.NdotV>FLT_MIN) |
180 |
| - { |
181 |
| - const float TdotH2 = _cache.TdotH*_cache.TdotH; |
182 |
| - const float BdotH2 = _cache.BdotH*_cache.BdotH; |
183 |
| - |
184 |
| - const float TdotL2 = _sample.TdotL*_sample.TdotL; |
185 |
| - const float BdotL2 = _sample.BdotL*_sample.BdotL; |
186 |
| - |
187 |
| - const float TdotV2 = interaction.TdotV*interaction.TdotV; |
188 |
| - const float BdotV2 = interaction.BdotV*interaction.BdotV; |
189 |
| - |
190 |
| - const float ax2 = ax*ax; |
191 |
| - const float ay2 = ay*ay; |
192 |
| - const float ndf = irr_glsl_ggx_aniso(TdotH2,BdotH2,_cache.isotropic.NdotH2, ax, ay, ax2, ay2); |
193 |
| - const vec3 reflectance = irr_glsl_fresnel_conductor(ior[0], ior[1], _cache.isotropic.VdotH); |
194 |
| - |
195 |
| - return irr_glsl_ggx_aniso_cos_remainder_and_pdf_wo_clamps(pdf, ndf, _sample.NdotL, _sample.NdotL2, TdotL2, BdotL2, interaction.isotropic.NdotV, TdotV2, BdotV2, interaction.isotropic.NdotV_squared, reflectance, ax2, ay2); |
196 |
| - } |
197 |
| - else |
198 |
| - { |
199 |
| - pdf = 0.0; |
200 |
| - return vec3(0.0); |
201 |
| - } |
| 184 | + const float ax2 = ax*ax; |
| 185 | + const float ay2 = ay*ay; |
| 186 | + const float TdotH2 = _cache.TdotH*_cache.TdotH; |
| 187 | + const float BdotH2 = _cache.BdotH*_cache.BdotH; |
| 188 | + const float ndf = irr_glsl_ggx_aniso(TdotH2,BdotH2,_cache.isotropic.NdotH2, ax, ay, ax2, ay2); |
| 189 | + |
| 190 | + const float TdotL2 = _sample.TdotL*_sample.TdotL; |
| 191 | + const float BdotL2 = _sample.BdotL*_sample.BdotL; |
| 192 | + |
| 193 | + const float TdotV2 = interaction.TdotV*interaction.TdotV; |
| 194 | + const float BdotV2 = interaction.BdotV*interaction.BdotV; |
| 195 | + |
| 196 | + const float VdotH = _cache.isotropic.VdotH; |
| 197 | + |
| 198 | + float orientedEta, dummy; |
| 199 | + const bool backside = irr_glsl_getOrientedEtas(orientedEta, dummy, VdotH, eta); |
| 200 | + const float orientedEta2 = orientedEta*orientedEta; |
| 201 | + |
| 202 | + const float VdotHLdotH = VdotH*_cache.isotropic.LdotH; |
| 203 | + const bool transmitted = VdotHLdotH<0.0; |
| 204 | + |
| 205 | + const float reflectance = irr_glsl_fresnel_dielectric_common(orientedEta2,abs(VdotH)); |
| 206 | + |
| 207 | + const float absNdotV = abs(interaction.isotropic.NdotV); |
| 208 | + return irr_glsl_ggx_aniso_dielectric_cos_remainder_and_pdf_wo_clamps(pdf,ndf,transmitted, abs(_sample.NdotL),_sample.NdotL2,TdotL2,BdotL2, absNdotV,TdotV2,BdotV2,interaction.isotropic.NdotV_squared, VdotH,_cache.isotropic.LdotH,VdotHLdotH, reflectance,orientedEta, ax2,ay2); |
202 | 209 | }
|
203 |
| -#endif |
204 | 210 |
|
205 | 211 | #endif
|
0 commit comments