Archived

This topic is now archived and is closed to further replies.

Tokage

Ripples and Stuff

Recommended Posts

Tokage    174
I'm relatively new to graphics and game programming. I'm trying to make a simple demo thingy with water ripples, and I have something that sort of works, but the ripples are very square and small. I was wondering if anyone knew of a good tutorial for creating realistic-looking ripples in water in 3D. I'm using C++ and OpenGL. [edited by - Tokage on March 16, 2003 12:55:57 PM]

Share this post


Link to post
Share on other sites
Raduprv    997
If you are new at graphic, and game programming, I suggest you to start with something more simple. I am not that new at it, and I still didn''t find a good way to add some nice waves, in my water I added some 2d waves (some random noise in the water), but, while it looks OK/decent for lake water, it looks bad for sea water...
There is an aerticle on gamasutra about waves, and water effects in general, but it is full of math, and I didn''t understand much out of it...

Height Map Editor | Eternal Lands | Fast User Directory

Share this post


Link to post
Share on other sites
Tokage    174
Thanks for the info. I consider myself very competent when it comes to pure math, so I probably wouldn''t have much trouble with that aspect of it. I''m not looking for anything complicated. Is there some book anyone would recommend for this kind of thing?

Share this post


Link to post
Share on other sites
jdi    127
http://freespace.virgin.net/hugo.elias/graphics/x_water.htm

Can easily be extended to 3D, and looks pretty good for very little work.

j

Share this post


Link to post
Share on other sites
greeneggs    130
Take a look at "A convolution-based algorithm for animated water waves" - Loviscach (Eurographics 2002). It does ripples very nicely. If you are interested in actual waves, then there are a number of papers, but the Gamasutra article is a good place to start.

Share this post


Link to post
Share on other sites
Tokage    174
quote:
Original post by jdi
http://freespace.virgin.net/hugo.elias/graphics/x_water.htm

Can easily be extended to 3D, and looks pretty good for very little work.

j


I can''t get it to work. Maybe I''m doing something wrong...

Share this post


Link to post
Share on other sites
Hairybudda    116
quote:
Original post by jdi
http://freespace.virgin.net/hugo.elias/graphics/x_water.htm

Can easily be extended to 3D, and looks pretty good for very little work.

j


Its simply a perchance mathematical glitch. There are better ways for 3d.

Share this post


Link to post
Share on other sites
jdi    127
Of course there are better ways of doing it. But I wouldn''t call it a "Perchance mathematical glitch." Mathematics doesn''t have glitches.

The main selling point of this really is that it''s incredibly easy - you can code up an implementation in a matter of minutes. Considering the original poster is trying to make a "simple demo thingy with water ripples," I thought it was a good match for what he wanted. No need to go for a full featured Navier-Stokes solver if this will do the job.

j

Share this post


Link to post
Share on other sites
Yann L    1802
Although a full NSE solution is going to look much better, and is not so hard to implement either. Have a look in the water section of the FAQ, there are a couple of papers about NSE solvers and other water algorithms.

Share this post


Link to post
Share on other sites
Tokage    174
Hi, I''m the original poster.

I''m mainly just using this for fun. I heard along the grapevine that there''s a way to simulate ripples using sums of sine functions. Is that hard too?

What FAQ are you referring to? Is it on GameDev?

Thank you all for being so helpful. This is why I love these forums.

Share this post


Link to post
Share on other sites
Yann L    1802
quote:

I''m mainly just using this for fun. I heard along the grapevine that there''s a way to simulate ripples using sums of sine functions. Is that hard too?


No, not really. But it ultimately depends on how realistic you want your water animation to be. Perhaps you should have a look into Fourier synthesis, the results are quite nice, esp. on large water bodies such as lakes.

quote:

What FAQ are you referring to? Is it on GameDev?


The FAQ of this forum: click.

Share this post


Link to post
Share on other sites
greeneggs    130
quote:
Original post by jdi
Of course there are better ways of doing it. But I wouldn''t call it a "Perchance mathematical glitch." Mathematics doesn''t have glitches.


However the mathematics is not presented on that web page. This is why I recommended the convolution paper, which properly presents the mathematics, and lets the implementer choose how expensive a filter to use.

If you (the original poster) are having bugs implementing the algorithm, are you writing into the same array you are reading from? That''s the simplest bug I can think of. I do recommend reading the paper -- I think it is better than solving the Navier Stokes equations when you just want ripples.

Share this post


Link to post
Share on other sites
Yann L    1802
greeneggs, do you have a link to that convolution paper ? I can't seem to find a free download.

Although the convolution approach is easier to code and offers better performance than the NSE, it is pretty unstable in my experience. Unless you apply a really large damping factor, but that makes the waves fade out to quickly. If you want nice long lasting waves, with interference and all, the convolution dataset tends to degenerate into wild high frequency oscillations, and it's pretty much impossible to recover (other than zeroing out the whole heightfield). It also creates those unrealistic high frequency noise around circular wavefronts.

Or does the paper you mentioned provide a solution to those problems ? I guess using a wider filter kernel will probably solve the noise problem, it will also reduce performance.


[edited by - Yann L on March 19, 2003 1:56:59 PM]

Share this post


Link to post
Share on other sites
JohnBolton    1372
The code at

http://freespace.virgin.net/hugo.elias/graphics/x_water.htm

is based on a spring model and works really well for generic water waves.

Here is a site with lots of water stuff:

http://www.vterrain.org/Water/

Share this post


Link to post
Share on other sites
blue_knight    194
Just wanted to mention that the code mentioned here: http://freespace.virgin.net/hugo.elias/graphics/x_water.htm isn''t a "mathmatical glitch" but rather is a simplified version of a discrete forward differencing approximation of a mass/spring system. The book "Game Programming Gems 2" has an article on it, but it takes into account grid size, wave speed and delta time (instead of being frame based). If you look at their final equations however, with the right constants you get EXACTLY the same equation used in the x_water article.
I''ve used this system for surface waves but I''ve run into problems (especially with low resolution simulations, say 64x64) with ripples being oddly shaped and have run into stability issues as well. For these reasons I will probably switch to a 2D NSE solver and the results should be much better.

Share this post


Link to post
Share on other sites
Tokage    174
Thank you all very much for all this information. Would anyone recommend the "Game Programming Gems" series for someone realtively (but not totally) new to game programming? If so, which one(s)?

Share this post


Link to post
Share on other sites
Chapel    122
quote:
Original post by Tokage
Thank you all very much for all this information. Would anyone recommend the "Game Programming Gems" series for someone realtively (but not totally) new to game programming? If so, which one(s)?


Get all three =). If you order directly from the publisher you can get all 3 for the price of 2. Be aware that they're not exclusively focused on graphics though(a strength if you ask me). Great books!

edit:
To answer your question, the first book probably has the most newbe-ish to game programming stuff.

Chapel

[edited by - Chapel on March 19, 2003 10:10:22 PM]

Share this post


Link to post
Share on other sites