From: Peter Schaefer Date: Sat, 9 May 2015 21:32:03 +0000 (+0200) Subject: fixed Normals in VS X-Git-Url: https://git.leopard-lacewing.eu/?a=commitdiff_plain;h=c0f64112211bf30dd5bce70c97f39bdf02385041;p=cgue_weave.git fixed Normals in VS --- 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