Dynamic Water Rendering

So I want dynamic water. First, water as a post-process effect didn’t work out since it seems like it’s an infinite plane, and you can’t have 2 kinds of water in the same view. I also tried simple water, but it seemed too reflective and changing the color didn’t have any effect. I even tried the glass shader but I got some kind of error. My last resort would be to simply use a transparent blue material. Any good (enough) way to render this?

You might want to be more specific about what you are trying.



For example is all your water flat (lakes) or wavey (ocean)…horizontal or flowing…transparent or opaque (do you need to see the bottom or just water surface + reflection)…etc

Thanks for your reply.

It’s going to (or at least, I want to) have oceans, lakes, waterfalls, etc.

The ocean’s going to be pretty much flat and static so I want reflections at least on that. At first I used the post-process water, but I don’t want every part of the terrain that’s under sea level to have water.

I’m planning on having a 3 dimensional grid of points containing data on the “density” of the water, color, flow direction, etc., and use marching cubes on it. But before all that, I have to make sure I’ll be able to render it as “water”.

I guess I’ll create my own shader…

3d grid for large bodies of water is extremely heavy, which is why it’s seldom used in games.



I went with this system for shading, use some simple heightmap analysis to generate the (2d) flowmaps and use a simple quad for rendering. I’m using full reflection now (based it on SimpleWater) but will remove that, which would make it possible to use a more complex mesh like a tilted plane, or even a high-res rectangular strip type mesh that follows the terrain.



The shader interpolates the flowmap values very well (four samples, cubic interpolation), so it looks smooth and doesn’t require a lot of data points. I use 32x32 cells for a 512x512 area and it’s looking fine. If you want to use a 3d array for flow values instead it would still not be that large. I haven’t tried that myself tho, I only use the (relative) depth, width and direction of the river to derive the surface flow vectors, then a “post processing” step to sync each value with its neighbours (and to correct for obstacles later).



The shader is compatible with old cards, no vertex texture fetches or weird branching behavior etc.



One con is that it requires a good deal of pixel shader work (5-6 texture lookups and a lot of calculations). This could probably be reduced tho (the author suggests a few things). Also of course it is not as versatile as a particle based system…



Developement is on hold now, working on a sky system and some other stuff, but I’ll get to it again later. Probably this fall. There’s a vid in some thread btw, from the early dev. I think if you search the forum for “running water” you find it.