diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2019-03-13 01:14:37 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2019-03-13 01:16:17 +0300 |
commit | 3146a07e3ecff46e4b006e761de2ac04af09d370 (patch) | |
tree | 72762fe9928342a143649dfba68f449189666b0d /source/blender/draw | |
parent | 31fba57677aec38842809b22f25a0484cbff691b (diff) |
Fix T60005: Eevee: Volume material doen't write alpha
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl | 3 | ||||
-rw-r--r-- | source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl | 5 |
2 files changed, 6 insertions, 2 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 ade19f4c7a8..5bd5aca576e 100644 --- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl @@ -834,7 +834,8 @@ void main() # if defined(USE_ALPHA_BLEND_VOLUMETRICS) /* XXX fragile, better use real viewport resolution */ vec2 uvs = gl_FragCoord.xy / vec2(2 * textureSize(maxzBuffer, 0).xy); - fragColor = volumetric_resolve(vec4(cl.radiance, cl.opacity), uvs, gl_FragCoord.z); + fragColor.rgb = volumetric_resolve(vec4(cl.radiance, cl.opacity), uvs, gl_FragCoord.z).rgb; + fragColor.a = cl.opacity; # else fragColor = vec4(cl.radiance, cl.opacity); # endif diff --git a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl index ae36252153f..c5c9ad543db 100644 --- a/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl @@ -151,5 +151,8 @@ vec4 volumetric_resolve(vec4 scene_color, vec2 frag_uvs, float frag_depth) vec3 scattering = texture(inScattering, volume_cos).rgb; vec3 transmittance = texture(inTransmittance, volume_cos).rgb; - return vec4(scene_color.rgb * transmittance + scattering, scene_color.a); + /* Approximate volume alpha by using a monochromatic transmitance + * and adding it to the scene alpha. */ + float final_alpha = mix(1.0, scene_color.a, dot(transmittance, vec3(1.0 / 3.0))); + return vec4(scene_color.rgb * transmittance + scattering, final_alpha); } |