Rendering a reflection about an arbitrary plane
So I've rendered reflections ( for water ) in the past, but my reflections were restricted to a plane described as simply a function of Z ( where Z is up ).
My code looked something like so ( taken from my water demo, leaving out clip planes ):
What I'm wondering, is how I can reflect about an arbitrary plane, described in (a,b,c,d) format. I imagine a matrix can be constructed which would represent the inversion, but I'm weak. Any suggestions?
My code looked something like so ( taken from my water demo, leaving out clip planes ):
Code:
glPushMatrix();
glTranslatef( 0.0f, 0.0f, _currentWaterLevel );
glScalef( 1.0, 1.0, 1.0 );
glTranslatef( 0.0f, 0.0f, _currentWaterLevel );
renderScene();
glPopMatrix();
What I'm wondering, is how I can reflect about an arbitrary plane, described in (a,b,c,d) format. I imagine a matrix can be constructed which would represent the inversion, but I'm weak. Any suggestions?
I'm pretty sure you can use one of these: http://en.wikipedia.org/wiki/Householder_reflection
Let n = (a, b, c) be the normal of the plane and let p be some point the plane passes through. Then make the 3x3 matrix H = I  2nn^T =
Then do something like
Let n = (a, b, c) be the normal of the plane and let p be some point the plane passes through. Then make the 3x3 matrix H = I  2nn^T =
Code:
[ 12*a^2, 2*a*b, 2*a*c]
[ 2*a*b, 12*b^2, 2*b*c]
[ 2*a*c, 2*b*c, 12*c^2]
Then do something like
Code:
glTranslatef(px, py, pz)
glMultMatrixf(H)
glTranslatef(px, py, pz);
That looks like what I'm looking for. I'll give it a stab ( unfortunately, I won't be able to for a couple more days, as I work out the render to FBO pipeline in my current codebase ).
Thanks!
Thanks!
It's been a few weeks, but as of last night reflection rendering in my code is robust, flexible, reasonably fast, and works like a champ. I wanted to post a couple screenshots just to show off.
Thanks for the help! Without the householder transform I'd never have gotten this working!
Thanks for the help! Without the householder transform I'd never have gotten this working!
Possibly Related Threads...
Thread:  Author  Replies:  Views:  Last Post  
Calculating tangent coords for arbitrary poly meshes  TomorrowPlusX  8  7,387 
Jul 9, 2007 03:10 PM Last Post: Hog 

Water Reflection  Marjock  29  14,627 
Sep 1, 2006 02:00 AM Last Post: Marjock 

Math: mirroring a view frustum about a plane  TomorrowPlusX  1  3,919 
Aug 19, 2006 03:30 PM Last Post: Jones 

Drawing an Infinite Plane  unknown  3  3,779 
May 5, 2006 12:54 PM Last Post: Zekaric 

Math question: deriving rotation by plane intersection  TomorrowPlusX  6  5,240 
Jan 24, 2006 07:28 AM Last Post: TomorrowPlusX 