Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Water in a terrain engine

  1. #1
    Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    428

    Water in a terrain engine

    I have a terrian engine set up, and i want to add water. I triwed to do this by simply having a semi transparent quad textured drawn at a certain height... This isnt bad except for the fact that there is REALLY bad jittering effect when the water meets the terrain. The waters edge jitters very badly there. does anyone know how to fix this.
    :: Sleep is a poor substitute for caffeine ::

  2. #2
    Junior Member Regular Contributor
    Join Date
    Apr 2001
    Posts
    133

    Re: Water in a terrain engine

    a) increase the depth of your depth buffer if you can.

    b) draw the water slightly higher, so it is further from terrain polygons that are roughly parallel to it.

    c) increase the angle of the terrain polygons at the waters edge, so they are more perpendicular to the water (this goes with b)

    d) use glPolygonOffset when you draw the water, might work...

  3. #3
    Intern Contributor
    Join Date
    Sep 2001
    Location
    paris, france
    Posts
    84

    Re: Water in a terrain engine

    for point a) :
    Isn't it rather decreasing the depth of zbuffer that would give a more precise zbuffer on the range covered ? Or did I missed something ? For me, the lesser zmax-zmin, the better the precision. Am I wrong ?

  4. #4
    Junior Member Regular Contributor
    Join Date
    Oct 2001
    Location
    Holland
    Posts
    184

    Re: Water in a terrain engine

    Originally posted by rixed:
    for point a) :
    Isn't it rather decreasing the depth of zbuffer that would give a more precise zbuffer on the range covered ? Or did I missed something ? For me, the lesser zmax-zmin, the better the precision. Am I wrong ?
    Correct, but 'increasing the depth' means increasing the number of available bits (via a different pixelformat) in this case I think.
    And yes, mapping a smaller range of depth values to the available depth bits will also improve accuracy.

    BTW: the difference between zmax and zmin is not the only important factor, it is also the ratio between zmax and zmin:
    zmin = 100, zmax = 199 is creates better accuracy than zmin = 1, zmax = 100 even if the difference is 99 in both cases.

    HTH

    Jean-Marc

  5. #5
    Intern Contributor
    Join Date
    Sep 2001
    Location
    paris, france
    Posts
    84

    Re: Water in a terrain engine

    OK!

    I usually set zmin=1, so I will fix it since its not relevant in many case if its 1 or 10 or even 100.

    I didn't know about this ratio thing. I will watch at the z calculations in the gl specs to understand why.

    thanks

  6. #6
    Intern Newbie
    Join Date
    Mar 2001
    Posts
    31

    Re: Water in a terrain engine

    I've got the same problem and am using the same method as you are until I get a textured wavy surface going. When I zoomed my camera in and scaled my view down to keep everything the same size it helped enormously.

    Try that and see what you think. Set your eyepoint closer to the scene, and render the scene smaller to keep it to scale. Instead of "zooming in" you're just increasing the resolution so to speak.

    I think.

    Care,
    Chris

  7. #7
    Junior Member Regular Contributor
    Join Date
    Apr 2001
    Posts
    133

    Re: Water in a terrain engine

    just to clarify, yes, i did mean increase the bit depth of the depth buffer...

  8. #8
    Member Regular Contributor
    Join Date
    Nov 2000
    Location
    Sydney, NSW, Australia
    Posts
    428

    Re: Water in a terrain engine

    Thanks all, but i figured it out, there is a much simpler way of fixing this, just use multiple quads in a grid. Having just one huge quad covering the entire map was the thing stuffing it up... So now i have a bunch of smaller quads...
    :: Sleep is a poor substitute for caffeine ::

  9. #9
    Intern Newbie
    Join Date
    Dec 2001
    Location
    Bucharest, Romania
    Posts
    34

    Re: Water in a terrain engine

    the Z-Buffer artifacts can be avoided in two ways:
    1) By increasing the zbuffer bit depth
    2) by setting the near plane a value bigger than 1, preferably set it 5 or 10 depending on how close do you want to look at the terrain
    if the value is too big , you'll encounter some unwanted nearplane clipping...

    good luck.

  10. #10
    Intern Newbie
    Join Date
    Jun 2001
    Posts
    46

    Re: Water in a terrain engine

    Mr. Shoe, more quads means a slower engine. You can fix your problem by using only a single quad and decreasing the ratio between the near and far clipping planes. For example:

    gluPerspective(fov,ratio,1.0f,100.0f);

    will give much better results than:

    gluPerspective(fov,ratio,0.1f,1000.0f);

    Try it

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •