diff options
Diffstat (limited to 'source/blender/draw/engines/eevee/shaders/prepass_frag.glsl')
-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 } |