Matt Ownby's Reflective Water for Quake2
GOAL:
To create more realistic looking water by adding a reflection which can be distorted like real reflections are.  Therefore my method is to render the reflection into a texture so that it can easily be distorted.  The other method of reflection of which I am aware is to use the stencil buffer and draw the reflection normally with the vertical portion of the vertices flipped.  This is adequate if trying to create a regular mirror, but of course won't work with water!  In order to learn how to do this, I referred to this site.

Below are screenshots of my progress:

Before September 2nd, 2003


My initial attempt at reflective water.  What you see in the upper-left is the texture that holds the reflected image.  This texture is then mapped onto the water.
Notice how the reflection of the bridge is too low.  The reason I am using q2dm2 is because the water reflection isn't working at all on q2dm1 due to the fact that
two water surfaces which are at different vertical levels can be visible at the same time on that map.

September 2nd

I now have the reflection looking correct if I point the camera at specified spots.  Problems I am experiencing is that certain polygons are not being rendered at all due to Quake2's optimizations.  I also still haven't figured out why the reflection was too low in the previous screenshots, so I added some hacks to force the reflection to be properly aligned.  I just wanted to see it looking correct :)  I am feeling pretty discouraged about why the texture isn't aligned properly because I have double and triple checked many different things.  Reflections on q2dm1 are still completely broken.

September 5th

I found and fixed the bug that was requiring me to use manual hacks to align the texture properly!  Now it is fully automated for any area on the map!  Woohoo!  To celebrate, I took some screenshots of q2dm1, as well as one from q2dm5.

September 5th, later that night

I decided to add waves to the water!  It looks pretty awesome, especially in real-time hehe.  It works great on water that is transparent, but has problems on solid water because there is nothing being drawn underneath the surface of the water!  You can see in the q2dm5 picture that there is are little black gaps on the border of the water.  I don't believe there is really anyway to get around this except to recreate the .bsp files and treat _all_ water as transparent, or at least treat all water as being transparent for a certain depth (just enough to cover the lowest point of the wave).

TODO:
- Use pbuffers instead of rendering reflection directly to the screen.  I have the code to do this in windows, but don't know how to do it in glx yet.
- Try to make all polygons in the reflection draw properly, I am not sure if this is possible due to the structure of the .BSP files