Sign in to follow this  
Mr_Ridd

Depth Test

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this