# OpenGL Particle System question,

This topic is 4781 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I want to try and model some flames with my basic particle system but im having troubles figuring how its done. I noticed in alot of examples it looks like the edges are a different colour mine looks very crappy at the moment im not sure how to do it. Do they have two particle systems behind each other ? one red one yellow or is there an easier way. I noticed my alpha blending isnt that accurate it sorta fades really quickly instead of gradually heres the code i use to init opengl maybe im missing something. Init Code
	glEnable(GL_DEPTH_TEST);//enables the depth test
glClearColor(0.0f, 0.3f, 0.3f, 0.0f);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
glEnable(GL_TEXTURE_2D);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.3);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);


thanks alot for any advice. [Edited by - fishleg003 on November 12, 2005 3:25:19 PM]

##### Share on other sites
Flames are best done using an additive blend and a very dim reddish or yellowish red particle color. Use glBlendFunc(GL_ONE, GL_ONE) to perform additive blending. This first shot uses alpha blending just as you are doing, and the second shot uses the same exact particle but with additive blending. You can see the difference.

##### Share on other sites
WOW what a change from before,

I dont understand how it blends like yours though i have a gray scale texture and im making it redish via glColor4f. How do i make it so the outsides are a different colour ?

thx alot
fishy

##### Share on other sites
Mine has a different color because it starts as red but with a little bit of green in it as well so that as more particles add on top, the color starts to tend toward yellow rather than red. Using just a 'pure' shade of red, green, or blue will not have this effect, but will instead simply increase the brightness of that shade.

##### Share on other sites
So something like this one ?

##### Share on other sites
Well, I always just use grey-scale textures colored with a single color. It's the RGB components of the color you use that determine how the color ramps up when multiple particles are blended atop one another. If you use a 'pure' shade of red, ie R>0 G==0 B==0 then the additive blending will merely increase the brightness of the red, without any color modification. But if you use a shade of red with a little green and a tiny bit of blue in it, then as particles are added on top of each other, the color tends away from red through yellow and toward white where the particles are densely packed (in the center of the cluster) and remains closer to the original red shade at the edges of the cluster where particles are not so dense.

##### Share on other sites
Cool tips mate thanks alot i would never of thought it would be that simple.

Final result :D

You have any idea's how i would model lightning ? Or a comet with a trail behind it ?

thanks again for that tip.

##### Share on other sites
Lightning is fairly easy. I do it by generating a chained-together sequence of quads, or a quadstrip if you will, following the path of the lightning. Then I draw the lightning in 2 passes using an additive blend. The first pass I draw the bluish 'halo' that surrounds the bolt, using a dark electric blue color and a texture that goes from dim at the edges to brighter in the middle. I use a similar sort of texture, though 'tighter' or sharper to draw the bar of lightning using a color closer to white. I did a writeup awhile ago with some screenshots from my engine here although it deals mainly with the generation of the quadstrip, and not so much on the texturing, and there are things in that process that I do differently now as well.

##### Share on other sites
Thx alot ill give that ago and post some shots of my mess lol.

Very nice lightning btw. :)

##### Share on other sites
Thanks. [grin]

I had some thoughts for doing a comet tail, but I haven't tried them so use with a grain of salt. But you could have the particles spawn along a line segment rather than a point, and have the life-span of the particles dependepent upon where on the line they spawn. Particles spawned from the center would live longer on average than particles spawned on the edges. The particles would be given a velocitiy perpendicular to the line segment. The result might (again, I haven't tried it) be a system in which lots of particles cluster in a mass around the segment, tapering out to a point at the end of the tail where the particles from the center would be the last ones left alive. Might be worth a try, anyway.

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 13
• 26
• 10
• 11
• 9
• ### Forum Statistics

• Total Topics
633736
• Total Posts
3013598
×