Green tangent space normal maps
There was a post on the Polycount messageboards asking about green normal maps - most normal maps you see are blue/purple colour.
“Today my programmer told me that [green] was the correct normal map for direct x and that the blueish one that both photoshop and 3d studio max generate (that happens to be the only kind I ever see anywhere) are incorrect for the purposes of direct x in games. Is my programmer crazy or is it possible that max and photoshop do not produce normal maps ‘correctly’? Are there different kinds of normal maps?”
Many people responded, pointing out that there 3 types or normal maps - World, Object and Tangent. The most common kind for games are Tangent Space normal maps which are characteristically blue/purple. While all these responses were correct, I thought that they had missed the point of the question.
The relevant part of the question as far as I saw it was :
“Today my programmer told me that was the correct normal map for direct x…….Is my programmer crazy?”
No. The coder is correct. The keyword there is DirectX, and it’s all because of compression.
These days there are so many textures in a game that we need to use compression to get them to fit on the disc. DXT (DDS) is a very common compression format (it provides good mipmapping too). However, it were never designed with normal maps in mind and the compression you get with it is nasty, nasty, and thrice nasty to normal maps. A hack/trick is to move the red ‘X’ channel into the alpha channel, since the alpha channel gets compressed separately.
Why move the red channel? The reason red is moved and not green or blue is simple - it’s to do with the amount of data stored in each channel. Blue is the least useful colour in the normal map as the map is mostly blue anyway, so we move either green or red. But DXT compression of the 16bits in the image favours green - it uses 5 bits to store red, 5 bits to store blue and 6 bits to store green.
So, we move the red data into the 8bit alpha channel and it gets a whole 8bits all to itself, leaving the green with 6 bits and blue with 5 bits.
It’s worth noting that you could theoretically store another map in the old red channel - like a simple spec map or a gloss map. Also, since you can use simple maths to calculate the blue from the green and the red, you can drop the blue.
This gives you a good tradeoff with compression and detail, and makes the normal map look green instead of purple.
Technorati Tags: 3d modelling, Art, normal maps
August 28th, 2006 at 11:51 am
[...] In the normal mapping post, I had said the red channel gets 16 bits all to itself - in fact it is 8. Unless a coder tells me otherwise. [...]
December 14th, 2006 at 10:31 pm
Thanks for the cool resources Rick.
Nvidia told me when using their compressor I should zero out the red and blue channels, since their algo compresses all three channels together. The less colors it has to accomodate in the compression step, the more accurate the green channel colors will end up.
Another option is use white in one of the unused channels, and darken it down in the mips. The shader can use this to shorten the normals with distance to get rid of the specular messiness you get on distant surfaces.
http://www.nvidia.com/object/bump_map_compression.html
http://ati.amd.com/developer/NormalMapCompression.pdf
October 1st, 2007 at 10:24 pm
Computer Game News and Reviews…
I couldn’t understand some parts of this article, but it sounds interesting…