Screen Space Water

17ba6d8b7ba3b6d82970a7bbba71a6de
0
vrnunes 102 Jan 16, 2009 at 03:49

Hi guys,

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.

water\_001.jpg

Regards!

8 Replies

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Jan 16, 2009 at 04:03

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.

29423feee2c8904e56009913425351b3
0
3DModelerMan 101 Jan 16, 2009 at 04:28

How does it render without a mesh though?

A0c9c0649c5deacc0ae3b7f7721c94d2
0
starstutter 101 Jan 16, 2009 at 05:37

@3DModelerMan

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.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Jan 16, 2009 at 07:24

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.

A0c9c0649c5deacc0ae3b7f7721c94d2
0
starstutter 101 Jan 16, 2009 at 08:26

@Reedbeta

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.

17ba6d8b7ba3b6d82970a7bbba71a6de
0
vrnunes 102 Jan 16, 2009 at 17:59

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…

17ba6d8b7ba3b6d82970a7bbba71a6de
0
vrnunes 102 Jan 17, 2009 at 09:03

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:

game\_003.jpg

I am programming this engine in my spare time, which is not much, and starting a small win32 game on top of it.

Regards!

A0c9c0649c5deacc0ae3b7f7721c94d2
0
starstutter 101 Jan 17, 2009 at 18:58

wow nice work! I’ve mostly done indoor rendering up to this point, so terrain engines are something new for me to see :)