Fix tangent/bitangent computation

Shouldn't make any difference since we don't rescale that much
This commit is contained in:
Vincent Lejeune 2015-01-12 23:01:35 +01:00
parent cfbbeef441
commit 08cb4b4297
2 changed files with 8 additions and 4 deletions

View File

@ -50,9 +50,11 @@ void main(void)
mat4 ModelMatrix = getWorldMatrix(Origin, Orientation, Scale);
mat4 TransposeInverseModelView = transpose(getInverseWorldMatrix(Origin, Orientation, Scale) * InverseViewMatrix);
gl_Position = ProjectionViewMatrix * ModelMatrix * vec4(Position, 1.);
// Keep orthogonality
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
tangent = (TransposeInverseModelView * vec4(Tangent, 0.)).xyz;
bitangent = (TransposeInverseModelView * vec4(Bitangent, 0.)).xyz;
// Keep direction
tangent = (ViewMatrix * ModelMatrix * vec4(Tangent, 0.)).xyz;
bitangent = (ViewMatrix * ModelMatrix * vec4(Bitangent, 0.)).xyz;
uv = Texcoord;
uv_bis = SecondTexcoord;
color = Color.zyxw;

View File

@ -47,9 +47,11 @@ void main(void)
mat4 ModelViewProjectionMatrix = ProjectionMatrix * ViewMatrix * ModelMatrix;
mat4 TransposeInverseModelView = transpose(InverseModelMatrix * InverseViewMatrix);
gl_Position = ModelViewProjectionMatrix * vec4(Position, 1.);
// Keep orthogonality
nor = (TransposeInverseModelView * vec4(Normal, 0.)).xyz;
tangent = (TransposeInverseModelView * vec4(Tangent, 0.)).xyz;
bitangent = (TransposeInverseModelView * vec4(Bitangent, 0.)).xyz;
// Keep direction
tangent = (ViewMatrix * ModelMatrix * vec4(Tangent, 0.)).xyz;
bitangent = (ViewMatrix * ModelMatrix * vec4(Bitangent, 0.)).xyz;
uv = (TextureMatrix * vec4(Texcoord, 1., 1.)).xy;
uv_bis = SecondTexcoord;
}