I learned how to get normal values from here: http://twentyfourbecks.wordpress.com/2009/08/30/153/
but I don’t understand some things.
Normal is a vector [nx, ny, nz] in range [-1, 1]. So in order to output this values to an image [0, 1], we need do some math. v_n is short for vector of normal
1, v_n /2.0, so its range is [-0.5, 0.5]
2, + 0.5, so its range is [0, 1]
3, store it into an image. So the range is [0, 255].
In order to recover normal from the image, we need to
1, /255, so the range becomes [0, 1.0].
2, -0.5, so the range becomes [-0.5, 0.5]
3, *2, so the range becomes [-1.0, 1.0]
I use a sphere to test my algorithm, the result is not correct. So I suspect values the normal channel in the blender, it is the normalized-normal value of the mesh?
Does anyone help me with that problem?
Many thanks.
Since that is done using blender’s rendered image in compositor and using color operations instead of math( 7f7f7f happens to be that 0.5 or 256/2 in hex), result depends on blender’s color management settings. Switch it off and you’ll get correct result.
If i think of it, do normal values need to be color corrected, really?
Really thanks for you reply.
I have found that (not 100 percent sure it it truth or not)
The recorded normal is opposite in sign.
For example, if the normal is [x, y, z], the recovered normal is [-x, -y, -z]
Another question puzzled me is that why we need “invert” node, because the normal can be stored in an image in the range of [0, 1].
I am 99.98% positive that normals are not inverted. And not so positive on explaining why exactly we need invert node; could be due to how normal data is stored.
Anyhow - here’s the test file to make some walls or whatever - http://www.pasteall.org/blend/17789.
I model a test scene which only contains a cube. The cube is rotate 45 degree around Z axis. Here it is:https://dl.dropbox.com/u/54750216/normal_depth_map_ex.blend
So, for the left face and right face, the normal should be [-0.7, 0, 0.7] and [0.7, 0, 0.7]
but the calcuate result is [0.52, 0, -0.85] and [-0.7, 0, -0.7]. The most strange thing is the value is not symmatrical.
I read this [TABLE=“class: prettytable, width: 100%”]
Normal
Calculates lighting and apparent geometry for a bumpmap (an image which is used to fake detail on an object) or for changing the apparent direction of light falling on an object.
While Camera is zeroed out, cube and point light is not. That might impact the results.
Face Normal data is needed to calculate reflected ray. Bump values change Normals - change how light is reflected at given Normal’s position. Apparently Normals need to be saved. Well, it could be calculated for each face since there’s stored vertex coordinates for face - fire and forget, but i don’t think this is how it’s done.
If you switch off color management RGB is ~0.5. It still says Gamma corrected on color picker tho…