Sorting Polys for Blending

Started by
3 comments, last by Ak37 22 years, 5 months ago
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
Help me with my Isometric OpenGL engine.
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.
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
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 ?
Help me with my Isometric OpenGL engine.
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

This topic is closed to new replies.

Advertisement