Sign in to follow this  
VerMan

Mapping coordinates (gluUnproject - gluProject)

Recommended Posts

Hello fellows, I'm doing some shadow mapping and i'm rendering from the light's point of view, get the depth buffer and save it to some array using glReadpixels. Later i render from the camera's point of view, do another glReadpixels and for every pixel i need to find its position in the previously saved array (where the depth map is stored). So i thought, ok 1) for every pixel in my array (x,y) i do a glUnproject(x,y,depth[x,y], camView, camProj, viewport, &wx, &wy, &wz) 2) glProject(wx, wy, wz, lightView, lightProj, viewport, &lx, &ly, &lz) but i'm getting some garbage, i.e. negative coordinates or off-limits like -1322, 673, etc assuming the viewport is 0,0,512,512 this should not happen... does it? or maybe i'm totally wrong in my approach... comments? thank you

Share this post


Link to post
Share on other sites
well, i figured it out.
For some reason i don't know after a glReadPixels(0,0,width,height,pixels) where pixels has been declared as:
GLubyte pixels[width][height][3]

I was reading this using a nested for loop like:
for(x=0; ...)
for(y=0; ...)
gluUnproject(x,y,...)

but x and y were inverted so now I use:
gluUnproject(y,x,...) and i'm done (wtf?)

Share this post


Link to post
Share on other sites

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