particle engine texture

Started by
3 comments, last by Optus 17 years, 11 months ago
What is the best way to draw particles: - the particles are tga textures with an alpha channel. - particles are bmp textures and blending is used with glBlendFunc(GL_SRC_ALPHA,GL_ONE); - " " " some other blending function. Also, do any of those methods need sorting? Finally, I'm just about to start implementing a particle engine that does explosions for my RTS game (exploding tanks and buildings), does any one have any advice or tips? Thanks.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
Advertisement
Just try them out all and see what works best. Textures with alpha will be the way to go.

glBlendFunct reference
if your particle need to use many colors, you will need an alpha channel.
if your particle need only one color, you don't need an alpha channel and you can change the particle color using vertex colors

use GL_SRC_ALPHA, GL_ONE to do additive blending
here, you don't need to sort your particles.
use GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA to do "normal" blending
here, you will need to sort them.

for explosions, I have an emitter to do additive particles for "fire balls" an emitter to do additive particles for "sparks", an emitter to do "normal" blending for smoke and one more ("normal" too) for debris.
First of all - is there any way to use tga images with alpha channels without sorting them?

Second:
I'm using bmp images with glBlendFunc(GL_SRC_ALPHA,GL_ONE);
with glDisable(GL_DEPTH_TEST); it looks like this:
Photobucket - Video and Image Hosting

but if depthtesting is enabled it looks like this:
Photobucket - Video and Image Hosting

Is there any way to have the depthtesting enabled without sorting or will I have to sort?

Thanks.
"We've all heard that a million monkeys banging on a million typewriters will eventually reproduce the entire works of Shakespeare. Now, thanks to the internet, we know this is not true." -- Professor Robert Silensky
Sure, you just leave the depth test enabled. But, while drawing the particles disable depth writing.
glDepthMask(GL_FALSE); // disable depth writerenderParticles();glDepthMask(GL_TRUE); // reenable depth write

This topic is closed to new replies.

Advertisement