开发者

Rendering particles as GL_TRIANGLE_FANs with transparency in OpenGL

I want to render particles with hexagons that fade out to the outside. I've used a TRIANGLE_FAN for each particle.开发者_高级运维 However, the transparency doesn't look very nice.

glBegin(GL_TRIANGLE_FAN);
    glColor4f(c.x, c.y, c.z, particle.temperature / 100.0);
    glVertex3f(0, 0, 0);
    glColor4f(0, 0, 0, 0);
    glVertex3f(0.866025404 * H / 2, 0.5 * H / 2, 0);
    glVertex3f(0, 1 * H / 2, 0);
    // other vertices omitted
glEnd();

I get an output which is flickering and where the black transparent parts are drawn over opaque objects at some frames. How do I have to change my rendering routine to avoid this bugs?

Rendering particles as GL_TRIANGLE_FANs with transparency in OpenGL


What you're observing is particles behind others that do not get drawn because a closer Z-value is present in the Z-buffer.

  1. You can draw your particles back to front.

  2. You could also disable depth-testing, but standard alpha blending will not be correct. with the ALPHA/ONE mode, you'll get to accumulate all particles, so that order will not be important either.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜