]> code.bitgloo.com Git - clyne/gamedev2.git/commitdiff
Flips the X axis of the normal map instead of the light direction when model is flipped
authorAndy Belle-Isle <drumsetmonkey@gmail.com>
Sat, 7 Sep 2019 05:15:51 +0000 (01:15 -0400)
committerAndy Belle-Isle <drumsetmonkey@gmail.com>
Sat, 7 Sep 2019 05:15:51 +0000 (01:15 -0400)
Shaders/world.frag

index c97c8806dcdf87ab8e2ead51ecac26b93021a40d..2b5ab5e0201659108f7c63e556f607cc93399d9d 100644 (file)
@@ -34,13 +34,13 @@ void main()
 
     for (int i = 0; i < LightNum; i++) {
         vec3 LightDir = vec3(LightPos[i].xy - fragCoord.xy, LightPos[i].z);
-        if (Flipped == 1)
-            LightDir.x = -LightDir.x;
 
         float D = length(LightDir);
 
         vec3 N = normalize(NormalMap * 2.0 - 1.0);
         vec3 L = normalize(LightDir);
+        if (Flipped == 1)
+            N.x = -N.x;
 
         vec3 Diffuse = 
             (LightColor[i].rgb * LightColor[i].a) * max(dot(N, L), 0.0);