Archived

This topic is now archived and is closed to further replies.

Zaxxon21

Particle question

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 -

Share this post


Link to post
Share on other sites