Simulating water

Started by
5 comments, last by Atrix256 14 years, 8 months ago
I do not need a very good one now , just one thats working. can you help me? What I have so far is a basic 3d grid, sort of like a heightfield grid with height being 0. I want to try to create a water ripple. [Edited by - tnutty on July 22, 2009 9:46:47 PM]
Our whole life is a opengl application.
Advertisement
Draw a texture that has some repeating ripples and bind it to a quad. Adjust the UV coordinates over time to make the ripples move. Then set slight transparency so that the ground can be seen through the water and voila, you got some tacky water.

How would you create a water on a terrian.
Our whole life is a opengl application.
Quote:Original post by tnutty
How would you create a water on a terrian.


This is something I made a while ago: http://kindjie.googlepages.com/home#fishtale

The formulas to displace the points are on the page, along with a link to the original paper and some (slow) C++ code. Check the video first to see if it's what you're looking for.

Good luck!

[size="1"]Try GardenMind by Inspirado Games !
All feedback welcome.
[s]
[/s]

[size="1"]Twitter: [twitter]Owen_Inspirado[/twitter]
Facebook: Owen Wiggins

[size="1"]Google+: Owen Wiggins

To make water anywhere you just draw geometry over the terrain. You could imagine a heightmap and a plane that intersects it. Put a blue texture on the plane and you've got water on terrain. Obviously you'll want to use fancy textures and rendering techniques to make the water look more interesting. But really it's just planar geometry intersecting the world geometry.

If you have a modeling program such as 3d studio it's very easy to experiment with.

Also the plane doesnt extend for ever, but only extends far enough to intersect the terrain geometry. Then it can stop. You do this so that you can have lakes up in the mountains and stuff and not have a gigantic water plane extending out to the horizon, out of your mountains.
How about simulating a ripple on a pond starting from the center of the
flat 3d grid.
Our whole life is a opengl application.
this isnt a complete solution but should hopefully get you started:

to start your ripple, set a DISTANCE variable to 0.

every tick of your function do the following:

1) loop through all vertices in your water grid, calculate their 2d distance from the center of the pond (ie ignore height!). Set the height of each vertex to be:

HEIGHT = sin(DISTANCE/WAVE_WIDTH)*WAVE_HEIGHT;

2) make distance larger each tick:

DISTANCE += WAVE_SPEED;

that will make a bunch of ripples that emanate from the center of the pond and go outwards.

Like i said it's not a complete solution but it should be a good start!

This topic is closed to new replies.

Advertisement