1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

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.
This commit is contained in:
x2048 2021-10-31 19:18:30 +01:00 committed by GitHub
parent 532d5b21fd
commit cef016d393
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 10 deletions

View file

@ -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);