Particle question

Started by
8 comments, last by Zaxxon21 21 years, 11 months ago
I was looking at Nehe tutorial 19 involving using particles and I had one question, if the background was not black, how would one be able to make sure that the particle bmp''s black parts were transparent? Would I have to make a tga file or something or is there an easier way? If tga files are the only way I can make an alpha channel, can someone explain to me how I could do this using Photoshop as its really the only graphics program I have... Thanks a lot!
Advertisement
If I remember right, NeHe''s engine blends the particles to the background using color, not alpha. So you wouldnt need a alpha-layer. The problem when mixing it with other colors then just one, is the depthtesting. In ordred for the engine to render correctly you need to start with the ones farthest away and end with the closest particles, so that they dont block eachother (unless you turn depthtesting off ofcourse, but then you wouldnt have such a dynamic engine)
In this tutorial, I''m quite sure NeHe use *additive* blending, thus black is transparent and Z-order is irrelevant.
Okay guys, sounds good, the question then is, how does one specify that black should be transparent, aka, how does one do this additive blending?
Nevermind, I seem to have figured it out, looks sweet, 1 problem I am now having though is that when I use fog, the black part of the image becomes visible, fog being:
glEnable(GL_FOG);
glFogf(GL_FOG_DENSITY, 0.0075);
glFogi(GL_FOG_MODE, GL_EXP);
glFogfv(GL_FOG_COLOR, fogcolor);
Any ideas how I can fix that (as in without removing the fog), thanks!
Transparency with the image used for the particle effect???
Brendan ''Locke'' Hennessy"I heard life sucks, so that''s why I don''t have one"
Every particle will blend with the fog just as any other surface so if you have a blue fog and black as alpha, it will turn blue annyway.
Why wouldnt you like to turn of fog before rendering particles? The should shine through the fog anyway. Im not sure what would look best, but what if you turn down the glColor the further away from the camera the particle is?
yeah, fog with transparent objects kinda sucks in openGL. You''d think there would be a way to have the transparency of an object affect how much fog it gets or something... I realize it''s not exactly "realistic" or anything, but it''d be handy.

What you can do is draw the particles with fog disabled and dim them down in the distance using a formula that simulates your fog parameters.
Okay, that sounds like a plan, thanks for the help guys!
One other solution might be to choose another method than additive blending. But your card needs to support this through extensions. I haven''t really looked into this very long but to me it seems that with other blending methods, fog and blend shouldn''t be a problem (if you can find the correct blendfuncs to go along with it).

- An eye for an eye will make the world go blind -

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

This topic is closed to new replies.

Advertisement