Hello,
I’m trying to use compositing nodes to render out the normals for a set of scenes that I have, and I want to render out (something) that will allow me to determine exactly the correct normals, i.e. three layers of values for x,y, and z normals in the range of -1 to 1, with 0 = no normal component in a given direction.
Since there is no image format that will store negative values, I have been trying to use mysterious Blender Math to create an output in the range of 0-1, 0-2, or 0-255, and render that out to an image (.png or .hdr), which I will then convert back to -1 to 1 using Matlab. But I haven’t yet been able to map the normals correctly.
I tried this setup:
http://twentyfourbecks.wordpress.com/2009/08/30/153/
… and the normals seem to be skewed toward +1 in both x and y dimensions. That is, the normals that should have a value of 0 (or 128, or 1) end up having higher values. Without access to some output of the original normal data, I can’t figure out why.
Here is my test setup. The node setup from the web site is on the bottom; another version that I tried is on top (more on that below). The colors in the “multiply” and “add” nodes at the bottom are both using colors of [.5,.5,.5] (mid-gray).
… and here is my evidence that the normals aren’t mapping as expected:
(The gray band - pixel intensity = 128 - should show up right at the center of the sphere, but it doesn’t!)
My alternative node setup uses “NORMALIZE” nodes, and seems to get me pretty close values to the (true?) values.
However, the “normalize” nodes make me nervous, because I’m not sure what they’re doing. What if, for example, I have a scene without any normals pointing (close to) straight left? Will the normal vectors be “normalized” properly? I doubt it. And even as I have implemented this, the normal vectors don’t map exactly from 0 to 2 (they map from .0039 to 2.0078). Why the offset?
I realize this is a bit of a fussy question, but I’m doing computations on these normals that are for a research project, so “looking about right” isn’t quite good enough.
Any ideas how I can better implement this are MUCH appreciated. Thanks!
Mark