views:

1022

answers:

2
+1  A: 

If your particules are already sorted you can render like this :

  • Render particule with GL WRITE DEPTH but no depth testing (I don't remember exactly the constants)
  • Render the rest of the scene with depth test.

This way you are sure to get scene interaction with nice-looking particules.

Raoul Supercopter
Managed to find the answer at the same time. The solution is to use: glDepthMask(GL_FALSE); [render particles] glDepthMask(GL_TRUE);
ICR
Other way around. You want to discard based on depth, but you don't want the blended primitives to affect each other by writing new depth.So the actual depth buffer contents is either only from glClear or the opaque objects.
Mads Elvheim
+2  A: 

Note: Please specify which OpenGL version you use when you post questions. That goes for any API. When you want to render primitives with alpha blending, you can't have depth writes enabled. You need to draw your blended primitives sorted back-to-front. If you have opaque objects in the scene, render them first, and then draw your transparent primitives in a back-to-front sorted fashion with depth test enabled and depth writes disabled.

glEnable(GL_DEPTH_TEST);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_POINT_SPRITE);
glEnable(GL_CULL_FACE);

while(1)
{
    ...
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glDisable(GL_BLEND);
    glDepthMask(1);
    RenderOpaque();
    SortSprites();
    glEnable(GL_BLEND);
    glDepthMask(0);
    DrawSprites();
    ...
}
Mads Elvheim