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:
- Make matrix to reflect about the plane of reflection.
- reflected modelview, RM = normal modelview * reflection matrix
- Render reflected scene using RM and default camera projection matrix P. I’m pretty sure things work up to here.
- Create texgen matrix: TG = S * (P * RM) where S is a scale and translation by 0.5 to center the texture.
- 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.
- 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?