Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Cat_B

Terrain Flickering

This topic is 5663 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, If you could point me in the right direction, I would appreciate it. As I move around the terrain, the texture flickers (even with the lights off) The only thing I can think of is that its related somehow to the depth testing or the mipmapping (but I also try without mipmapping and it does the same thing)And it flickers no mateer what distance I am from the terrain, but only when it moves. Here are the relevant lines: glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); at each frame I: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); and I load the texture both ways: if (mip==0){ glTexImage2D(GL_TEXTURE_2D, 0, 3, Image->sizeX, Image->sizeY,0, GL_RGB, GL_UNSIGNED_BYTE, Image->data); }else{ gluBuild2DMipmaps(GL_TEXTURE_2D, 3, Image->sizeX, Image->sizeY, GL_RGB, GL_UNSIGNED_BYTE, Image->data); } with glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,FilterTypeNear); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,FilterTypeFar); where I have tried differents parameters eg GL_LINEAR, GL_NEAREST, GL_LINEAR_MIPMAP_LINEAR thanx

Share this post


Link to post
Share on other sites
Advertisement
Pretty much as in the nehe tutorials

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(fovy,(GLfloat)width/(GLfloat)height,znear,zfar);
glMatrixMode(GL_MODELVIEW);


where

float fovy=45.0;
float znear=0.1f;
float zfar=5000.0f; ( large, I know....)

width=640
height=480

Share this post


Link to post
Share on other sites


I changed the zfar to 1000 but it still does it.


I should add (I have just discovered this) that the flickering
is not as bad if I move in the -x direction, but is equally bad if I move in the +x,+z,-z directions.......

Share this post


Link to post
Share on other sites
Haha, thanx for the hint: I set the znear to 1.0f and no more flickering- why it works, I don''t know.

Share this post


Link to post
Share on other sites
here''s an explanation.

basically, you want the zFar/zNear ratio to be as low as reasonably possible. from the link above: "Empirically it has been observed that ratios greater than 1000 have this undesired result."

-steve.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!