Browse Source

android lol fix

sebavan 4 years ago
parent
commit
169979fcad

+ 10 - 4
src/Shaders/ShadersInclude/bumpFragment.fx

@@ -12,15 +12,21 @@
 	#if defined(TANGENT) && defined(NORMAL)
 	#if defined(TANGENT) && defined(NORMAL)
 		mat3 TBN = vTBN;
 		mat3 TBN = vTBN;
 	#elif defined(BUMP)
 	#elif defined(BUMP)
-		mat3 TBN = cotangent_frame(normalW * normalScale, vPositionW, vBumpUV);
-    #else
-		mat3 TBN = cotangent_frame(normalW * normalScale, vPositionW, vDetailUV, vec2(1., 1.));
+		// flip the uv for the backface
+		vec2 TBNUV = gl_FrontFacing ? vBumpUV : -vBumpUV;
+		mat3 TBN = cotangent_frame(normalW * normalScale, vPositionW, TBNUV);
+	#else
+		// flip the uv for the backface
+		vec2 TBNUV = gl_FrontFacing ? vDetailUV : -vDetailUV;
+		mat3 TBN = cotangent_frame(normalW * normalScale, vPositionW, TBNUV, vec2(1., 1.));
 	#endif
 	#endif
 #elif defined(ANISOTROPIC)
 #elif defined(ANISOTROPIC)
 	#if defined(TANGENT) && defined(NORMAL)
 	#if defined(TANGENT) && defined(NORMAL)
 		mat3 TBN = vTBN;
 		mat3 TBN = vTBN;
 	#else
 	#else
-		mat3 TBN = cotangent_frame(normalW, vPositionW, vMainUV1, vec2(1., 1.));
+		// flip the uv for the backface
+		vec2 TBNUV = gl_FrontFacing ? vMainUV1 : -vMainUV1;
+		mat3 TBN = cotangent_frame(normalW, vPositionW, TBNUV, vec2(1., 1.));
 	#endif
 	#endif
 #endif
 #endif
 
 

+ 0 - 3
src/Shaders/ShadersInclude/bumpFragmentMainFunctions.fx

@@ -24,9 +24,6 @@
 	// Thanks to http://www.thetenthplanet.de/archives/1180
 	// Thanks to http://www.thetenthplanet.de/archives/1180
 	mat3 cotangent_frame(vec3 normal, vec3 p, vec2 uv, vec2 tangentSpaceParams)
 	mat3 cotangent_frame(vec3 normal, vec3 p, vec2 uv, vec2 tangentSpaceParams)
 	{
 	{
-		// flip the uv for the backface
-		uv = gl_FrontFacing ? uv : -uv;
-
 		// get edge vectors of the pixel triangle
 		// get edge vectors of the pixel triangle
 		vec3 dp1 = dFdx(p);
 		vec3 dp1 = dFdx(p);
 		vec3 dp2 = dFdy(p);
 		vec3 dp2 = dFdy(p);

+ 3 - 1
src/Shaders/ShadersInclude/pbrBlockClearcoat.fx

@@ -165,7 +165,9 @@ struct clearcoatOutParams
             #if defined(TANGENT) && defined(NORMAL)
             #if defined(TANGENT) && defined(NORMAL)
                 mat3 TBNClearCoat = vTBN;
                 mat3 TBNClearCoat = vTBN;
             #else
             #else
-                mat3 TBNClearCoat = cotangent_frame(clearCoatNormalW * clearCoatNormalScale, vPositionW, vClearCoatBumpUV, vClearCoatTangentSpaceParams);
+                // flip the uv for the backface
+                vec2 TBNClearCoatUV = gl_FrontFacing ? vClearCoatBumpUV : -vClearCoatBumpUV;
+                mat3 TBNClearCoat = cotangent_frame(clearCoatNormalW * clearCoatNormalScale, vPositionW, TBNClearCoatUV, vClearCoatTangentSpaceParams);
             #endif
             #endif
 
 
             #if DEBUGMODE > 0
             #if DEBUGMODE > 0