View Full Version : Obtaining angle of incidence
03-12-2012, 09:54 AM
Is there a way to determine the angle of incidence of a facet from the frame buffer?
I know how to use glReadPixels using GL_DEPTH_COMPONENT and then gluUnProject to get the 3D location. Is there a similar call that will provide me with the angle of incidence between the ray and the facet?
03-12-2012, 11:03 AM
I've done this with an ID buffer, where I render unique color for each polygon. Once you know the polygon ID, computing and transforming polygon normal with CPU is easy.
Alternatively you can render surface normal to G-buffer. I have no idea which one works better. Often you need either ID buffer or G-buffer for some other things, so that can nudge you towards a choice.
03-12-2012, 12:13 PM
Thank you, tksuoran. The first option sounds like my best bet. Plus this would solve another problem, which leads to a second question.
I was planning on using glReadPixels to read the depth buffer to obtain z. But I need resolution down to the centimeter. I did an experiment where I rendered a scene at 60 meters and then rendered it again at 60.001 meters, just to test for accuracy. To my surprise, the differences between the two was plus/minus 25 meters! Is the depth buffer and gluUnProject normally this inacurate? Now one difference between the two renderings is the field-of-view would be slightly different, but I don't think it would affect it that much.
The reason I said your solution kills two birds with one stone is while I'm computing the normal for the facet I can also caculate the z-value since the one from GL is so innacurate.
I'm more just curious about the accuracy issue.
In case anyone is curious, I already have a program to render scenes that gives me all the information I need. But we have a project where we will be doing tens of thousands of renderings that will take several days to run. I thought maybe I could use OpenGL to do the rendering for me and just read the results. This would greatly speed things up.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.