PDA

View Full Version : Additive Blending in particles



mouser58907
03-25-2010, 02:02 AM
Hi, I'm trying to right a CUDA (and eventually OpenCL) based particle engine. I have the particles working, but I would like to have them blend additively. Here is my current rendering code:



void glDrawParticles (void) {
//GLfloat fSizes[2];
//GLGetFloatfv(GL_ALIASED_POINT_SIZE_RANGE, fSizes);
//if( fSizes[1] > 100.0f )
//fSizes[1] = 100.0f;

glPointSize( 4 );
glPushMatrix();

glEnable(GL_POINT_SPRITE);
glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE);
glEnable (GL_BLEND);
glBlendFunc (GL_ONE, GL_ONE);
glBindTexture(GL_TEXTURE_2D, texture[1]);
glBegin(GL_POINTS);
for( int i = 0; i < ParticleCount; i++ )
{
glColor4f( Particle[i].Red,
Particle[i].Green,
Particle[i].Blue,
0.3f );

glVertex3f( Particle[i].p.x,
Particle[i].p.y,
Particle[i].p.z );
}
glEnd();

glPopMatrix();
}

It currently just draws them all the specified RGB color, (0.1,0.8,0.1). Shouldn't it be turning brighter? Am I doing something wrong?

Thanks.

mouser58907
03-26-2010, 12:32 AM
86 views and 0 responses. Can't anyone give me a pointer?

ZbuffeR
03-26-2010, 02:09 AM
86 views, with 99% being either guest (can't post) or spiders (hopefully can't post).

Come on, how impatient you are. European people are sleeping at night.

Your code seem correct, you can try some sanity checks like rendering on a grey background to check the additive blend works.

Did you disable depth test ? It may get in the way.

mouser58907
03-26-2010, 07:46 AM
Disabling the depth test fixed it. Thank you.