Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: jagged coastline problem

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2005
    Location
    Newport News, VA
    Posts
    1

    jagged coastline problem

    I am having issues doing a simple water quad over a terrain square.

    Once I place the Quad into the scene with the height-mapped terrain. I get a jagged coast-line. I am not sure what I am doing wrong here. I think I have correctly enabled blending, because the water is transparent.

    here is a screenshot


    What am i missing here?
    I've placed this code before the water:

    glEnable( GL_BLEND );
    glDepthMask( GL_FALSE );
    glBlendFunc( GL_SRC_ALPHA, GL_ONE );

    glPushMatrix();
    glBegin( GL_QUADS );

    //water
    glColor4f( 0.0f, 0.2f, 0.7f, 0.7f );
    glVertex3f( 0.0f, 20.0f, 0.0f );
    glVertex3f( 0.0f, 20.0f, (float)[terrain iSize] );
    glVertex3f( (float)[terrain iSize], 20.0f, (float)[terrain iSize] );
    glVertex3f( (float)[terrain iSize], 20.0f, 0.0f );


    glEnd();
    glPopMatrix();

    glDepthMask( GL_TRUE );
    glDisable( GL_BLEND );

    I also enable it with glDepthTest, and glDepthFunc

    I am not sure what else to do here to remove the jagged coastline. The resolution shouldn't be too much of an issue, because its 128 x 128.
    GO BENGALS!

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    3,962

    Re: jagged coastline problem

    Your problem is caused by limited zbuffer precision.

    You can fix this by pushing the near clip plane out a little bit and pulling the far clip plane in to some sensible value, (the near clip value will have most influence over the quality). Basically you want to fit everything in the scene or that might be in the scene between the clip planes but also accept a bit of near clipping if something gets really close.

    I'd bet you've set near to something like 0.01 and far way out there in like 100000.0 just to catch everything, it sounds like a good idea but infact it's not for reasons you've now discovered (there are other problems with it too). It's a very common mistake.

Posting Permissions

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