PDA

View Full Version : Reading normal vectors of a 3D model



Var2008
08-06-2008, 03:21 PM
I have rendered a 3D model (available to me in the form of vertices and triangles), and I am able to use glreadpixels and gluUnproject to read the color and depth values of every point of the model that is visible from my chosen viewpoint.

My application also needs the normal vector associated with each such point. Does OpenGL provide me a quick way to do this? Of course, I could try to locate in which triangle of the model, each point belongs and then get the normal corresponding to that face. But that would be slower.

Zengar
08-06-2008, 05:11 PM
Use shaders to output the per-pixel normal. It should be also possible by playing around with lights and or texture combiners, but shaders are the easiest way.