mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-04 02:41:19 +00:00
Pass the tangent in object space
This commit is contained in:
parent
157c11398d
commit
b4dda045a6
@ -28,7 +28,7 @@ varying vec2 emissiveMapUV;
|
||||
#if @normalMap
|
||||
uniform sampler2D normalMap;
|
||||
varying vec2 normalMapUV;
|
||||
varying vec3 viewTangent;
|
||||
varying vec3 passTangent;
|
||||
#endif
|
||||
|
||||
#if @envMap
|
||||
@ -52,7 +52,7 @@ varying vec4 lighting;
|
||||
varying vec4 passColor;
|
||||
#endif
|
||||
varying vec3 passViewPos;
|
||||
varying vec3 passViewNormal;
|
||||
varying vec3 passNormal;
|
||||
|
||||
#include "lighting.glsl"
|
||||
|
||||
@ -77,15 +77,17 @@ void main()
|
||||
gl_FragData[0].xyz = mix(gl_FragData[0].xyz, decalTex.xyz, decalTex.a);
|
||||
#endif
|
||||
|
||||
vec3 viewNormal = passViewNormal;
|
||||
|
||||
#if @normalMap
|
||||
vec3 normalTex = texture2D(normalMap, normalMapUV).xyz;
|
||||
|
||||
vec3 viewBinormal = cross(viewTangent, viewNormal);
|
||||
mat3 tbn = mat3(viewTangent, viewBinormal, viewNormal);
|
||||
vec3 normalizedNormal = normalize(passNormal);
|
||||
vec3 normalizedTangent = normalize(passTangent);
|
||||
vec3 binormal = cross(normalizedTangent, normalizedNormal);
|
||||
mat3 tbn = mat3(normalizedTangent, binormal, normalizedNormal);
|
||||
|
||||
viewNormal = normalize(tbn * (normalTex * 2.0 - 1.0));
|
||||
vec3 viewNormal = gl_NormalMatrix * normalize(tbn * (normalTex * 2.0 - 1.0));
|
||||
#else
|
||||
vec3 viewNormal = gl_NormalMatrix * normalize(passNormal);
|
||||
#endif
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ varying vec2 emissiveMapUV;
|
||||
|
||||
#if @normalMap
|
||||
varying vec2 normalMapUV;
|
||||
varying vec3 viewTangent;
|
||||
varying vec3 passTangent;
|
||||
#endif
|
||||
|
||||
#if @envMap
|
||||
@ -43,7 +43,7 @@ varying vec4 lighting;
|
||||
varying vec4 passColor;
|
||||
#endif
|
||||
varying vec3 passViewPos;
|
||||
varying vec3 passViewNormal;
|
||||
varying vec3 passNormal;
|
||||
|
||||
#include "lighting.glsl"
|
||||
|
||||
@ -85,7 +85,7 @@ void main(void)
|
||||
|
||||
#if @normalMap
|
||||
normalMapUV = (gl_TextureMatrix[@normalMapUV] * gl_MultiTexCoord@normalMapUV).xy;
|
||||
viewTangent = normalize(gl_NormalMatrix * gl_MultiTexCoord7.xyz);
|
||||
passTangent = gl_MultiTexCoord7.xyz;
|
||||
#endif
|
||||
|
||||
#if @specularMap
|
||||
@ -98,5 +98,5 @@ void main(void)
|
||||
passColor = gl_Color;
|
||||
#endif
|
||||
passViewPos = viewPos.xyz;
|
||||
passViewNormal = viewNormal;
|
||||
passNormal = gl_Normal.xyz;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user