Jump to content
  • Advertisement
Sign in to follow this  
kordova

OpenGL Terrain/skybox fighting for draw

This topic is 4381 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

When I use a skybox or a far plane that overlaps rendered terrain, I get this: I believe it to be z-fighting, but have a depth size of 24 (which improved some issues from 16 earlier). What is the best method to correct this problem? Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
Easiest way would be to render the skybox first with depth writes disabled.

eg.

glDepthMask(FALSE);  // Sky wont write to the depth buffer
RenderSkyBox();
glDepthMask(TRUE); // Terrain will write to the depth buffer
RenderTerrain();
Hope that helps

Share this post


Link to post
Share on other sites
Hmmm, I had tried that after the terrain render but this does not seem to fix it either.

I have also noticed now that the sky pops up in small spots occasionally nearer than the border as well.

Share this post


Link to post
Share on other sites
Well the only other thing I can suggest would be to push the near plane back and bring the far plane forward.

What are your current z-near and z-far values?

Share this post


Link to post
Share on other sites
Quote:
Original post by nts
Well the only other thing I can suggest would be to push the near plane back and bring the far plane forward.

What are your current z-near and z-far values?

Near: 50.0f
Far: 50000.0f-100000.0f (I want to render as far as possible for a large, open terrain with subtle hills)

This is a farther far plane than the one used in the above picture but I have the same issue along the seams of my terrain patches and with occasional spots randomly especially on the crests and troughs of the hills.

Quote:
Original post by zedzeek
draw the skybox last with
glDepthRange( 1.0, 1.0 ) // if possible if not 0.99999, 1.0

Rendering the skybox after the terrain makes it significantly more obvious (as in, hilltops nowhere near the far plane/sky box will pop out), and setting the depth range does not seem to have any dramatic affect.

Cheers.

[Edited by - kordova on July 19, 2006 11:53:06 PM]

Share this post


Link to post
Share on other sites
Quote:
Original post by kordova
Rendering the skybox after the terrain makes it significantly more obvious (as in, hilltops nowhere near the far plane/sky box will pop out), and setting the depth range does not seem to have any dramatic affect.

aye?

Share this post


Link to post
Share on other sites
1; Disable depthwriting

2; Draw sky (using only rotations, no movements etc.) centered at the camera

3; Enable depthwriting

4; Render world


This way the sky can be small as an apple, but still cover the "entire world".

Share this post


Link to post
Share on other sites
Ok, this must be an issue with Xcode not actually incorporating my changes when I rebuild. I ran it this morning, changing the far buffer to be even farther away (4x) and it works fine whether depth writing is disabled or not during the skybox render. Either way, I will leave it disabled just in case this pops up later.

Thanks for your help, each of you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!