Depth Test
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
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
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
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.
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.
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
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
Also, make sure that you're actually clearing the z-buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
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
But if is scene is static he should not have problems if he forgot it.
Keep us informed if you resolv your problem.
neyna
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement