Skip to main content
gamedev.net
🔒 Locked

gluUnProject

Started by _walrus 0 replies 550+ views
Original Post
_walrus
_walrus
Hi, i''m just wondering the workings of gluUnProject, more specifcally i want to know exactly the matrix that are applied to a point in screen coordinates to get it back into world coordinates. (i want to manually compute the transformation of gluUnProject). Suppose I have Transformations: Projection and Camera, where camera is the inverse of its world coorindate positioning and Projection is a Perspective projection. I specify a point to be drawn as follows: PushProjectionStack(Projection) ... PushModelViewStack(Camera) Draw Points PopModelViewStack ... PopProjectionStack Now i want to transform this point back into world coordinates. I could use gluUnproject, but I want to bring them back into world coorindates manually. Suppose P is a point in Screen coordindates: (InverseCamera* (InverseProjection*P)) isn''t right, I''m just curious as to what it is missing to manually compute gluUnproject. Thanks
_walrus
_walrus
I just figured it out, gluUnproject as follows:

P * NDCTranform * InverseProjection * InverseCamera

where NDCTransform convert screen coordinates into normalized device coordiantes. So if anybody needed to compute the matrix that does a gluUnproject the above equation will work. This can really speed up computations if you have to unproject many points in a scene each render pass (because gluUnProject most likely recomputes these transforms each time gluUnProject is called and since inverse must be computed this can be very costly).


[edited by - _walrus on December 12, 2002 11:09:58 AM]

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.