Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Fade from one color to another

Author
Message
Kryogenik
16
Years of Service
User Offline
Joined: 22nd Sep 2009
Location: Heidelberg, Germany
Posted: 23rd Apr 2010 22:43
Hey guys. I'm adding a flamethrower to my game and I decided I should enhance my particle system, so it can have fading particles, rotating particles, and stuff. I found out how to physically fade a particle (ghost object and fade object) and rotating it was pretty self explanatory (zrotate, duh). But I got stuck. You know how a flamethrower's fire starts how blue and fades to reddish orange? I want to be able to do that, but haven't been able to figure out how to fade colors like that. I know for red and blue, you could just use rgb and increase red and decrease blue, but what about something else? I thought of just increasing and decreasing the rgb stuff, but won't that just make a bunch of random colors until it reaches the one you put in? Sorry if this question has already been answered. Anyway, thanks in advance

Codesurge is so awesome, thanks Hyrichter.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 23rd Apr 2010 22:50
Why not just make a blue flame as well, and have it fade out on a shorter life than the flames. I think that would give the better effect, the other option is to mess with the object diffuse colours, and that can get complex.


Health, Ammo, and bacon and eggs!
The Viking
17
Years of Service
User Offline
Joined: 21st Oct 2008
Location: Asgard
Posted: 24th Apr 2010 02:23
When you are talking about fading it... do refer to a gradient appearance where the base of the flame is blue, and the tip is yellow? or are you referring to it starts out yellow and slowly gets more blue over time up to a certain level?

www.myspace.com/norseblod
Math89
22
Years of Service
User Offline
Joined: 23rd Jan 2004
Location: UK
Posted: 24th Apr 2010 12:31
You can use linear interpolation: c = a*c1 + (a-1)*c2 where c1 and c2 are your two colours and a is the blending coefficient in the range [0,1]. All you need to do is to increase the value of a, and apply this small formula on your r, g, and b values.

Login to post a reply

Server time is: 2026-07-26 04:28:04
Your offset time is: 2026-07-26 04:28:04