vrnunes at January 15th, 2009 22:49 — #1
After getting shocked by the Screen Space water that is starting to appear at some IOTDs, I started to implement this little thing by myself, on my actual terrain engine that uses the traditional forward rendering approach.
Below is the result of a few hours messing with it. Please note that this water implementation is NOT COMPLETED yet, I just implemented the "virtual" aspect (there is no mesh for the water at all), and the raycasting to calculate transparency.
Now I'll add the sky reflections and bump mapping, so I'll probably post another image in here when I'm finished with it.
The edges clipping is vertex-based, unfortunately. I will be glad to hear some criticism and suggestions! Until now I'm excited with this.
The engine itself has support for sky and other features, but I was not using when I took this screenshot.
reedbeta at January 15th, 2009 23:03 — #2
Cool! I implemented a partially screen-space water system for Infamous (which uses deferred shading) a few weeks ago. The ability to fog and distort the image behind the water really lends it a lot of realism. Another guy at my company wrote a nifty Fourier synthesis routine to generate the normal map for the water, and that works really well too.
3dmodelerman at January 15th, 2009 23:28 — #3
How does it render without a mesh though?
starstutter at January 16th, 2009 00:37 — #4
How does it render without a mesh though?
I guess we use the word "render" pretty loosley. It's a post process effect, an easy extension for deferred shading. As I understand it, you take the world-space position of the pixel (presumably from the g-buffer) and set a variable "water line". From there you basicly just test if the pixel is below the water line and how far it is. Theres also other steps to do lighting of course.
At least I *think* thats what it is. I could be wrong. I just remember doing something similar a while back.
Personally though, I havent warmed up to the idea of it yet. IMO it might be hard to get consistant with other water effects that require geometry.
reedbeta at January 16th, 2009 02:24 — #5
I guess we also use the term "mesh" pretty loosely. Actually, screen-space postprocessing effects use a full-screen quad (though in the case of the water, it would make more sense to clip the quad by the horizon line, to avoid using fillrate for the sky part of the screen).
That said, it's a good idea to use an actual water mesh, as you then get the benefits of early-Z culling to eliminate the pixels where there is no water. You can still recover the screen-space position, sample the depth buffer behind the water, and so on.
starstutter at January 16th, 2009 03:26 — #6
Actually, screen-space postprocessing effects use a full-screen quad
Well I just kind of assumed people knew that. Renering an effect without *any* geometry? Tha'd be a trick. Alright, well, I guess I'd say water geometry then.
vrnunes at January 16th, 2009 12:59 — #7
Just to make things clear, actually it is rendered within the terrain pixel-shader, very much like a fog effect.
It was my fault to mention the screen-space water and not to make it clear that my version is trying to "emulate" the screen-space water, but I'm not using a fullscreen quad.
For every pixel below the water plane, I cast rays from there to the eye position, intersecting with the water plane. Then, based on that distance, I determine the transparency at that pixel.
I made some further tests, and for the game that I'm currently making, it will fit nicely. What I really like about this water is that it is being really quick to implement, and does not add a single vertex to the batch.
EDIT: After some more tests, I am aborting my implementation of this technique, and returning to the water grid approach! I will keep the ray casting though, as I guess that was what really impressed me...
vrnunes at January 17th, 2009 04:03 — #8
OK, just to finish this thread that was just one of my very own equivoques, here is an up to date image made by my engine:
I am programming this engine in my spare time, which is not much, and starting a small win32 game on top of it.
starstutter at January 17th, 2009 13:58 — #9
wow nice work! I've mostly done indoor rendering up to this point, so terrain engines are something new for me to see