[Bf-blender-cvs] [3146a07e3ec] master: Fix T60005: Eevee: Volume material doen't write alpha
Clément Foucault
noreply at git.blender.org
Tue Mar 12 23:16:33 CET 2019
Commit: 3146a07e3ecff46e4b006e761de2ac04af09d370
Author: Clément Foucault
Date: Tue Mar 12 23:14:37 2019 +0100
Branches: master
https://developer.blender.org/rB3146a07e3ecff46e4b006e761de2ac04af09d370
Fix T60005: Eevee: Volume material doen't write alpha
===================================================================
M source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
M source/blender/draw/engines/eevee/shaders/volumetric_lib.glsl
===================================================================
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);
}
More information about the Bf-blender-cvs
mailing list