Fade Particle to black

Apprentice
Posts: 9
Joined: 2010.02
Post: #1
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);
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #2
I don't see why that wouldn't work. What's the problem?
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2010.02
Post: #3
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
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #4
Are you in GL_SRC_ALPHA, GL_ONE blend mode?
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2010.02
Post: #5
Fenris Wrote:Are you in GL_SRC_ALPHA, GL_ONE blend mode?

I have testet all blending-combinations, nothing works
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #6
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.
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2010.02
Post: #7
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...
Quote this message in a reply
Oldtimer
Posts: 834
Joined: 2002.09
Post: #8
It looks to me as if there's no alpha channel on the particle?
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2010.02
Post: #9
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);
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Discrad black parts in texture bonanza 7 5,655 Oct 27, 2011 01:05 AM
Last Post: bonanza
  Problems trying to fade in windowed mode Wowbagger 4 3,697 Aug 13, 2007 12:11 PM
Last Post: Wowbagger
  how to make a RGBA image fade away? WhatMeWorry 7 4,406 Nov 13, 2006 07:58 PM
Last Post: akb825
  Particle Engine bronxbomber92 9 3,761 Oct 16, 2006 03:44 PM
Last Post: bronxbomber92
  Particle trails LongJumper 6 3,280 Jun 29, 2005 12:42 AM
Last Post: LongJumper