Fix #28819: Normal Maps appear inverted in GLSL shader and offline renderer (2.6rc1)
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 6 Oct 2011 14:55:30 +0000 (14:55 +0000)
committerSergey Sharybin <sergey.vfx@gmail.com>
Thu, 6 Oct 2011 14:55:30 +0000 (14:55 +0000)
Caused by recent bump maps flip commit.
If texture is used as Normal Map it's normal factor shouldn't be flipped.

source/blender/blenloader/intern/readfile.c

index 95bf44d884c6db3b6e7a9690c08a5e40df7ffaa0..ce5805921dcb80f9ac9c37b7a62cde6e0c47ecd5 100644 (file)
@@ -12122,8 +12122,12 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                        if(mtex) {
                                                if((mtex->texflag&MTEX_BUMP_FLIPPED)==0) {
                                                        if((mtex->mapto&MAP_NORM) && mtex->texflag&(MTEX_COMPAT_BUMP|MTEX_3TAP_BUMP|MTEX_5TAP_BUMP)) {
-                                                               mtex->norfac= -mtex->norfac;
-                                                               mtex->texflag|= MTEX_BUMP_FLIPPED;
+                                                               Tex *tex= newlibadr(fd, lib, mtex->tex);
+
+                                                               if(!tex || (tex->imaflag&TEX_NORMALMAP)==0) {
+                                                                       mtex->norfac= -mtex->norfac;
+                                                                       mtex->texflag|= MTEX_BUMP_FLIPPED;
+                                                               }
                                                        }
                                                }
                                        }