Generating normal field from a specific viewpoint

My apologies for my awkward usage of terms, as I am a complete newbie.

Let’s say I have a model with all normals calculated, and a canvas (window) that renders it from a specific viewpoint.
I’d like to create a matrix, the same size of the canvas, in which each cell contains the normal of the object in the corresponding canvas position. In other words, I want to know, for each pixel that is rendered, what is the corresponding normal of the object.

For example, if I have a plane, whose normal(s) are all (0,0,1), and it is rendered parallel to the canvas, then my matrix would contain (0,0,1) for each cell that corresponds to a point on the canvas that shows the plane, and null for empty (black) points in the canvas.

Of course, I intend to use this on more complex objects, possibly concave ones.

Thanks in advance,
Aaron.

I suggest you use shaders and just write the normal to the output, than you can readback the pixels and will have the normals.

You’ll probably want to write the output to a framebuffer object with a floating point texture or renderbuffer attached.

N.