How to avoid a common rendering mistake
We've all been there.
You've got a great bunch of models arranged into a stunning scene,
You've found some great PBR textures on the net.
You've set up your materials and applied them to your models.
Your cameras and lighting are all set.....You push render, grab another cup of coffee.....and the completed image looks great. Well, it looks good..... It's not bad,.... You look closer and you realise that there is something off with the image. You can't really put your finger on it.
Lets take a closer look at the photo above. The textures are the same. The left and right sides look similar, but the left hand side of the image looks a little weird. The shadows look strange and the edges of the bricks just don't look right. So what's going on?
The materials for the left and right hands of the wall are almost identical. They both use the same 6K textures and comprise of a Color Map, a Reflection Map as well as a Normal Map. The normal map is where the weirdness happens.
What exactly is a Normal Map?
A normal map is a 'purpley' colored image texture that is used in computer graphics to fake small artifacts such as bumps and small indents on a flat plane. It allows the rendering program to add a slight 3D effect to your materials. In the image above, the normal map simulates the depth of the mortar joints between the bricks as well as adding surface details to the bricks. It really is a clever way to add additional detail without adding unnecessary polygons
And this is where our issue raises it's ugly head.
OpenGL vs DirectX
The 2 main graphic standards are OpenGL and DirectX and with regards to Normal maps are 66% identical. The last 33% is where the issue occurs. The difference between the 2 standards is how they store the Y-Axis information on the Green color channel contained in the Normal map. The good news is that it is a simple matter to convert the maps from one standard to the other by inverting the Green channel of the image.
OpenGL Normal map
The image below is an example of a Normal map formatted to the OpenGL standard. There is a clear impression here that the relief details are displayed as you would expect to see in your final renders.
DirectX Normal Map
The image below is an example of a Normal map formatted to the DirectX standard. This map is exactly the same as the OpenGL version except I have inverted the Green channel. Inverting the Green channel gives us an almost inverted view from the OpenGL map.
Recommended by LinkedIn
What happens if you use the wrong Normal map?
If you are using software that expects Normal maps in the DirectX format and you use the OpenGL format your images just won't look right. The images will look Ok when viewed at a distance.
The software I used to render these images uses Direct X. There is not really much difference in the images although the correctly formatted DirectX image still looks more cohesive and correct.
For this image I used a Normal map formatted for OpenGL
For this image I used a Normal map formatted for DirectX
Once we start to produce close up images the effects of the Normal maps become obvious and the issues can be seen easily. Again, the images are passable and unless you know what you are looking for the effects are easily overlooked.
For this closeup image I used a Normal map formatted for OpenGL. Close inspection of the images shows that the edges of the bricks seem to protrude from the face of the bricks. The white mortar on the full brick at the top middle of the image seems to be set inside the face of the brick.
The next closeup image uses the correct DirectX format Normal map. You can see the bricks look real, the shadows match, the mortar on the faces of the bricks look solid and real.
Conclusion
The difference between the 2 standards is very easy to see when presented side by side, but when configured incorrectly you get that feeling that something isn't quite right. If you are creating your own models and textures
Its very easy to run a quick test render to confirm that you get the output you require and if it is incorrect a quick swap of the Green channel will fix you right up.
Great info, thanks for sharing it.
Well written Dave
Great article!