Skip to main content
GameDev.net gamedev.net
🔒 Locked

Real Reflection Question

Started by GMA965_X3100 Dec 31, 2010 at 1:09 AM 3 replies 1.6k views
Original Post
GMA965_X3100
GMA965_X3100
So, I and I just decided to learn reflection, via openGL's powerful stencil buffer functionality.

B4 u leave, check out the issue i have bottom the post, and download my little reflection test! controls are on screen:
http://www.mediafire.com/?j6gccss6b65m6m2

So I code and code, and still, object was not reflecting. And when i say code and code, I meant frustratingly recoded reflection code over and over, and still to no avail. I checked and checked, until i realise something; the pixel format descriptor's stencil value wasn't set to 1!!!!!

my 'nicely' reflected boxxer car from my Ghetto project:


Uploaded with ImageShack.us


Uploaded with ImageShack.us


Uploaded with ImageShack.us

damage is being applied:

Uploaded with ImageShack.us


Uploaded with ImageShack.us


Anyway, solved that issue. And I noticed that objects reflected on are drawn differently than normal.

BUT I HAVE AN ISSUE!!!
We all know the reflection equation ( eg. ref_eq [ ] = { 0.0f, -1.0f, 0.0f, 0.0f } ) is used to remove artifacts, ( odd imaging results ) when applied with glClipPlane ( ) in stencil reflection process.

I know that in order to reflect accross x axis, the equation would change such that only the x coord would be -1, others 0, ...and the reflected object would be scaled such that also the x coord would be -1, others 1. I know that the target ( eg. floor being reflected on ) could be rotated, but I rotated, adjusted the reflection 'equation' and the scale function, yet still no result!!!!! Help I nuh, help I please!!!!

[Edited by - GMA965_X3100 on December 31, 2010 2:55:30 AM]
gzaloprgm
gzaloprgm
AFAIK the clip plane is only for objects intersecting the floor (not the car)

To draw the reflected geometry nicely, maybe you should try culling the other faces (glCullFace).

Cheers,
Gzaloprgm
In tangent space no one can hear you scream
GMA965_X3100
GMA965_X3100
I know that the clip plane is for reflection thourgh floor, I have never stipulated other wise. I asked how I would reflect through other axes, say a wall ( z axis )...because I tried the obvious means, and it didn't work..
Lord_Evil
Lord_Evil
If you want to do a wall reflection, just adjust your scaling, i.e. instead of glScalef(1,-1,1) you could do (1,1,-1) for a reflection on the xy-plane.

However, if you want to do an arbitrarily oriented reflection, you need to calculate the correct scaling factors. Have a look here for some hints.


Another option (which AFAIK is more common these days) would be to render the reflected scene to a texture and apply that you your mirror.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.