diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-06-30 22:12:32 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-06-30 22:12:44 +0300 |
commit | 981d7381cd27432616c69d63cfaeb16aff6d3edb (patch) | |
tree | 8f5c3fc7e8640f1a2abdd553bc8c6792d85b8165 /source/blender/draw/engines | |
parent | 3562be2bdaacb6db37da38b2269fb56d2d838261 (diff) |
Fix T77069 EEVEE: Mix shader with holdout & transparent BSDF fails
This follows Cycles closer.
Diffstat (limited to 'source/blender/draw/engines')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl index 402d306df45..393ecaf1fc5 100644 --- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl @@ -877,6 +877,14 @@ Closure closure_mix(Closure cl1, Closure cl2, float fac) { Closure cl; cl.holdout = mix(cl1.holdout, cl2.holdout, fac); + + if (FLAG_TEST(cl1.flag, CLOSURE_HOLDOUT_FLAG)) { + fac = 1.0; + } + else if (FLAG_TEST(cl2.flag, CLOSURE_HOLDOUT_FLAG)) { + fac = 0.0; + } + cl.transmittance = mix(cl1.transmittance, cl2.transmittance, fac); cl.radiance = mix(cl1.radiance, cl2.radiance, fac); cl.flag = cl1.flag | cl2.flag; @@ -958,7 +966,7 @@ void main() { Closure cl = nodetree_exec(); - float holdout = 1.0 - saturate(cl.holdout); + float holdout = saturate(1.0 - cl.holdout); float transmit = saturate(avg(cl.transmittance)); float alpha = 1.0 - transmit; @@ -972,8 +980,9 @@ void main() * Since we do that using the blending pipeline we need to account for material transmittance. */ vol_scatter -= vol_scatter * cl.transmittance; - outRadiance = vec4(cl.radiance * vol_transmit + vol_scatter, alpha * holdout); - outTransmittance = vec4(cl.transmittance, transmit * holdout); + cl.radiance = cl.radiance * holdout * vol_transmit + vol_scatter; + outRadiance = vec4(cl.radiance, alpha * holdout); + outTransmittance = vec4(cl.transmittance, transmit) * holdout; # else outRadiance = vec4(cl.radiance, holdout); ssrNormals = cl.ssr_normal; |