Sign in to follow this  

secret alpha sorting

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

hi, I am trying to figure out the best way to implement alpha sorting for my 3d game. All my objects that need to display graphic code (openGL) implement an interface (IDrawable) this interface contain virtual methods like drawPlain(), draw2DTex(). I make a list of all the objects that implement this interface and pass throught it to render my screen. That's fine to display non transparent objects. But now for transparent objects I use the same technique, I sort objects with their distance of the camera, and render these objects. The result is not so good, specialy if one object render many transparent polygons with different depth. How do you do for your game? is there a big secret I dont know? are all polygons sorted? thanks

Share this post


Link to post
Share on other sites
If your object is convex thenyou can skip sorting and render it twice, with different triangle winding orders. If it's not then you almost have to sort triangles by distance if you need absolutly correct image. There are a couple of more hacks you could use to speed things up, but they all target specific problems/cases. You also have to remember that not all modes need sorting.

Share this post


Link to post
Share on other sites
Quote:
Original post by _DarkWIng_
If your object is convex thenyou can skip sorting and render it twice, with different triangle winding orders


Could you explain it somehow, or give me a link/clue about how or why this works ?

Share this post


Link to post
Share on other sites
What he says is basicly this.
If you have a cube(but only one) you could cheat by first drawing all the backfacing polygons then all the frontfacing ones, this is because in a convex object no polygons facing the same way can ever overlap no matter witch way you look at it (allso if you draw a line from any vertex to any other vertex, it will never intersect one of the polygons or be drawn outside the object).
IF it did it's not a convex object.
This only works if you only have one object, if you have two of them then things will be different, then the method will only work if they are not intersecting each other in any way.

now in the case for most games convex objects are rare, so you have to sort the transparent polygons and then render them after you render the opaque ones.
Alpha testing could allso be used to cheat a little if the only thing you want to do is to cut a small hole in the texture.

Share this post


Link to post
Share on other sites

This topic is 4794 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.

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