forked from mirror/openmw-tes3mp
fix transpose error fo gles2
This commit is contained in:
parent
cda3782cf2
commit
cef725012c
2 changed files with 27 additions and 5 deletions
|
@ -243,7 +243,9 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
#if NORMAL_MAP && SH_GLSLES
|
||||||
|
mat3 transpose( mat3 m);
|
||||||
|
#endif
|
||||||
// ----------------------------------- FRAGMENT ------------------------------------------
|
// ----------------------------------- FRAGMENT ------------------------------------------
|
||||||
|
|
||||||
#if UNDERWATER
|
#if UNDERWATER
|
||||||
|
@ -376,13 +378,13 @@
|
||||||
float3 binormal = cross(tangentPassthrough.xyz, normal.xyz);
|
float3 binormal = cross(tangentPassthrough.xyz, normal.xyz);
|
||||||
float3x3 tbn = float3x3(tangentPassthrough.xyz, binormal, normal.xyz);
|
float3x3 tbn = float3x3(tangentPassthrough.xyz, binormal, normal.xyz);
|
||||||
|
|
||||||
#if SH_GLSL
|
#if SH_GLSL || SH_GLSLES
|
||||||
tbn = transpose(tbn);
|
tbn = transpose(tbn);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float4 normalTex = shSample(normalMap, UV.xy);
|
float4 normalTex = shSample(normalMap, UV.xy);
|
||||||
|
|
||||||
normal = normalize (shMatrixMult( transpose(tbn), normalTex.xyz * 2 - 1 ));
|
normal = normalize (shMatrixMult( transpose(tbn), normalTex.xyz * 2.0 - float (1.0,1.0,1.0) ));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENV_MAP || SPECULAR || PARALLAX
|
#if ENV_MAP || SPECULAR || PARALLAX
|
||||||
|
@ -576,5 +578,14 @@
|
||||||
// prevent negative colour output (for example with negative lights)
|
// prevent negative colour output (for example with negative lights)
|
||||||
shOutputColour(0).xyz = max(shOutputColour(0).xyz, float3(0.0,0.0,0.0));
|
shOutputColour(0).xyz = max(shOutputColour(0).xyz, float3(0.0,0.0,0.0));
|
||||||
}
|
}
|
||||||
|
#if NORMAL_MAP && SH_GLSLES
|
||||||
|
mat3 transpose(mat3 m){
|
||||||
|
return mat3(
|
||||||
|
m[0][0],m[1][0],m[2][0],
|
||||||
|
m[0][1],m[1][1],m[2][1],
|
||||||
|
m[0][2],m[1][2],m[2][2]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -221,6 +221,9 @@
|
||||||
#if UNDERWATER
|
#if UNDERWATER
|
||||||
#include "underwater.h"
|
#include "underwater.h"
|
||||||
#endif
|
#endif
|
||||||
|
#if NORMAL_MAP && SH_GLSLES
|
||||||
|
mat3 transpose(mat3 m);
|
||||||
|
#endif
|
||||||
|
|
||||||
SH_BEGIN_PROGRAM
|
SH_BEGIN_PROGRAM
|
||||||
|
|
||||||
|
@ -319,7 +322,7 @@ shUniform(float4, cameraPos) @shAutoConstant(cameraPos, camera_position)
|
||||||
|
|
||||||
// derive final matrix
|
// derive final matrix
|
||||||
float3x3 tbn = float3x3(tangent, binormal, normal);
|
float3x3 tbn = float3x3(tangent, binormal, normal);
|
||||||
#if SH_GLSL
|
#if SH_GLSL || SH_GLSLES
|
||||||
tbn = transpose(tbn);
|
tbn = transpose(tbn);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
@ -492,5 +495,13 @@ albedo = shLerp(albedo, diffuseTex, blendValues@shPropertyString(blendmap_compon
|
||||||
shOutputColour(0).a = 1.0-previousAlpha;
|
shOutputColour(0).a = 1.0-previousAlpha;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
#if NORMAL_MAP && SH_GLSLES
|
||||||
|
mat3 transpose(mat3 m){
|
||||||
|
return mat3(
|
||||||
|
m[0][0],m[1][0],m[2][0],
|
||||||
|
m[0][1],m[1][1],m[2][1],
|
||||||
|
m[0][2],m[1][2],m[2][2]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue