After being disappointed in how bad "faked" reflection looks when not using a planar water surface, I went ahead and implemented screenspace raytracing:
It was inspired by
this video showcasing the new CryEngine, but the implementation is my own.
The implementation is quite simple:
The scene is first rendered without the water to two textures - one containing the actual colors, the other containing the depth info (in a FLOAT_R32 texture).
The scene is then rendered again to the screen, this time with the water.
The water is rendered with a shader, where the magic happens:
In the fragment shader, the geometry position together with the water normal at that position is used to calculate a reflected ray, i.e. the reflection direction.
Steps are then taken along this reflection direction.
For each step, the new position is projected back onto the screen.
This new screen position is used to look up the scene depth at that location.
If the distance between the camera and the position along the reflected ray is greater than the value in the depth buffer, the ray has hit terrain. We then use the screen position to look up the color from the color texture.
Of course, there are some issues, as can be seen in the video, as well as a significant cost (my framerates dropped from 50 FPS to 30 FPS). Mind you, the shader is not optimized yet, but it's unlikely it will be possible to get it back to 50 FPS by shader optimization alone, at least not without losing too much quality in the reflections...
Anyways, feel free to leave your comments.