|
@@ -12,15 +12,21 @@
|
|
|
#if defined(TANGENT) && defined(NORMAL)
|
|
|
mat3 TBN = vTBN;
|
|
|
#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
|
|
|
#elif defined(ANISOTROPIC)
|
|
|
#if defined(TANGENT) && defined(NORMAL)
|
|
|
mat3 TBN = vTBN;
|
|
|
#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
|
|
|
|