Sign in to follow this  

Calculate normal knowing only point coordinates ...

This topic is 2320 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I don't know if there is a possible solution to this: I have a routine that gathers point coordinates using the depth buffer (using opengl glreadpixels function).
So, when the user click an object in the 3D window, the point coordinates are known. How would I calculate nornals for that point, if possible ?

Share this post


Link to post
Share on other sites
There are 2 principle ways:

1. During rendering not only color and depth but also the normal is computed and stored in its own buffer. Obviously, the normal belonging to a pixel can be read from such a normal buffer. Inaccuracies will occur at object margins where only sub-pixels are covered, of course.

2. The co-ordinates of the pointer position are "unprojected", i.e. the screen co-ordinates are mapped back into view space, and further transformed into world space. You can use either the 2D co-ordinates to compute a ray in the world space and search for the frontmost hit on an object, or else also use the depth to compute a point in world space and search for the object with its surface closest to that point. However, you can compute the normal with the knowledge of the point on the surface.

Share this post


Link to post
Share on other sites
Thanks haegarr. About solution 1, how do I access the normal buffer ? I couldn't find any info about it. Do I need to render geometry as VBO's in order to be able to access the normal buffer (currently I use display lists).

Share this post


Link to post
Share on other sites
[quote name='Alessandro' timestamp='1312722543' post='4845765']
About solution 1, how do I access the normal buffer ? I couldn't find any info about it. Do I need to render geometry as VBO's in order to be able to access the normal buffer (currently I use display lists).
[/quote]
There is no normal buffer at default. You have to use an appropriate fragment shader script and store the fragment's normal either in a frame buffer image or else in a texture (RTT).

Share this post


Link to post
Share on other sites

This topic is 2320 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this