Hi,
I’m currently working on a sprite editor for bump map.
So far generating filters to create normals works great, but the precision seems slightly off.
(Z could be inverted depending on left/right handed)
But there are few things that are bothering me:
there is no way to have a perfect orthogonal normal since R and G couldn’t be translated to exactly 0 (127 is a bit below 0 and 128 a bit above)
I heard that some engine have 128 as 0, and other have 127 (like the Source engine), what about Babylonjs?
Some existing tools I use seems to generate “exaggerated” normals, e.g. the blue channel drop below 127 (sometime around 110 or even 100), it’s supposed to create a normal aiming slightly in the backward direction: is it a bug of those tools, or am I missing something???
It would be nice if a dev could give me the exact formula for converting back and forth RGB and normals.
This is true for Babylon.js. Most people use 128 to represent 0, but in Babylon.js, the code will do this (which is the equivalent math as what you noted):
128 / 255 * 2 - 1 = 0.003921568627451
In Babylon.js, if you want to exaggerate the normal, you can use the level property to do it. Like this:
bumpTexture.level = 2;
This will result in the X and Y components of the normal being multiplied by 2 for PBR materials.