]> git.tdb.fi Git - libs/gl.git/commitdiff
Normalize fragment normal
authorMikko Rasa <tdb@tdb.fi>
Tue, 23 Jun 2020 14:11:54 +0000 (17:11 +0300)
committerMikko Rasa <tdb@tdb.fi>
Tue, 23 Jun 2020 14:35:09 +0000 (17:35 +0300)
With some shading models even small deviations, such as result from
the quantization to 8-bit texel component values, may cause visible
artifacts.

shaderlib/common.glsl

index 05648e4c0c106f469b63ed0346dc4c8b32c0c9be..4a81636037be1224d0d2856cdfd90b67d8eef3fc 100644 (file)
@@ -68,7 +68,7 @@ void main()
 vec3 get_fragment_normal()
 {
        if(use_normal_map)
-               return texture(normal_map, texcoord.xy).xyz*2.0-1.0;
+               return normalize(texture(normal_map, texcoord.xy).xyz*2.0-1.0);
        else
                return vec3(0.0, 0.0, 1.0);
 }