PDA

View Full Version : Plane Projection



07-16-2003, 07:47 PM
I'm attempting to implement an effect that will be like forcing all rendering to be projected onto a specified plane and clipped to a specified reason probably using the stencil test. This effect would be used for simulating video screens or something of that nature.

My theory is:

The vertex starts in objectspace.
Multiplied by the modelview matrix, it is now in worldspace.
(marker here)
Multiplied by the projection matrix, it is now in viewspace.
...

At the marker, I need to transform the point given in worldspace into a point on the plane that is also in worldspace. Since it occurs directly between the modelview and projection transformation, it occured to me I could either multiply the projection matrix (freshly loaded with an identity matrix at the beginning of the frame) by the matrix that would project points to the plane, or I could do it after all modelview transformations by multiplying that matrix by the new one.

I'm sure both ways have their merits, and even the red book suggests using the projection matrix to force rendering to flatten to a plane.

I am aware of depth test issues with this, but I'll work with that later. I have a matrix that almost seems to work given some parameters; I'm working some errors out of that.

My question is, am I on a good track for this idea?

errno
07-16-2003, 10:30 PM
is it a good idea ??? it depend on the scene you want to project on the plane.
the method works, but you'll have some problems with depth test because all fragments will have the same z. the image on the plane will be very messy.

to avoid this, the best way is to render the scene on a texture and render the plane with this texture.

07-17-2003, 05:06 AM
Yes, precisely the depth issue I was talking about. Right now my work around is to enforce back-to-front drawing of things with the on the "monitor," using a depth function of GL_LEQUAL

07-17-2003, 10:43 AM
Furthermore, it would not be too hard to modify this to allow the same rectangular region defined as a "monitor" to be redefined as a "mirror"

It would just be a different matrix.

errno
07-17-2003, 10:43 PM
yes, but you'll have to find the matrix...