PDA

View Full Version : screen->texture coord xform?



DaddyO
04-13-2004, 11:51 AM
OpenGL rookie looking for some answers... Please help.

Iím working on a system design which uses texture mapping to project satellite imagery onto terrain, then allows the user to graphically pick a point in the projected image (screen coordinates). We then want to convert the screen coordinates back into texture coordinates (NOT object coordinates). The reason for this is that we have a very precise image-to-object coordinate transform for the satellite image (far more precise than the OpenGL projection), and accuracy is critical. No object-to-image coordinate transform is available.

How can I convert screen coordinates into texture coordinates?

plasmonster
04-13-2004, 03:43 PM
This is a real dome scratcher. If all you have to start with is a screen coordinate, then you might proceed as follows:
Firstly, by texture coordinate, I assume you mean the linearly interpolated vertex (s,t). Finding this exact value will be difficult, if not impossible. But to attempt it, you have to make a stop in object space. You see, you need to find out where you hit the object; then, understanding how gl interpolates texture coordinates, you could derive the (s,t). This could be very tricky, especially if the projection is difficult to determine, and even if not, an exact match is highly unlikely. There might be a clever way to do this with a fragment program, but I would really need to give that some thought, and, being new to gl, that might not be your first choice. Maybe there's a way to turn the problem on its head. You say you are projecting an image; is there a way to reverse the projection process? That is, bounce the selection ray into the projection space itself? Just a thought...