How to use normal maps?
Use CoronaNormal node in the material editor to load RGB normal map files you want to use as the bump map for your material. The bitmaps can be loaded using either the native 3ds Max Bitmap node, or using the Corona Bitmap node, which offers more filtering options and generally renders faster:
When loading the normal map file in 3ds Max, it is recommended to use the default gamma settings in the Browse Images for Input window:
What are the issues?
Unfortunately, there are various standards when it comes to the way normal map information is stored and interpreted by various 3D software. For example, red color may represent either "up in the plane of texture" direction or "right in the plane of texture" direction. The light blue color (RGB 128 128 255) usually represents "flat" areas (directly facing the viewer), however the image may have some kind of gamma correction applied to it, which may change that color value.
This means that the same image may produce different results when loaded as a normal map in different software. Likewise, two normal maps created with different software may produce different results when loaded as normal maps and rendered in a single 3D application.
To overcome this, the CoronaNormal node offers several options:
- "Add gamma to input" - this adds sRGB gamma to the linear input image. This must be enabled to get the correct results if the loaded normal map lacks sRGB gamma.
Note: Corona will attempt to detect whether this option should be enabled or not, and in case it should, will show a warning message once rendering is started:
- Flip red (X) - determines the left-to-right direction of the normal map (higher red values mean either right direction or left direction of the normals).
- Flip green (Y) - determines the bottom-to-top direction of the normal map (higher green values mean either bottom direction or up direction of the normals)
- Swap red and green - decides which color should be interpreted as the left-to-right direction, and which as the left-to-right direction
How to find out what settings to use?
There are two ways to find out which settings are correct:
- Get reliable information about the normal map you are using (e.g. it could be included in a readme file supplied with the bitmap).
- Trial and error approach.
Sometimes it is easy to imagine what the normals should look like (in case of a spherical or pyramidal pattern), but sometimes it may be harder (in case of a chaotic, organic pattern).
Below is a guide showing what settings to apply in various cases.
In the first example, we will be using a normal map generated from a half-sphere, seen from above. It was saved directly from the Corona VFB as a 32-bit EXR file:
The normal map we will be using.
Viewport screenshot of the geometry which was used to capture the normal map.
You can download the normal map here: [link]
Let's see what happens if we load the above normal map into a CoronaNormal node with the default settings, plug it into a bump map channel of a CoronaMtl, and enable some reflectivity to see how the light distributes:
It is clear that the bump map is not working correctly (for example, the bumps are concave, and they should be convex). So let's try fixing that:
First, let's render the test object without any kind of bump, to see what the correct normals look like:
This will allow us to better understand whether gamma should be added to the normal map or not. If the gamma of the normal map is wrong, we will see a difference in the "flat" areas, which should look identical to the original geometry.
Let's enable the normal map back, and see how it reacts to the "Add gamma to input" checkbox:
"Add gamma to input" disabled.
"Add gamma to input" enabled.
We can clearly see that enabling the "add gamma" checkbox did not solve the issue with incorrect shading. Furthermore, it made shading in the "flat" areas worse, which means that we definitely should not enable this option. This means that the original normal map already contains correct gamma.
Let's try with the "Flip green (Y)" setting now:
"Add gamma to input" disabled. "Flip green (Y)" enabled.
We can now see that the material looks closer to what we would expect - the bumps are convex, and the shading looks correct. We can further fine-tune the material, by slightly lowering the normal map's strength:
"Strength multiplier" lowered to 0,5.
The material now looks as we would like it to. The solution was to leave "Add gamma" checkbox unchecked, enable the "Flip green" option, and lower the strength of the normal map to a desired value.
As it was mentioned above, those settings may be however different for normal maps downloaded from (or generated with) different sources:
In the above case (bricks), the solution was to enable both the "Add gamma" and "Flip green" options, otherwise the result would be incorrect.
In the above case (gravel), the solution was to enable the "Add gamma" and "Swap red and green" options, otherwise the result would be incorrect.
Note: interactive rendering is extremely useful in finding out what settings should be used for a specific normal map.