Rendering a reflection about an arbitrary plane

Posts: 1,199
Joined: 2004.10
Post: #1
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 ):

glTranslatef( 0.0f, 0.0f, _currentWaterLevel );
glScalef( 1.0, 1.0, -1.0 );
glTranslatef( 0.0f, 0.0f, -_currentWaterLevel );



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?
Quote this message in a reply
Posts: 45
Joined: 2006.07
Post: #2
I'm pretty sure you can use one of these:

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 =

[ 1-2*a^2,  -2*a*b,  -2*a*c]
[  -2*a*b, 1-2*b^2,  -2*b*c]
[  -2*a*c,  -2*b*c, 1-2*c^2]

Then do something like
glTranslatef(px, py, pz)
glTranslatef(-px, -py, -pz);
Quote this message in a reply
Posts: 1,199
Joined: 2004.10
Post: #3
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 ).

Quote this message in a reply
Posts: 1,199
Joined: 2004.10
Post: #4
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.

[Image: reflectiontest-2008-01-14-03.png]

[Image: reflectiontest-2008-01-14-02.png]

Thanks for the help! Without the householder transform I'd never have gotten this working!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Calculating tangent coords for arbitrary poly meshes TomorrowPlusX 8 7,833 Jul 9, 2007 03:10 PM
Last Post: Hog
  Water Reflection Marjock 29 15,571 Sep 1, 2006 02:00 AM
Last Post: Marjock
  Math: mirroring a view frustum about a plane TomorrowPlusX 1 4,037 Aug 19, 2006 03:30 PM
Last Post: Jones
  Drawing an Infinite Plane unknown 3 3,918 May 5, 2006 12:54 PM
Last Post: Zekaric
  Math question: deriving rotation by plane intersection TomorrowPlusX 6 5,463 Jan 24, 2006 07:28 AM
Last Post: TomorrowPlusX