1
\$\begingroup\$

I want to draw in my game some particles. But when I draw one particle above another particle, alpha channel from this above "clear" previous drawed particle. I set in OpenGL blend in this way:

glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );

My fragment shader for particle is very simple:

precision highp float;
precision highp int;
uniform sampler2D u_maps[2];
varying vec2 v_texture;
uniform float opaque;
uniform vec3 colorize;
void main()
{   
    vec4 texColor = texture2D(u_maps[0], v_texture);
    gl_FragColor.rgb = texColor.rgb * colorize.rgb;

    gl_FragColor.a = texColor.a * opaque;
}

I attach screenshot from this: enter image description here

Do you know what I made wrong ?

I use OpenGL ES 2.0.

\$\endgroup\$
3
\$\begingroup\$

I think it has something to do with the z sorting.

Try not writing to the z-buffer when rendering your particles using :

glDepthMask(GL_FALSE);

And don't forget to reset it to GL_TRUE after that.

\$\endgroup\$
  • \$\begingroup\$ thx, it's work ;) \$\endgroup\$ – piotrek Sep 16 '12 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.