Jump to content
  • Advertisement
Sign in to follow this  
Mr_Ridd

Depth Test

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

Hey I've loaded a model into my scene and it has a normal texture. When I load it I can see through it, so I enabled depth testing and then it disappeared. What can I do to fix this? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Hi,

can you post some code, to see when u set the depth testing and which function you use. (post some pseudo code plz)

I don't understand why your model is transparent and with depth testing it disappears.
Do you set an alpha lesser than 1.0f ?
Do you set GL_BLENDING ?

neyna

Share this post


Link to post
Share on other sites
Ok, my blendFunc is Gl_ONE and GL_ALPHA_ONE, i think, something like that.

No I'm not enabling blending, if I do it changes all my colours. I don't really know why it does that.

Ok, the depth code...

???(1.0)
glEnable(GL_DEPTH_TEST)
glDepthFunc(GL_LEQUAL)

I haven't got my code here but there's also another method I call that I pass 1.0 into it. Not sure what it's called though.

Share this post


Link to post
Share on other sites
the other method is glClearDepth(1.0f); (function specifies the clear value for the depth buffer)

If you dont enable blending, you don't need a blendFunc. And GL_ONE and GL_ALPHA_ONE is not the commune way for doing blending. All depend what king of blending you do ! blending is a way to melt some colors. For exemple, if you have one yellow pixel and one blue pixel one over the other, u can have a green pixel but setting blending.
Transparency is a special use of blending and use the following parameters : (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)

initialization :
glClearDepth(1.0f);
glDepthFunc(GL_LEQUAL);

in ur draw code :
glEnable(GL_DEPTH_TEST);

it seems the good way of doing.

How did you set the perspective?
near and far plane are VERY important for z-buffer (it is in log2, so if near plane is near 0, the z-buffer has big problems with precision)

hope that helps

neyna

Share this post


Link to post
Share on other sites
Oh damm i forgot to mention it ...

But if is scene is static he should not have problems if he forgot it.

Keep us informed if you resolv your problem.

neyna

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!