Jump to content
  • Advertisement
Sign in to follow this  
meiryousa

OpenGL back face showing through

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

I'm messing around trying to make a water effect. The thing is, it's messing up and I'm not sure how to fix it. I've tried to cull the face wtih glEnable(GL_CULL_FACE) and various glCallFunc, but it didn't work. I have depth testing enabled. Yeah, I'm fairly new to opengl so I'm not sure what is causing this issue:

model.jpg

 

EDIT: I managed to figure out that it has to do with the blending

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

 

trying to figure out how to fix it still.

Edited by meiryousa

Share this post


Link to post
Share on other sites
Advertisement
it's not a state, it's because alpha blending is order dependent.
to fix this you need to have all triangles drawn in a sorted way, in your case, from the furthest away to the nearest.

that might be a bit challenging for a gl beginner, thus a little cheat would be to first draw the mesh with zbuffering enabled, but colorwrite disabled. Then draw the water a 2nd time, this time with color enabled and depth compare set to just set pixels if they match the depth value e.g. GL_EQUAL.

Share this post


Link to post
Share on other sites

if this is only culling problem (becasue sorting is expensive) you messed with glFrontFace( GL_CW , GL_CCW ); and glCullFace( GL_FRONT, GL_BACK etc)  and you may not calculate vertex normals for the water faces

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!