EEVEE Shader comments: Explain why material gets darkened when using mix shader

We are still ditching the specular intensity of SSR (ssr_data.xyz).
But at least now there is some comment about it.

See T61704 for user reports on that matter.

Comments with the blessing of Clément Foucault.
This commit is contained in:
Dalai Felinto 2019-02-19 18:33:46 -03:00
parent a10dc319ca
commit 0e7409d466
Notes: blender-bot 2023-02-14 03:40:01 +01:00
Referenced by issue #61704, Eevee - material gets darkened when shader is being mixed with itself using 'mix shader'
1 changed files with 9 additions and 2 deletions

View File

@ -741,16 +741,23 @@ Closure closure_mix(Closure cl1, Closure cl2, float fac)
# endif
# endif
}
/* When mixing SSR don't blend roughness.
*
* It makes no sense to mix them really, so we take either one of them and
* tone down its specularity (ssr_data.xyz) while keeping its roughness (ssr_data.w).
*/
if (cl1.ssr_id == outputSsrId) {
cl.ssr_data = mix(cl1.ssr_data.xyzw, vec4(vec3(0.0), cl1.ssr_data.w), fac); /* do not blend roughness */
cl.ssr_data = mix(cl1.ssr_data.xyzw, vec4(vec3(0.0), cl1.ssr_data.w), fac);
cl.ssr_normal = cl1.ssr_normal;
cl.ssr_id = cl1.ssr_id;
}
else {
cl.ssr_data = mix(vec4(vec3(0.0), cl2.ssr_data.w), cl2.ssr_data.xyzw, fac); /* do not blend roughness */
cl.ssr_data = mix(vec4(vec3(0.0), cl2.ssr_data.w), cl2.ssr_data.xyzw, fac);
cl.ssr_normal = cl2.ssr_normal;
cl.ssr_id = cl2.ssr_id;
}
cl.opacity = mix(cl1.opacity, cl2.opacity, fac);
cl.radiance = mix(cl1.radiance * cl1.opacity, cl2.radiance * cl2.opacity, fac);
cl.radiance /= max(1e-8, cl.opacity);