Fade Particle to black
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
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);
I don't see why that wouldn't work. What's the problem?
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
Fenris Wrote:Are you in GL_SRC_ALPHA, GL_ONE blend mode?
I have testet all blending-combinations, nothing works
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.
Nothing in what you've posted indicates why it would become transparent.
Thanks for reply.
Texture-Environment is setup correctly.
Here a screenshot of what i get
![[Image: blend.jpg]](http://wr-media.net/tmp/blend.jpg)
blendmodes:
Texture-Environment is setup correctly.
Here a screenshot of what i get
![[Image: blend.jpg]](http://wr-media.net/tmp/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...
I have testet textures with alpha-channel but no luck:
![[Image: pic.jpg]](http://wr-media.net/tmp/pic.jpg)
here is the effect what i want (fade from brown to black, and fade out)
![[Image: test.jpg]](http://wr-media.net/tmp/test.jpg)
This is my textur:
![[Image: tex.jpg]](http://wr-media.net/tmp/tex.jpg)
This is my new code:
![[Image: pic.jpg]](http://wr-media.net/tmp/pic.jpg)
here is the effect what i want (fade from brown to black, and fade out)
![[Image: test.jpg]](http://wr-media.net/tmp/test.jpg)
This is my textur:
![[Image: tex.jpg]](http://wr-media.net/tmp/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);
Possibly Related Threads...
Thread: | Author | Replies: | Views: | Last Post | |
Discrad black parts in texture | bonanza | 7 | 10,185 |
Oct 27, 2011 01:05 AM Last Post: bonanza |
|
Problems trying to fade in windowed mode | Wowbagger | 4 | 6,056 |
Aug 13, 2007 12:11 PM Last Post: Wowbagger |
|
how to make a RGBA image fade away? | WhatMeWorry | 7 | 6,523 |
Nov 13, 2006 07:58 PM Last Post: akb825 |
|
Particle Engine | bronxbomber92 | 9 | 6,092 |
Oct 16, 2006 03:44 PM Last Post: bronxbomber92 |
|
Particle trails | LongJumper | 6 | 5,575 |
Jun 29, 2005 12:42 AM Last Post: LongJumper |