diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-05-07 16:00:37 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-05-07 16:00:37 +0300 |
commit | 9f2e995c3edf04ca490720b8a2d5af276e1e7d7c (patch) | |
tree | 83d076f852f5116b0ac6b0d739b8c1dde63c9808 /source/blender/draw/engines/eevee/shaders | |
parent | 3a035a4417f97ed4700135dfd06967e9aa901573 (diff) |
Fix T97796 EEVEE: Regression: Alpha clipped materials rendered as alpha hashed
This was because the alpha clip thresholding was previously done in the
material nodes codegen. Now it is the responsibility of the engine to
implement it.
This adds a loose uniform that is set by EEVEE itself to control the clip
behavior.
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/prepass_frag.glsl | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl b/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl index c8eea8d7860..15c68dc5829 100644 --- a/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl +++ b/source/blender/draw/engines/eevee/shaders/prepass_frag.glsl @@ -11,6 +11,8 @@ #pragma BLENDER_REQUIRE(surface_lib.glsl) #ifdef USE_ALPHA_HASH +/* A value of -1.0 will disable alpha clip and use alpha hash. */ +uniform float alphaClipThreshold; /* From the paper "Hashed Alpha Testing" by Chris Wyman and Morgan McGuire */ float hash(vec2 a) @@ -76,9 +78,16 @@ void main() float opacity = saturate(1.0 - avg(cl.transmittance)); - /* Hashed Alpha Testing */ - if (opacity < hashed_alpha_threshold(worldPosition)) { - discard; + if (alphaClipThreshold == -1.0) { + /* NOTE: uniform control flow required for dFdx(). */ + if (opacity < hashed_alpha_threshold(worldPosition)) { + discard; + } + } + else { + if (opacity <= alphaClipThreshold) { + discard; + } } #endif } |