|
@@ -380,25 +380,27 @@ void main(void) {
|
|
|
|
|
|
// _____________________________ Alpha Fresnel ___________________________________
|
|
// _____________________________ Alpha Fresnel ___________________________________
|
|
#ifdef ALPHAFRESNEL
|
|
#ifdef ALPHAFRESNEL
|
|
- // Convert approximate perceptual opacity (gamma-encoded opacity) to linear opacity (absorptance, or inverse transmission)
|
|
|
|
- // for use with the linear HDR render target. The final composition will be converted back to gamma encoded values for eventual display.
|
|
|
|
- // Uses power 2.0 rather than 2.2 for simplicity/efficiency, and because the mapping does not need to map the gamma applied to RGB.
|
|
|
|
- float opacityPerceptual = alpha;
|
|
|
|
- float opacity0 = opacityPerceptual * opacityPerceptual;
|
|
|
|
- float opacity90 = fresnelGrazingReflectance(opacity0);
|
|
|
|
-
|
|
|
|
- vec3 normalForward = faceforward(normalW, -viewDirectionW, normalW);
|
|
|
|
-
|
|
|
|
- // Calculate the appropriate linear opacity for the current viewing angle (formally, this quantity is the "directional absorptance").
|
|
|
|
- alpha = fresnelSchlickEnvironmentGGX(clamp(dot(V, normalForward), 0.0, 1.0), vec3(opacity0), vec3(opacity90), sqrt(microSurface)).x;
|
|
|
|
-
|
|
|
|
- #ifdef ALPHATEST
|
|
|
|
- if (alpha <= ALPHATESTVALUE)
|
|
|
|
- discard;
|
|
|
|
|
|
+ #if defined(ALPHATEST) || defined(ALPHABLEND)
|
|
|
|
+ // Convert approximate perceptual opacity (gamma-encoded opacity) to linear opacity (absorptance, or inverse transmission)
|
|
|
|
+ // for use with the linear HDR render target. The final composition will be converted back to gamma encoded values for eventual display.
|
|
|
|
+ // Uses power 2.0 rather than 2.2 for simplicity/efficiency, and because the mapping does not need to map the gamma applied to RGB.
|
|
|
|
+ float opacityPerceptual = alpha;
|
|
|
|
+ float opacity0 = opacityPerceptual * opacityPerceptual;
|
|
|
|
+ float opacity90 = fresnelGrazingReflectance(opacity0);
|
|
|
|
+
|
|
|
|
+ vec3 normalForward = faceforward(normalW, -viewDirectionW, normalW);
|
|
|
|
+
|
|
|
|
+ // Calculate the appropriate linear opacity for the current viewing angle (formally, this quantity is the "directional absorptance").
|
|
|
|
+ alpha = fresnelSchlickEnvironmentGGX(clamp(dot(viewDirectionW, normalForward), 0.0, 1.0), vec3(opacity0), vec3(opacity90), sqrt(microSurface)).x;
|
|
|
|
+
|
|
|
|
+ #ifdef ALPHATEST
|
|
|
|
+ if (alpha <= ALPHATESTVALUE)
|
|
|
|
+ discard;
|
|
|
|
|
|
- #ifndef ALPHABLEND
|
|
|
|
- // Prevent to blend with the canvas.
|
|
|
|
- alpha = 1.0;
|
|
|
|
|
|
+ #ifndef ALPHABLEND
|
|
|
|
+ // Prevent to blend with the canvas.
|
|
|
|
+ alpha = 1.0;
|
|
|
|
+ #endif
|
|
#endif
|
|
#endif
|
|
#endif
|
|
#endif
|
|
#endif
|
|
#endif
|