Wednesday, January 20, 2016

graphics programming - What are the advantages of tangent space normals over object space normals?


What are the advantages of normals in tangent space to normals in object space for calculation of bump mapping?



Answer



Everything, really.


The only benefit to object-space normals is simplicity. They're easier to use.


Tangent-space normals require a tangent-space basis, but offer:




  1. The ability to use the same texture for different surfaces. Object-space normal maps can only ever be used on the surface for which they were created. By regularizing normals in tangent-space, you gain the freedom to use the same bump texture for different surfaces. As long as the surface has a tangent-space basis, you'll get reasonable results.





  2. The ability to modify the texture mapping, with UV animation for example. Since object-space normal maps store normals in object-space, you can't just add 0.5 to all of the texture coordinates and expect to get proper normals from the texture. You can with tangent-space bump mapping.




  3. Smaller component representation. Object-space normal maps must have 3 components; you can't drop one and reconstitute it in the shader. Tangent-space normals will always have a positive Z component, so you can only store the XY of the normal. So you can either get greater precision by using a GL_RG16_SNORM or GL_RG16F formats (32-bits per texel), or employ compression by using an RG-compressed image format (GL_COMPRESSED_SIGNED_RG_RGTC1​, 8-bits per texel) format. You can try to use S3TC on an object-space normal map, but good luck with what you get back.




The absolute most you get with object-space normal maps is less computation time (not having to transform the light direction into tangent space, or alternatively, transforming the normal from tangent space into model space). But that's not a big deal, especially nowadays with deferred renderers running around.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...