Reflective surfaces (e.g. water)

Started by
46 comments, last by VanKurt 20 years, 6 months ago
I''m trying to create a reflective surface just like mirror or water. I''ve read a lot of posts on this topic and I think I''ve got the theory by now: 1) You flip the geometry around the water plane 2) You set the water plane as a clipping plane (so that things under water aren''t drawn) 3) You render the scene to a texture But as easy as that sounds I''ve still some questions: - What''s the easyest way to flip my whole geometry (that are a LOT of objects) about the water plane? Is there some easy trick like moving the camera/changing it''s up vector?? - How do I define my own clipping planes? - How do I apply that texture to my plane? What texture coords should I use and where do I get them???? Lots of questions...but hopefully lots of answers, too.... Thanks a lot, FunKurt
Advertisement
>- What''s the easyest way to flip my whole geometry (that are a
>LOT of objects) about the water plane? Is there some easy trick
>like moving the camera/changing it''s up vector??

Use glScale-functions.
glScalef(1, -1, 1); // Flips y

>>How do I define my own clipping planes?
Use glClipPlane(GL_CLIP_PLANE0, plane_equation) to define the plane.
Then use glEnable(GL_CLIP_PLANE0) to enable it.
I''m looking into this, too, and I was wondering if you should define a sort of viewing box coming out from the water so you only draw reflected objects that have reflections you can see from your current position. Is this right?
Thanks circuit!

But what about the texturing? How does that work?
I think it would be difficult to map a texture on a quad which has been rendered that way...
I''ve tryed google in order to find some tuts/samples, but it''s all about stencil reflection, which not what I need...

Maybe smeone has got a good link???
Thanks!!!
I think there is another way using the stencil buffer.
It goes somthing like:
draw your reflective surface into the stencil buffer,
flip your geometry and redraw it to the colour buffer only where the stencil buffer is set.

---
When I''m in command, every mission''s a suicide mission!
---When I'm in command, every mission's a suicide mission!
Is this method suitable for large planes? (I mean REALLY big, so that the player sees only a very small part of it at a time)
Yes. The stencil buffer is just as big as the color buffer (your screen). The only limit that you have is that ou have to render your terrain twice. Once flipped over Y and once normal, so it takes longer.

I hope you have a good frustum culling / occlusion culling method!

Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]


GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don''t post crap!

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

Allright then! Thanks for your support.. I''ll try that as soon as possible :-)
Hi there!

The glScalef(1,1,-1) works great... except for one thing.

The models get all funky normals... if I flip a box, it´s like you press down the top of it and through to the other side... thus, leaving the box inside out. <- not nice! =)

Is there a function for flipping the normals? thanx!



P.S would it be better to have several small quads of water(textures), or just one quad/trianglepair with one texture wrapped all over it? I recon the one quad solution is pretty fillrate punishing..?

"Game Maker For Life, probably never professional thou." =)
"Game Maker For Life, probably never professional thou." =)

This topic is closed to new replies.

Advertisement