Skip to main content
gamedev.net
🔒 Locked

Water effects?

Started by Lithic Feb 10, 2003 at 2:00 AM 7 replies 1.6k views
Original Post
Lithic
Lithic
I was looking at Yann''s screenies saying OMG that is so much better than my progress (www.HaVoKsite.tk). The biggest thing that struck me, however, was his water effects. The rest was just good use of textures and 3D objects. I was wondering if somebody could give some insight on just how he gets that pretty sparkling shimmer, and if it moves in realtime? --===LITHIC===--
Yann L
Yann L
Did I post a screenshot with water ? It must have been an older one then, as the water system is not working currently.

Anyway, water is not that difficult. You basically have two parts: the mesh computation (and possibly bumpmaps), and the rendering. The water surface itself can be computed using a lot of different methods, with varying degree of realism: Spring models, Perlin noise, spectral synthesis (FFT), Navier Stokes solver. You should choose your model depending on the realism you need and the performance drop you are willing to accept. It also depends on the size of the water body.

The rendering itself is pretty much only pixelshader magic. To get realistic water, you need to take three main components into account: the reflection, the refraction and a Fresnel term weighting both. You should compute the first two per-pixel, the Fresnel term can either be per-pixel or per-vertex. For the reflection, don''t simply use an envmap, as so many people do. Treat your water surface like a planar mirror, and render a real geometric reflection into a texture. Then, when rendering the water, you can projectively apply this reflection texture, and perturb the tex coordinates perpixel, according to the reflection vector. Refraction is analogous.

The water deformations should be computed on the water mesh at a coarse level, as well as at a higher frequency on a bumpmap.

To get sparkeling, you need a good perpixel specular model, that also operates on the water bumpmap.

Have a look at the ''Deep water animation and rendering'' paper, here, at the bottom of the page. It provides a good foundation for the techniques discussed, although some aspects of their reflection and refraction model can still be improved.

/ Yann
d000hg
d000hg
I''ve been thinknig about water mechanics recently - the main stuff is simple but what about where there''s land? You can''t just make water heights go up/down as at the shore water is seen to travel forwards and backwards. Plus some dips inland would mysteriously fill/empty with waves! I wondered about making it so when a wave goes up a beach and reaches the top of a hill it falls down the other side somehow. I thought about some kind of connected particle system where particles can give a pushing force to others but can''t be pulled (compressional strength but zero tensional strength). The only thing is over most of the water this just isn''t needed as we just want to model the surface.



Read about my game, project #1
NEW (18th December)2 new screenshots, one from the engine and one from the level editor



John 3:16
greeneggs
greeneggs
quote:
Original post by d000hg
I''ve been thinknig about water mechanics recently


If you want waves, I haven''t seen anything really new since Peachey''s original paper. It has recently been implemented in OpenGL (free source code), but doesn''t look too amazing. http://www.cs.umbc.edu/~bsmith15/799/ If you don''t want waves, just damp.
d000hg
d000hg
It looks OK - more a poor rendering than anything else - but the thing is it''s probably not useful except in shallow water. For deep water the springs/dapming models are probably fine, just looking at the water surface; however in shallow water we need to treat the water as a 3d system. I recall that in deep water waves rarely disturb very far below the surface which could dramatically reduce the performance penalty though.
Ideally I want when I wave comes over a ridge or whatever for it to pool naturally rather than disappearing or returning to the sea magically. I''d also love to see waves hitting rocks & shooting high up. On a related note, water that realistically flows across a landscape following it would be fantastic in realtime - you add a source and a big dam below it down a valley and as the game progresses a lake forms - then you blow up the dam and get some amazing effects! Maybe I''ll work on realistic water one day - that''s the problem with needing to finish your project, you can''t just rush off on anything that looks interesting.



Read about my game, project #1
NEW (18th December)2 new screenshots, one from the engine and one from the level editor



John 3:16
Lithic
Lithic
I took your advise and read that paper... it was interesting, but my code interpretation of it turned out looking like anything but water, although it was an interesting effect. Is there any other articles, code, or pseudocode examples i could take a look at for further clarification as to how the formula works. I did, however in the process develop a great gaussian random function

--===LITHIC===--
--===WWW.HaVoKsite.TK===--
coelurus
coelurus
Have a look at this link:
http://www.unet.univie.ac.at/~a9104678/ChengineOrg/Pages/Diary.htm
He got source code for many water-effects, including the FFT-version.
greeneggs
greeneggs
Is there a good way to render complicated water surfaces? Transparency but no refraction, without raytracing?

Basically, I''d like to be able to duplicate the images in "Practical animation of liquids" - Foster & Fedkiw.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.