3
\$\begingroup\$

I needed to implement particles for my 2D game, written in C++ with OpenGL for graphics, so I went ahead and created a nice geometry container to batch particles together and then implemented the basic stuff on them. So far so good, my particles work fine as intended, with a decent performance.

However, even tho my particles appear, animate and die the way they are supposed to, I am experiencing banding in the particles. All particles are drawn in a single draw call with additive blending. When I render a single particle I don't seem to get any noticeable banding, but the more particles I stack on top of each other, the more clear the banding becomes, giving unacceptable results.

You can see here some particles painted with my mouse as a brush, they look decently but we notice the problem In here, I just stack a lot of particles together so you can see the problem more clearly

Particle texture

I am doing nothing fancy with the rendering, it should work but here 's some more info. Blend mode: glBlendFunc(GL_SRC_ALPHA, GL_ONE); (for particle textures with varying alpha) Context: 32 bit color depth and nothing seems to be banding anywhere else, there isn't anything using low-precision Fragment shader output: gl_FragColor = texture2D(texture, texUV) * outColor;

Also, I developed this system inspired in HGE particle editor. I am using the same particle texture that this program uses successfully, with no visible banding at all, but it doesn't work for me for some reason. Link: http://hge.relishgames.com/

Thanks

\$\endgroup\$
8
  • \$\begingroup\$ It might be better to include the particle texture in your question rather than linking to a game engine. \$\endgroup\$
    – Mokosha
    Commented Dec 3, 2013 at 23:13
  • \$\begingroup\$ done.. might be hard to see it in a white background tho. :) \$\endgroup\$
    – Grimshaw
    Commented Dec 3, 2013 at 23:27
  • \$\begingroup\$ Oh, the single particle is being rendered in the engine. Can you post the source image for the particle? That might help make it more clear. \$\endgroup\$ Commented Dec 4, 2013 at 3:54
  • \$\begingroup\$ What is the alpha of an individual particle in these images? In the second image you posted, I assume that is several (many?) particles being rendered on top of each other, each with a fairly low alpha? Also, are you using alpha-test, and if so what is the threshold set to? \$\endgroup\$ Commented Dec 4, 2013 at 7:19
  • \$\begingroup\$ the third image in my question is an atlas with a few textures for different particles, I am using the top-left one for the above two screenshots, which show them stacked with additive blending in a ingame demonstration. In each of the particles the color is always white, and the alpha varies from 0 to 255 depending on how opaque the texel is. I experience banding even if the sum of all stacked particles is not above(1.0,1.0,1.0,1.0). I am not using alpha test, its completely disabled. Any tips are appreciated :) \$\endgroup\$
    – Grimshaw
    Commented Dec 4, 2013 at 19:00

1 Answer 1

1
\$\begingroup\$

As a variant. Render particles in translucent off-screen buffer in normal mode. Then render this buffer to screen in additive mode.

Example, fabricated in Gimp.

If you want better result. Render particles in normal mode, but self-illuminated, i.e. they must not be affected by lighting (if you using lighting at all). Ideally they must also emit some light.

\$\endgroup\$
3
  • \$\begingroup\$ This actually seems to make sense, I will try that next, do I need some kind of special renderable texture or a regular RGBA8888 will do? Thanks \$\endgroup\$
    – Grimshaw
    Commented Dec 5, 2013 at 0:47
  • \$\begingroup\$ @Grimshaw I can't think of anything special, just regular texture. Moreover, if particles are opaque, then there is no need for alpha channel in offscreen buffer. Also if you planning to render multiple batches of particles, I'd recommend to create one offscreen buffer same size as viewport, and then clear and reuse it for every next batch. \$\endgroup\$ Commented Dec 5, 2013 at 5:40
  • \$\begingroup\$ So, basically draw my batch of additive particles in an offscreen buffer then sum that one up to the screen in the end. I will try it later, hoping it gives better results ^^ It's not like its horrible looking as it is now, as long as I don't stack too many particles.. \$\endgroup\$
    – Grimshaw
    Commented Dec 5, 2013 at 5:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .