Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 


Submitted by Gottfried Chen, posted on March 03, 2002




Image Description, by Gottfried Chen



Here is what I've been doing recently. After some research I've implemented some realtime water algorithms I found to be interesting.

The top row shows two shallow water algorithms. On the left I use an algorithm that was used in an old SGI demo called Newave. On the right I've implemented the old 2D demo water (there is a description of it in "Game Programming Gems 1" and somewhere on gamedev).

The bottom row shows deep ocean water simulation described in Tessendorf's paper http://home1.gte.net/tssndrf/index.html and by Lasse Staff Jensen (http://www.gamasutra.com/gdce/jensen/jensen_01.htm). On the left is the basic statistical water method and on the right with the choppy waves displacement applied. The statistical water is tileable so you can generate bigger patches of water by tiling the geometry.

I've started my research after reading Jensen's paper and seeing screenshots of it, but being unable to find any running demo or source code implementing the deep ocean water, so I had to do it on my own to see it in motion.

A running demo of the water algorithms can be downloaded at www.chengine.com. (The demo also implements another method called "Gerstner Waves" but the results are rather unconvincing, further I've removed the dampening from the 2D water so it runs forever, but oscillates a bit heavily). I haven't put much effort into shading the water, it's just a water texture with an environment map blended on top of it. Further you can download the source code for the water surface simulation. (Just download the GameEngine source code and look into the Terrain library). I didn't post the source code for the demo itself because it is quite a mess and so I don't want it to become public :)



[prev]
Image of the Day Gallery
www.flipcode.com

[next]

 
Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
stoo

March 03, 2002, 04:29 PM

At last, i'll be able to see the deep water stuff in action! I tried looking for stuff on that as well, but I could never find anything. The bottom right pic looks the best, with the one above it looking a bit "spikey", like a bunch of pebbles are going in.

What are you doing for the texture maps in those shots - it looks pretty cool.

cheers,
stoo

 
bigcheese

March 03, 2002, 04:34 PM

It crashes during startup here :( (winxp, tnt2, lots o ram)

It's nice that the water got implemented though.

 
stoo

March 03, 2002, 04:41 PM

Well, i've tried it now.. For all but one of the water types I get a black window, but the deep water one works cool (80fps, GeForce2, 800mhz athlon, 256RAM). I very much like the lighting on the water.

For the ones that don't work, it seems to report the vertices and other bits correctly (i.e. if I pan with the mouse, the vertex count goes down to 0 - pressumably the thing goes offscreen).

Here is the log:

INFO @ 00000s: ------------------------------------------------------------
INFO @ 00000s: Begin logging
INFO @ 00000s: ------------------------------------------------------------
INFO @ 00000s: Loading settings from "Test.set"
INFO @ 00000s: Initializing Direct3D ...
INFO @ 00.16s: Direct3D initialization complete.
INFO @ 00.16s: Default fill mode is solid.
INFO @ 00.16s: Default alpha blend mode is off.
INFO @ 00.16s: Default specular lighting is off.
INFO @ 00.16s: Default texture is none.
INFO @ 00.16s: Default material is white.
INFO @ 00.22s: Initializing DirectInput ...
INFO @ 00.22s: DirectInput initialization complete.
INFO @ 38.45s: Shutting down DirectInput ...
INFO @ 38.45s: DirectInput shut down complete.
INFO @ 38.45s: Shutting down Direct3D ...
INFO @ 38.45s: Direct3D shut down complete.





Nice work,
stoo

 
Flawless

March 03, 2002, 05:01 PM

Niiice!

The last algorithm (the one you see when you push space until it doesn't change any more) is looking great!

Can you give us any details about that algo? :-)

 
Jeff Olson

March 03, 2002, 05:02 PM

Very spiff, I'm going to read up on the papers later.

 
Bunnz

March 03, 2002, 05:08 PM

Cool ;) - Austria rules ;)

Have fun
Bunnz
Visit: www.bunnz.com

 
Leif...

March 03, 2002, 05:11 PM

Works great, very nice. I especially like the last deep water version.

Leif...

 
Dr.Mosh

March 03, 2002, 05:15 PM

Do you have your Direct3D set to debug mode?

 
Morgan

March 03, 2002, 05:48 PM

Your deep water looks as good as the SIGGRAPH paper! Nice job.

-m

 
Hiro Protagonist

March 03, 2002, 06:00 PM

Wow. I really like this one.
I played around with the textures on your demo and was able to make some very nice looking water. The textures in the screenshots you showed had a bit too much contrast INMHO. I didn't see any changes when playing with the heightmap, so I am assuming that you procedurally change the hight map based on something other than the original data. Very cool stuff.

 
dEViNiTY

March 03, 2002, 06:35 PM

looks good
I hope my monitor won't leak

keep it up

 
Eoin

March 03, 2002, 06:40 PM

Crashes on my system too, Win2k - TNT2 - 128mb RAM.

Cheers,
Eoin.

 
Infernal

March 03, 2002, 07:26 PM

crashes at loadup on my machine too.
win2kpro, 32mb-tnt2u, 384mb.

 
Jason Kozak

March 03, 2002, 07:33 PM

Agreed! Great stuff. I like that you can tile the statistical water though, very useful for rendering large sections of water.

Btw, there's a bug in the last method:

 
Merov

March 03, 2002, 07:47 PM

Crashes here also. Win98, TNT, 128 megs RAM

 
Flawless

March 03, 2002, 07:59 PM

Oh that?

Personally, I thought it was a sea monster ;-)

 
richard

March 03, 2002, 08:17 PM

I'm the king of the world!!

Aye, no.. an iceberg?!

I'm seasick... *bweeeurk!*


Uh.. ?

Oops.. oh.. uhm, pardon me.. it's a bit too realistic for me :)

Great work!

This is the first water simulation I've seen that looks REAL instead of fake with those dull sine and/or other thingies.

/me swims back to the titanic..

 
gibber

March 03, 2002, 08:43 PM

Its nice to see a heighmap rendering method used for somthing other than rendering a terrain. I really like the choppy waves, but it seemed quite slow compared to the other modes, even though the framerate was just as high.

As the demo ran succesfully my spec is
512 Mb DDR
Win98 SE
AMD T-Bird 1.4Ghz
ASUS A7M(o/b sound)
Sparkle GF3 (not ti)

 
noxa

March 03, 2002, 09:58 PM

No crash here, it just doesn't display anything. It starts ok, but shows a black screen. Reports ~185fps, with about 6962tris - so it thinks its doing something. The log file reports no errors, and no other d3d app gives me problems (including my own).

System:
-Win2k pre-SP3
-Geforce2Go 32mb
-512mb ram
-DX8.1 final (debug runtime active)

I really wanted to see this working! Oh well, I guess I'll just drool over the screenies for now ;)

BTW, I think you should release the code, assuming that its cleanliness is the only thing holding you back - I, and I'm sure some others, would benifit from this :)

Nice work!

 
Ikuyubon

March 03, 2002, 11:25 PM

WOW!
Awesome!
Especialy the last one!
Good work.

 
Remnant

March 03, 2002, 11:34 PM

Nice work! Like others, nothing but the last mode renders for me (they all show stats and triangles being rendered, but only a blankscreen for the water). I get around 190fps in the last image though, so I'd say it was running just fine.

Athlon XP 1600 w/ a GF2Ti.

 
Ben Hanson

March 04, 2002, 01:07 AM

Switching D3D to Runtime rather then debug fixed the display problem for me (black screen).

Pretty cool stuff, BTW.

 
Dr.Mosh

March 04, 2002, 03:07 AM

switch to retail D3D drivers :)

 
matt benic

March 04, 2002, 04:08 AM

*sigh* another crash victim.. P3, Vanta card (basically a tnt2 I think). Seems to be trying to access a nullpointer.. oh well. Pity, the screens look fantastic!

 
jeti

March 04, 2002, 04:18 AM

The last shot really looks like wind sea.
What's the upper right? Is there a resonator
or what? Sadly the demo crashes. But the shots
look terrific.

 
Phantom

March 04, 2002, 04:39 AM

I didn't study the sources, so this is a lazy question: How 'heavy' is the last algorithm? It looks spectacular and very real, but would it be possible to use it in a game?

 
mc_woods

March 04, 2002, 05:27 AM

Brilliant screenshots, sorry I can't download the demo (I'm at work - and unfortunatly it's not a game dev comp).

And when I do manage to get a phone in at home I will for sure get the demo. There is an interesting artical on Gamasutra about deep water rendering. You might like to take a look : http://www.gamasutra.com/gdce/jensen/jensen_01.htm

 
stoo

March 04, 2002, 05:46 AM

Yes it is. I'll change over to retail and give it a good look.

cheers,
stoo

 
jet

March 04, 2002, 06:08 AM

hi,

thanks for all the good response! now to answer some questions:
- Jason: The spikey thingy that looks like a sea monster is definitely a bug. The reason is simple: when I generate the heightmap and x/z-delta map for the water, then I have to convert it into a mesh for displaying. In this converter I have to set boundaries for the y-min/max values. If I choose them smaller, larger than the real max values, then I get those strange artifacts. So basically I was just to lazy to wait long enough to choose correct values.
- Crashes: I've only tested the demo on GeForce cards with Dx8. I don't do any device enumeration and any checks before using the device. So I guess it's natural that it crashes on a lot of cards (again I was too lazy).
- Performance: The choppy water (last screenshot) needs to do this every frame: Calculate water spectrum for the height map and do two 2D-reverse FFTs to get the water data, then generate a mesh and put the whole thing into a dynamic vertex buffer. If you take time coherency into account then maybe you can speed it up a little more.
- Heightmap: For all wondering what the heightmap.tga is used for: Well it's not used at all. I save the first heightmap frame of the statistical water to disk for debugging (see code snippet velow) and have forgotten to take the code out for the demo :)
- Source: The source for the water simulation and mesh generation are all online and free. Just download the GameEngine source and look into the terrain library. I just don't want to release the demo source, because it is just hacked into my engine test framework, but the loop for the last screenshot looks something like that (below is an old version though):

//------------------------------------------------------------------------------
void TestFramework::loopChoppyWaves()
//------------------------------------------------------------------------------
{
static ChoppyWaves cw(-0.15f, 6, 6, 0.0008f, Vector2(30,10), 100.0f, 100.0f);
static bool first(true);
static Mesh* mesh = 0;
static Vector3* vertices = 0;
unsigned int vertexCount(0);
static DeltaMapConverter dm(cw.getXSize(), cw.getYSize());

static UInt16* indices = 0;
unsigned int indexCount(0);

cw.tick(theGameTime.getAbsolute()/1000.0f);

if (first)
{
mCamera.setPosition(Vector3(0, 180, -240));
mLight->setDirection(Vector3(0, -180, 240));

//------------------------------------------------------------------------------
// Generate mesh
//------------------------------------------------------------------------------

HeightMap hm(cw);
Terrain terrain(hm);

terrain.createMesh(true,
vertexCount, vertices,
0, 0,
indexCount, indices);

//------------------------------------------------------------------------------
// Add to scene
//------------------------------------------------------------------------------
mesh = new Mesh(vertexCount, vertices, 0, 0, 0,
indexCount, indices, Mesh::TRIANGLE_LIST);

Geometry* g = new Geometry(*mesh);

// Need this so that bounding sphere gets calculated
g->updateGeometry();

// Add geometry to tree
Node* root = new Node("Root");
root->addChild(*g);

// Add light
root->addChild(*mLight);

root->updateRenderStates();

// Set root in world
mWorld.setRoot(root);

hm.save("HeightMap.tga");

first = false;
}

HeightMap hm(cw);
Terrain terrain(hm);
terrain.set(Terrain::BOTTOM_TO_TOP);

terrain.setYRange(Interval(-8, 8));
terrain.createMesh(false,
vertexCount, vertices,
0, 0,
indexCount, indices);

dm.modifyMesh(cw.getDeltaMapX(), cw.getDeltaMapZ(), vertices);

mesh->calculateNormals();

if (mesh->cache() != 0)
mesh->cache()->update();

theGameTime.tick();
}

 
jet

March 04, 2002, 06:21 AM

the framerate on the choppy water and statistical water is independent of the animation speed, which can be controlled by a wind speed parameter.

 
This thread contains 37 messages.
First Previous ( To view more messages, select a page: 0 1 ... out of 1) Next Last
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.