• Advertisement

Archived

This topic is now archived and is closed to further replies.

Sorting Polys for Blending

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

How do I sort polygons so it will blend perfectly. Is it...like :: Draw all non-blending polys on screen Enable Depth Testing Draw all blending polys on screen from farthest to nearest ? is it true ? How do I sort the polys (from diffrent camera position) ? Thanks in advance

Share this post


Link to post
Share on other sites
Advertisement
Yeah, that should work.

Sort the polys by their z depth in camera space. You''ll likely need to use some variant of a billboarding technique or transform the polys yourself.

Depending on what the polys are, you may be able to skip it, tho. I have had no problem with blending in the wrong order unless I really look hard. But then, I''m just blending smoke and fire, so they''re generally not very order dependent.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
No, it won''t work. Do it like that:

Enable Depth Testing
Enable depth writes
Draw all non-blending polys on screen
Disable depth writes
Draw all blending polys on screen from farthest to nearest
- AH

Share this post


Link to post
Share on other sites
How do I sort polys from farthest to nearest ? Should I get the Projection and Modelview Matrix, multiply it and get the transformed coordinates for every vertics. And calculate the distance of each vertex to the camera position ?

I''m rather dumb about this thing, can someone tell me how to do this. Because polygons are 3 dimensional objects and one vertex could be the farthest vertex and the other could be the nearest vertex ? Should I make an average distance of every triangle (from its Vertics) to the camera ?

Oh well.. any good link for a nice tutorial ?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
There are several different methods, you could just take the average of the 3 vertices. Or the nearest one to the camera. Or the farthest. It won''t make much difference, if your faces are small. Just be sure to be consistent (eg. don''t just take the first vertex of a face, you''ll get unconsistent ordering and things will flicker).

- AH

Share this post


Link to post
Share on other sites

  • Advertisement