From c0f64112211bf30dd5bce70c97f39bdf02385041 Mon Sep 17 00:00:00 2001 From: Peter Schaefer Date: Sat, 9 May 2015 23:32:03 +0200 Subject: [PATCH] fixed Normals in VS --- shader/basicTexture_VS.hlsl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shader/basicTexture_VS.hlsl b/shader/basicTexture_VS.hlsl index 29d73f0..2b83c33 100644 --- a/shader/basicTexture_VS.hlsl +++ b/shader/basicTexture_VS.hlsl @@ -18,7 +18,11 @@ void main() { fUVs = aUV; vec4 world_Position = uModel * vec4(aPosition, 1); - worldNormal = (uModel * vec4(aNormal, 0.0f)).xyz; + mat3 scale = transpose(mat3(uModel))*mat3(uModel); + vec3 Normal; + for (int i = 0; i < 3; ++i) + Normal[i] = 1/(scale[i][i])*aNormal[i]; + worldNormal = normalize((uModel * vec4(Normal, 0.0f)).xyz); gl_Position = uProjection * uView * world_Position; } \ No newline at end of file -- 2.47.3