PDA

View Full Version : Look this!



Gelero
10-02-2001, 05:57 PM
hey! whats up ?
im trying to make my particles glowing like fire, or something like that!
im using this code:




case FStyle of
normal : begin
glColor3f( __VisualColor[0], __VisualColor[1], __VisualColor[2] );
glCallList( FImageHandle ); // Draw Our Particle
end;
trans : begin
glEnable(GL_BLEND); // Enable Blending
glBlendFunc( GL_SRC_ALPHA, GL_ONE ); // Type Of Blending To Perform
glColor4f( __VisualColor[0],
__VisualColor[1],
__VisualColor[2],
Particles[loop].life );
glCallList( FImageHandle ); // Draw Our Particle
glDisable(GL_BLEND);
end;
glow : begin
glEnable(GL_BLEND); // Enable Blending
glBlendFunc( GL_ONE, GL_ONE );
glColor4f( __VisualColor[0],
__VisualColor[1],
__VisualColor[2],
Particles[loop].life );
glCallList( FImageHandle ); // Draw Our Particle
glDisable(GL_BLEND);
end;
end;


where am i making mistake???




[This message has been edited by Gelero (edited 10-03-2001).]

Evil-Dog
10-02-2001, 08:23 PM
Hi Gelero
What programmign language is that ?

------------------------------
Evil-Dog
*Sleep is a waste of time*

Gelero
10-03-2001, 02:12 AM
its Delphi!

can you help me ???

Bob
10-03-2001, 02:25 AM
I don't see anything wrong with that piece of code.

But think of it, what have you told us? Basically you said, "whats wrong?". You don't give any description on what actually happens, and what you want to happen (apart from a "glow effect").

A detailed description of the problem, what you want, what happens, what do you compile into your displaylist, would be great to know. Otherwise I'm afraid noone can help you.

Gelero
10-03-2001, 02:42 AM
ok... i have a single quad stored in display list... the particle!
and im using the FStyle = glow...

so, my particle has to be glowing, damn!

look at screenshot and see by yourself!

http://www.brfree.com.br/~dodgethis/ss.jpg

thanks for the help!

Bob
10-03-2001, 03:00 AM
glBlendFunc(GL_ONE, GL_ONE) is used when performing additive blending, which is used, among orther places, in particle systems to create a glow-like effect.

To get this glow effect, you must draw a few particles ontop of eachother, so that their color is added. The particle itself is not glowing, it's the result of several particles together that causes the output to look like the particle are glowing.

To get the glow-color to reach a white color, all particles together must contribute to all three color components.

If you have 10 red and blue particles that are added together, the final "glow" will be magenta and not white, because there are no particles contributing to the green color component.

Gelero
10-03-2001, 03:10 AM
ok... i see...
but look at screenshot... im drawing a particle on top of each other... some with red component and some with red AND green(yellow)components...
those particles are suppose to be glowing in some color!!!!! but they are not!

why????

Bob, are you online on ICQ???

[This message has been edited by Gelero (edited 10-03-2001).]

Bob
10-03-2001, 03:43 AM
Yes, I'm online now (thanks for reminding me by the way, was offline http://www.opengl.org/discussion_boards/ubb/biggrin.gif ). UIN is 72295179

Anyways, you are right, those particles should be added (glowing if you like). Can it be that depthbuffer test is on, and you (by accident) happen to draw them in front to back. This way, additive blending has no effect.

Try to disable depth writes before drawing particles (keep depthtest), this might be it. Order should not be dependent with additive blending, but this assumes all particles can be drawn into the buffer, which is not the case if some of them are rejected by the Z-buffer because newer older particles are drawn "in front" and Z-buffer is updated.