Zeno
11-19-2003, 09:45 AM
Hi all. This is an embarrasing question for me but I can't afford to spend too much more time dinking around with it, so I hope someone can help.
I'm trying to get a planar reflection (like a flat mirror) to work using projected texture mapping in a vertex program.
Here is what I am doing now:
1) Make matrix to reflect about the plane of reflection.
2) reflected modelview, RM = normal modelview * reflection matrix
3) Render reflected scene using RM and default camera projection matrix P. I'm pretty sure things work up to here.
4) Create texgen matrix: TG = S * (P * RM) where S is a scale and translation by 0.5 to center the texture.
5) Send texgen matrix as 4 GL_EYE_PLANEs using glTexGenfv. Each eye plane is a row from the TG matrix. This is done after camera modelview has been applied but individual object transforms have not.
6) Use texgen matrix in vertex program on vertices that have been transformed by modelview... i.e. texcoords = TG * (Mv)
What I'm actually seeing on the mirrored surface is several copies of what I think is the correct reflection texture. Like it's being projected way too small (I have GL_REPEAT as the texture mode right now, which is why I see many copies). Any ideas?
I'm trying to get a planar reflection (like a flat mirror) to work using projected texture mapping in a vertex program.
Here is what I am doing now:
1) Make matrix to reflect about the plane of reflection.
2) reflected modelview, RM = normal modelview * reflection matrix
3) Render reflected scene using RM and default camera projection matrix P. I'm pretty sure things work up to here.
4) Create texgen matrix: TG = S * (P * RM) where S is a scale and translation by 0.5 to center the texture.
5) Send texgen matrix as 4 GL_EYE_PLANEs using glTexGenfv. Each eye plane is a row from the TG matrix. This is done after camera modelview has been applied but individual object transforms have not.
6) Use texgen matrix in vertex program on vertices that have been transformed by modelview... i.e. texcoords = TG * (Mv)
What I'm actually seeing on the mirrored surface is several copies of what I think is the correct reflection texture. Like it's being projected way too small (I have GL_REPEAT as the texture mode right now, which is why I see many copies). Any ideas?