Point Sprite Fade

Hello,

Context: OpenGL/ES on iphone

I’m trying to fade out point sprite particles based on time. I have the point sprites appearing, but they are not fading out. It was my understanding that changing the alpha value of the color (based on time) would fade the particle out. This doesn’t seem to be working. Suggestions? My code that draws the particles is as follows:


glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
glDepthMask(GL_FALSE);
		
glMatrixMode(GL_TEXTURE);
glPushMatrix();
{
	glBindTexture(GL_TEXTURE_2D, textures[0]);
	glEnable(GL_POINT_SPRITE_OES);
	glEnableClientState(GL_VERTEX_ARRAY);
	glVertexPointer(3, GL_FLOAT, 0, particles);			

	glEnableClientState(GL_POINT_SIZE_ARRAY_OES);
	glPointSizePointerOES(GL_FLOAT, 0, sizes);
			
	glTexEnvf(GL_POINT_SPRITE_OES, GL_COORD_REPLACE_OES, GL_TRUE);

	glEnableClientState(GL_COLOR_ARRAY);
	glColorPointer(4, GL_FLOAT, 0, color);
			
	glDrawArrays(GL_POINTS, 0, particleCount);
			
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_COLOR_ARRAY);
	glDisable(GL_POINT_SPRITE_OES);			
}
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);


I fill the color array with r,g,b,a values (r,g,b are all currently set to 0) ‘a’ varies over time from 1.0 to 0.0. The texture is a red bitmap with a radial alpha channel. I’ve also tried using a different blend function:

glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

That makes a bit of a difference in the appearance of the particle, but does nothing to affect the fading out of the particle. Is this possible with POINT_SPRITES?

My texture loading code (in case you need it) is as follows:


glGenTextures(1, &textures[0]);
glBindTexture(GL_TEXTURE_2D, textures[0]);
	
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	
glTexImage2D(GL_TEXTURE_2D, 
	 0, // level of detail, 0 is full
	 GL_RGBA, 
	 textureWidth, 
	 textureHeight, 
	 0, // always 0, borders are not supported
	 GL_RGBA, 
	 GL_UNSIGNED_BYTE, 
	 textureData);

Any help would be appreciated.

Cheers,
Paul

Ahh… I figured it out. Turn off lighting before drawing particles:

glDisable(LIGHTING);

Cheers,
Paul

There are very good Point Sprite systems for the iPhone in both Oolong, and Cocos2D. It’s relatively trivial to alter the Cocos one to 3D.
Just letting you know for future reference. :slight_smile:

Thanks Scratt!