Please tell me what state (Enabled/Disabled) should be of the following when I have to implement transparency.
I am rendering the opaqe objects first and then transparent objects. The transparent objects are sorted and split using BSP.
Consider following :
Obj 1 : Alpha-1
Obj 2 : Alpha-2
Obj 3 : Alpha-2
Obj 4 : Alpha-1
Alpha-2 is less (more transparent) than Alpha-1.
While sorting should I sort Obj 1 & 4 together and render, finally sort Obj 2 & 3 and render OR I can collectively sort 1,2,3 & 4 together and render them.
Currently I am sorting & rendering the transparent polygons collectively, but the results are sometimes questionable.
Often I have more than 3,000 transparent polygons which while sorting hang up machine ie out of resources or take lot of time. Which is the fastest algorithm to select the polygon to act as a splitting plane?
Depending on the type of geometry, octrees can be faster than BSP (for indoors BSP works very well, for outdoors octrees are better).
The correct way for rendering transparent objects is :
1/ Render nontransparent objects
2/ Render transparents POLYGONS from back to front
No need to question if a poly is more transparent than another, just see if it is a bit transparent (case 2/) or totally opaque (alpha = 1.0, case 1/). You have to sort them along the Z axis, not depending on their alpha value.
Maybe if your results are “questionable”, this is because you don’t render Polys from back to front, but meshes, and maybe non convex meshes. If you Z-sort meshes you have to be sure that they are all convex, and then you can render this way :
2.1/ cull front faces and render
2.2/ cull back faces and render
Hope this helps a bit
Something Lolo forgot to say: When rendering opaque objects have depth tests and depth writing enabled, when rendering transparent objects leave depth test enabled but disable depth writing by using glDepthMask(GL_FALSE).