iDevGames Forums
Fade Particle to black - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Fade Particle to black (/thread-2691.html)



Fade Particle to black - bonanza - Apr 2, 2008 10:46 AM

hi,
anyone know to how i can fade a particlecolor from red (for example) to black?
Fading works with all colors except black.
I have testet all blending-types, but nothing works.

here is my code
Code:
float r = p[i].startColor.r + (p[i].timeAlive / p[i].lifeTime) * (p[i].endColor.r - p[i].startColor.r);
float g = p[i].startColor.g + (p[i].timeAlive / p[i].lifeTime) * (p[i].endColor.g - p[i].startColor.g);
float b = p[i].startColor.b + (p[i].timeAlive / p[i].lifeTime) * (p[i].endColor.b - p[i].startColor.b);
                
glColor4f(r, g, b, 1.0);



Fade Particle to black - OneSadCookie - Apr 2, 2008 11:16 AM

I don't see why that wouldn't work. What's the problem?


Fade Particle to black - bonanza - Apr 2, 2008 11:28 AM

OneSadCookie Wrote:I don't see why that wouldn't work. What's the problem?

when fade to black, the particles fade out (transparent) but they should fade to black


Fade Particle to black - Fenris - Apr 2, 2008 11:37 AM

Are you in GL_SRC_ALPHA, GL_ONE blend mode?


Fade Particle to black - bonanza - Apr 2, 2008 11:38 AM

Fenris Wrote:Are you in GL_SRC_ALPHA, GL_ONE blend mode?

I have testet all blending-combinations, nothing works


Fade Particle to black - OneSadCookie - Apr 2, 2008 12:44 PM

Should be ONE, ONE_MINUS_SRC_ALPHA or SRC_ALPHA, ONE_MINUS_SRC_ALPHA depending on whether the underlying texture is premultiplied or not. Make sure the texture environment is set to MODULATE.

Nothing in what you've posted indicates why it would become transparent.


Fade Particle to black - bonanza - Apr 2, 2008 09:57 PM

Thanks for reply.
Texture-Environment is setup correctly.
Here a screenshot of what i get
[Image: blend.jpg]

blendmodes:
Code:
glDepthMask(GL_FALSE);
glEnable(GL_BLEND);

glBindTexture(GL_TEXTURE_2D, texture);

//glBlendFunc(GL_SRC_ALPHA, GL_ONE);
//glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ONE);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

render...



Fade Particle to black - Fenris - Apr 3, 2008 04:57 AM

It looks to me as if there's no alpha channel on the particle?


Fade Particle to black - bonanza - Apr 3, 2008 05:24 AM

I have testet textures with alpha-channel but no luck:
[Image: pic.jpg]
here is the effect what i want (fade from brown to black, and fade out)

[Image: test.jpg]

This is my textur:
[Image: tex.jpg]

This is my new code:
Code:
float r = _p[i].startColor.r * (1-(_p[i].age / _p[i].maxAge) ) + _p[i].endColor.r * (_p[i].age / _p[i].maxAge);
float g = _p[i].startColor.g * (1-(_p[i].age / _p[i].maxAge) ) + _p[i].endColor.g * (_p[i].age / _p[i].maxAge);
float b = _p[i].startColor.b * (1-(_p[i].age / _p[i].maxAge) ) + _p[i].endColor.b * (_p[i].age / _p[i].maxAge);            
float alpha = (_p[i].age / _p[i].maxAge);
            
glColor4f(r,g,b, 1- alpha);