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

 Home / 3D Theory & Graphics / Techniques for reasonably nice water?? Account Manager
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.

March 25, 2005, 11:53 AM


Im busy making a terrain engine using heightmapping(Looks Sw33t! :)) and i was wandering what the best way of acheiving this effect is?
It doesnt have to be fancy...Maybe a Texture mapped square streatched across the length and width of the terrain would be nice!

I would like to see some opinions...And it would be even better if you people could pointed me to some tutorials on the net! :) OpenGL!!!

the NOOB one!


March 25, 2005, 07:57 PM

I used a very simple one involving a double buffer and basic sample filtering. It's like take the average height if the pixels around one pixel, and damp it a little, then swap buffers around.

It was also used in a game I worked on for 3D water surface, we generated height displacement, and corresponding vertex normals, to get refraction and reflection effects. Looks very nice, if a bit 'oiley'.

ha, here it is.


March 26, 2005, 06:17 AM

Simplest water:

Place a quad wherever you want a "pool" of water. The edges of this quad should intersect the terrain (be 'underneath" it). Alpha blend your water texture on it - you'll want this tiled otherwise larger quads will have a nasty pixelated appearance. Render with z-buffering - first the terrain, then the water quad.

  2. ---            ----  terrain
  3.              /
  4.    ------------  water quad
  5.      ______/

Problems: water may have z-fighting at the "shoreline" where the quad intersects the terrain. Water is always flat. Water surface is static and not very interesting.

Advantages: very easy to calculate when something intersects the water plane. Very easy to know water "depth" (just find the terrain under it). Very simple to draw.

If you start with this, as you work with it you will get a handle on how water works in relation to the terrain, and start to build-up other, more complex implementations. Eventually you can move to polygons clipped to the terrain, water "volumes", reflection/refraction/wave effects in shaders, etc.

But the simplest water is just quads laid on the terrain. If you use one big "water plane" in the world then all water is at the same height. Using individual water rectangles (quads) you can have water at different elevations (sea, mountain lakes, etc.).


March 26, 2005, 07:41 AM

I tried something simmilar to that of antiELVIS, streatching the square across the map but the texture didnt appear on the square i streatched across the map???

Could it be the rendering of the heightmap interfearing with the texture mapping??


March 26, 2005, 05:52 PM

Need to see some code to answer that. If you have z-buffering off, and you draw the water first, then the terrain would draw on top of the water quad and cover it up.

This thread contains 5 messages.
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.