# OpenGL Particle System question,

## 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.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627682
• Total Posts
2978614
• ### Similar Content

• Both functions are available since 3.0, and I'm currently using glMapBuffer(), which works fine.
But, I was wondering if anyone has experienced advantage in using glMapBufferRange(), which allows to specify the range of the mapped buffer. Could this be only a safety measure or does it improve performance?
Note: I'm not asking about glBufferSubData()/glBufferData. Those two are irrelevant in this case.
• By xhcao
Before using void glBindImageTexture(    GLuint unit, GLuint texture, GLint level, GLboolean layered, GLint layer, GLenum access, GLenum format), does need to make sure that texture is completeness.
• By cebugdev
hi guys,
are there any books, link online or any other resources that discusses on how to build special effects such as magic, lightning, etc. in OpenGL? i mean, yeah most of them are using particles but im looking for resources specifically on how to manipulate the particles to look like an effect that can be use for games,. i did fire particle before, and I want to learn how to do the other 'magic' as well.
Like are there one book or link(cant find in google) that atleast featured how to make different particle effects in OpenGL (or DirectX)? If there is no one stop shop for it, maybe ill just look for some tips on how to make a particle engine that is flexible enough to enable me to design different effects/magic
let me know if you guys have recommendations.
• By dud3
How do we rotate the camera around x axis 360 degrees, without having the strange effect as in my video below?
Mine behaves exactly the same way spherical coordinates would, I'm using euler angles.
Tried googling, but couldn't find a proper answer, guessing I don't know what exactly to google for, googled 'rotate 360 around x axis', got no proper answers.

References:
Code: https://pastebin.com/Hcshj3FQ
The video shows the difference between blender and my rotation:

• By Defend
I've had a Google around for this but haven't yet found some solid advice. There is a lot of "it depends", but I'm not sure on what.
My question is what's a good rule of thumb to follow when it comes to creating/using VBOs & VAOs? As in, when should I use multiple or when should I not? My understanding so far is that if I need a new VBO, then I need a new VAO. So when it comes to rendering multiple objects I can either:
* make lots of VAO/VBO pairs and flip through them to render different objects, or
* make one big VBO and jump around its memory to render different objects.
I also understand that if I need to render objects with different vertex attributes, then a new VAO is necessary in this case.
If that "it depends" really is quite variable, what's best for a beginner with OpenGL, assuming that better approaches can be learnt later with better understanding?

• 13
• 12
• 10
• 12
• 22