Results 1 to 7 of 7

Thread: Terrain edges keep shaking / vibrating....

  1. #1
    Member Newbie
    Join Date
    Jul 2004
    Location
    Bangalore
    Posts
    37

    Terrain edges keep shaking / vibrating....

    Please help me to resolve the following problem:

    I have created a terrain using Triangle Strips and it is being rendered properly.

    But when I add water ( QUAD with BLENDING enabled - ranging from one end of terrain to the other end, lies somewhere in the middle of the terrain in Y-direction ), the edges where water ( QUAD ) intersect the terrain starts shaking(i.e vibrating).

    What could be the problem ?

    By the way, this is what happens in the Render() function :

    Render()
    {
    ...
    ...
    // Draw Terrain
    glPushMatrix();
    glScalef(10.0f, 2.0f, 10.0f);
    Draw_Terrain_UsingTStrips();
    glPopMatrix();

    // Draw Translucent Quad for Water
    glPushMatrix();
    glEnable(GL_BLEND);
    glDepthMask(GL_FALSE);

    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    glColor4f(1.0f, 1.0f, 1.0f, 0.3f);

    glBindTexture(GL_TEXTURE_2D, WATER_TEXTURE);
    glScalef(15.0f, 1.0f, 15.0f);
    glBegin(GL_QUADS);
    T,V Pair for all the 4 Corners
    glEnd();

    glDepthMask(GL_TRUE);
    glDisable(GL_BLEND);
    glPopMatrix();
    ...
    ...
    }

    Please note: I have scaled terrain & the QUAD for water(differently).
    - I have used gluPerspective(45.0f, w/h, 0.1f, 20000);

    - I also have the latest driver for my RivaTNT2 M64 (v 71.89 WHQL Certified)

    Any suggestions ?

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,662

    Re: Terrain edges keep shaking / vibrating....

    I don't see any bad things at first glance. I just can say that if you want to do transparencies then this function should be best than the one you stippled:

    BlendFunc(SRC_ALPHA, ONE_MINUS_SRC_ALPHA);

    But that will surely not resolve your shaking problem.

  3. #3
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: Terrain edges keep shaking / vibrating....

    >> gluPerspective(45.0f, w/h, 0.1f, 20000);
    I suspect z-fighting caused by insufficient depth buffer precision.
    Does the shaking looks like this ? Then try with distance values that are nearer to each other, like :
    gluPerspective(45.0f, w/h, 2.0f, 10000.0f);

    If this reduce the shaking, that's it.

    Some background on the topic :
    http://www.opengl.org/resources/faq/...epthbuffer.htm
    http://www.sjbaker.org/steve/omniv/l..._z_buffer.html
    http://www.opengl.org/resources/tuto...es/node28.html

  4. #4
    Member Newbie
    Join Date
    Jul 2004
    Location
    Bangalore
    Posts
    37

    Re: Terrain edges keep shaking / vibrating....

    Originally posted by jide:
    I don't see any bad things at first glance. I just can say that if you want to do transparencies then this function should be best than the one you stippled:

    BlendFunc(SRC_ALPHA, ONE_MINUS_SRC_ALPHA);

    But that will surely not resolve your shaking problem.
    Hi JIDE !

    Thanks a lot.

    Water looks a lot better now...( i.e more realistic. )

  5. #5
    Member Newbie
    Join Date
    Jul 2004
    Location
    Bangalore
    Posts
    37

    Re: Terrain edges keep shaking / vibrating....

    Originally posted by ZbuffeR:
    >> gluPerspective(45.0f, w/h, 0.1f, 20000);
    I suspect z-fighting caused by insufficient depth buffer precision.
    Does the shaking looks like this ? Then try with distance values that are nearer to each other, like :
    gluPerspective(45.0f, w/h, 2.0f, 10000.0f);

    If this reduce the shaking, that's it.

    Some background on the topic :
    http://www.opengl.org/resources/faq/...epthbuffer.htm
    http://www.sjbaker.org/steve/omniv/l..._z_buffer.html
    http://www.opengl.org/resources/tuto...es/node28.html
    Hi ZbuffeR !

    Thanks ! I set near to 2.0f and far to 20,000.0f... and now there are no visible vibrations / shaky stuff when I add water.

    How come it got resolved when near = 2.0f ?

    Is it because of the huge viewing volume when near = 0.1f ( and consequently more rendering to be done for 0.1 than 2.0 ) ?

  6. #6
    Senior Member Regular Contributor
    Join Date
    Jan 2004
    Posts
    314

    Re: Terrain edges keep shaking / vibrating....

    Look at the "love your z buffer" link.

    Basically it boils down to the formula used to encode both tiny distances (0.1) and large distances (20000) into one 16 or 24 bit integer.

    It's non-linear, giving more precision near the camera where you normally want it, and less precision far away.

    But Steve Baker (in that link) probably explains it better.

  7. #7
    Senior Member OpenGL Pro
    Join Date
    Jul 2001
    Location
    France
    Posts
    1,662

    Re: Terrain edges keep shaking / vibrating....

    Originally posted by OGL_PGR:
    Hi JIDE !

    Thanks a lot.

    Water looks a lot better now...( i.e more realistic. )
    No problems

Similar Threads

  1. glOrtho() and camera shaking magnitude
    By saucermancer in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-26-2011, 01:18 PM
  2. Fading out the edges of my terrain
    By Dan M in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 08-14-2010, 09:28 PM
  3. object shaking
    By pongkm in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 07-21-2002, 10:15 PM
  4. annoying vibrating lines!
    By robert_s in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 11-14-2001, 12:14 PM
  5. Shaking the screen
    By TheGecko in forum OpenGL: Advanced Coding
    Replies: 8
    Last Post: 03-13-2001, 10:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean