Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Additive Blending in particles

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2010
    Posts
    13

    Additive Blending in particles

    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:

    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.

  2. #2
    Junior Member Newbie
    Join Date
    Feb 2010
    Posts
    13

    Re: Additive Blending in particles

    86 views and 0 responses. Can't anyone give me a pointer?

  3. #3
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,655

    Re: Additive Blending in particles

    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.

  4. #4
    Junior Member Newbie
    Join Date
    Feb 2010
    Posts
    13

    Re: Additive Blending in particles

    Disabling the depth test fixed it. Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •