Original Post
Hi! There’s two things about normal mapping that I have never understand and till now I have not seen any clear explanation: => To apply normal mapping to a terrain for example in a coordinate system where y is up can I'm doing this in the pixel shader: float3 n = (2.0*tex2D(normalTextureSampler,In.normTexCoord).rbg)-1.0; in the pixel shader without float3 ambient = pixelColor * gMaterial.ambientColor; float3 diffuse = pixelColor * dot(n, gLight.direction) * gMaterial.diffuseColor; pixelColor = saturate(ambient + diffuse); Note: I'm using .rbg and not rgb because my up direction is y and not z (this is correct?). I assume then that the normal stores the y component in b (all the standard bluish normal maps do this) My question is, do I need in this case to transform the light vector to texture space? I have seen some implementations where the normal map is sampled directly in the pixel shader without transforming the light vector (I think I understand why I need to transform the light vector for other objects but in this case it’s necessary?). => Another question is: What is the difference between object space normal maps and tangent space normal maps, it's in the way they are built? It's in the way they are used? I’ve already implemented a terrain system doing exactly what I have described and I think it looks right…but it’s really the right way of doing normal mapping ? Thanks in advance for any help [Edited by - Ivo Leitao on August 8, 2007 1:34:20 PM]