[Bf-blender-cvs] [4aabea8b87a] master: Fix T70640 EEVEE: Alpha hashed material is darker when alpha is not 1.0
Clément Foucault
noreply at git.blender.org
Wed Oct 9 14:56:41 CEST 2019
Commit: 4aabea8b87a94ba7a63352364573004b2e054db8
Author: Clément Foucault
Date: Wed Oct 9 14:56:21 2019 +0200
Branches: master
https://developer.blender.org/rB4aabea8b87a94ba7a63352364573004b2e054db8
Fix T70640 EEVEE: Alpha hashed material is darker when alpha is not 1.0
Predivide all radiance components as the alpha effect comes from the hashed
transparency (pixel rejection).
===================================================================
M source/blender/draw/engines/eevee/shaders/bsdf_common_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 98012aea303..1f68935403c 100644
--- a/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
+++ b/source/blender/draw/engines/eevee/shaders/bsdf_common_lib.glsl
@@ -918,14 +918,15 @@ void main()
Closure cl = nodetree_exec();
float holdout = 1.0 - saturate(cl.holdout);
+ float transmit = saturate(avg(cl.transmittance));
+ float alpha = 1.0 - transmit;
# ifdef USE_ALPHA_BLEND
vec2 uvs = gl_FragCoord.xy * volCoordScale.zw;
vec3 vol_transmit, vol_scatter;
volumetric_resolve(uvs, gl_FragCoord.z, vol_transmit, vol_scatter);
- float transmit = saturate(avg(cl.transmittance));
- outRadiance = vec4(cl.radiance * vol_transmit + vol_scatter, (1.0 - transmit) * holdout);
+ outRadiance = vec4(cl.radiance * vol_transmit + vol_scatter, alpha * holdout);
outTransmittance = vec4(cl.transmittance, transmit * holdout);
# else
outRadiance = vec4(cl.radiance, holdout);
@@ -953,6 +954,15 @@ void main()
outRadiance.rgb += cl.sss_irradiance.rgb * cl.sss_albedo.rgb * fac;
# endif
+
+# ifndef USE_ALPHA_BLEND
+ float alpha_div = 1.0 / max(1e-8, alpha);
+ outRadiance *= alpha_div;
+ ssrData.rgb *= alpha_div;
+# ifdef USE_SSS
+ sssAlbedo.rgb *= alpha_div;
+# endif
+# endif
}
# endif /* MESH_SHADER && !SHADOW_SHADER */
More information about the Bf-blender-cvs
mailing list