Depth Test

Started by
4 comments, last by Neyna 19 years, 7 months ago
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
The ability to succeed is the ability to adapt
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
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.

The ability to succeed is the ability to adapt
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

Also, make sure that you're actually clearing the z-buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
"Voilà! In view, a humble vaudevillian veteran, cast vicariously as both victim and villain by the vicissitudes of Fate. This visage, no mere veneer of vanity, is a vestige of the vox populi, now vacant, vanished. However, this valorous visitation of a bygone vexation stands vivified, and has vowed to vanquish these venal and virulent vermin vanguarding vice and vouchsafing the violently vicious and voracious violation of volition. The only verdict is vengeance; a vendetta held as a votive, not in vain, for the value and veracity of such shall one day vindicate the vigilant and the virtuous. Verily, this vichyssoise of verbiage veers most verbose, so let me simply add that it's my very good honor to meet you and you may call me V.".....V
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

This topic is closed to new replies.

Advertisement