Sign in to follow this  
felipedrl

Alpha sort for trees

Recommended Posts

How do I alpha sort trees? My tree is made of two crossed planes with alpha. For some trees I can see the edge fully transparent when there´s the other tree plane behind it. I assume this happens because the piece of the plane that are in front is rendered first. So how do I sort it? Thanks.

Share this post


Link to post
Share on other sites
I would use alpha testing instead of sorting, and disable blending (in your simple case).

glAlphaFunc(GL_GREATER,0.5);
glEnable(GL_ALPHA_TEST);

and GL_LINEAR filtering for the tree texture.

All fragment's whose alpha value < 0.5, will fail the test, so it wont write to the depth buffer, so you will get perfect visibility (I hope that makes sense)

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