summaryrefslogtreecommitdiff
path: root/client/shaders/shadow_shaders
diff options
context:
space:
mode:
authorx2048 <codeforsmile@gmail.com>2021-10-31 19:18:30 +0100
committerGitHub <noreply@github.com>2021-10-31 19:18:30 +0100
commitcef016d393959e989df259aeacd055fc702a55ca (patch)
treefc1907616d74818da7a321567952db22eabd5641 /client/shaders/shadow_shaders
parent532d5b21fdff8bd8aa460b010ebd3bef1b9878dd (diff)
downloadminetest-cef016d393959e989df259aeacd055fc702a55ca.tar.gz
minetest-cef016d393959e989df259aeacd055fc702a55ca.tar.bz2
minetest-cef016d393959e989df259aeacd055fc702a55ca.zip
Apply shadow only to the naturally lit part of the fragment color (#11722)
Fragment color for nodes is now calculated from: * Texture color, highlighted by artificial light if present (light color conveyed via vertex color). * Texture color highlighted by natural light (conveyed via vertex color) filtered by shadow. * Reflected day/moonlight filtered by shadow (color and intensity), assuming some portion of the light is directly reflected from the materials.
Diffstat (limited to 'client/shaders/shadow_shaders')
-rw-r--r--client/shaders/shadow_shaders/pass1_trans_fragment.glsl5
1 files changed, 2 insertions, 3 deletions
diff --git a/client/shaders/shadow_shaders/pass1_trans_fragment.glsl b/client/shaders/shadow_shaders/pass1_trans_fragment.glsl
index 032cd9379..b267c2214 100644
--- a/client/shaders/shadow_shaders/pass1_trans_fragment.glsl
+++ b/client/shaders/shadow_shaders/pass1_trans_fragment.glsl
@@ -33,9 +33,8 @@ void main()
//col.rgb = col.a == 1.0 ? vec3(1.0) : col.rgb;
#ifdef COLORED_SHADOWS
col.rgb *= varColor.rgb;
- // alpha 0.0 results in all-white, 0.5 means full color, 1.0 means all black
- // resulting color is used as a factor in the final shader
- float packedColor = packColor(mix(mix(vec3(1.0), col.rgb, 2.0 * clamp(col.a, 0.0, 0.5)), black, 2.0 * clamp(col.a - 0.5, 0.0, 0.5)));
+ // premultiply color alpha (see-through side)
+ float packedColor = packColor(col.rgb * (1.0 - col.a));
gl_FragColor = vec4(depth, packedColor, 0.0,1.0);
#else
gl_FragColor = vec4(depth, 0.0, 0.0, 1.0);