Hi there!
I have been away from these forums for quite a while but I have a new problem with one of my 3D engines and need some help from experienced users.
My problem is a “classic”: I have implemented transparency in my engine and I can’t seem to get sorting to work properly. In order to keep things simple, I am only working with triangles.
I have read many topics on the subject in these forums but couldn’t find the answer to my question: how should I sort my primitives to get the “correct” result? I have tried the following:
- Calculate centre of triangles in World Space Coordinates, sort according to Z (distance from vertex to view plane).
- Calculate centre of triangles in World Space Coordinates, sort according to X^2+Y^2+Z^2 (square of distance from vertex to viewer).
- Project triangle vertices (Projection Matrix * Modelview Matrix * vertex), sum up Z values of projected vertices, divide by 3, sort according to this value.
- Project triangle vertices (gluProject), sum up Z values of projected vertices, divide by 3, sort according to this value.
I have also tried other methods but they were so dumb that I won’t even mention them.
The problem is that whichever technique I use, I always get artefacts. My “test case” is a box made of 6 faces (12 triangles). Whatever I try, I always find a “viewpoint” (position/orientation) that has some kind of problem.
Is it possible for one of you who has implemented such a thing is one of his own engine to tell me how to do this properly? I have done many searches on the web or here but couldn’t find a definitive answer…
Thanks a lot.
Regards,
Eric
[This message has been edited by Eric (edited 10-08-2003).]