Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, alibaba), 1,184 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Fog fade thing... #134287
06/06/07 15:21
06/06/07 15:21
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
Because there are so many helpfull and n00b-friendly people on this forum, I'll ask my next question

I'm fading my fogcolor from evening to night and use now a single "fog_fade_speed" variable for the fade-speed. Logicaly this gives bad results because the count-down/count-up to the night fogcolors is different for each fogcolor(rgb). Now I'd need a formula that calculates the fog_fade_speed var for each fogcolor-shifting...you know what I mean?

Here what I have so far (just crap!!!):
Code:
//evening
var fog_eve_r = 250;
var fog_eve_g = 120;
var fog_eve_b = 60;

//night
var fog_night_r = 4;
var fog_night_g = 9;
var fog_night_b = 14;


var fog_fade_speed = 0.08; //...multiplied by time_speed

function suneve_fog_fade{

if d3d_fogcolor1.red > fog_eve_r {d3d_fogcolor1.red -= fog_fade_speed*time_step*time_speed;}
if d3d_fogcolor1.green > fog_eve_g {d3d_fogcolor1.green -= fog_fade_speed*time_step*time_speed;}
if d3d_fogcolor1.blue > fog_eve_b {d3d_fogcolor1.blue -= fog_fade_speed*time_step*time_speed;}

if d3d_fogcolor1.red < fog_eve_r {d3d_fogcolor1.red += fog_fade_speed*time_step*time_speed;}
if d3d_fogcolor1.green < fog_eve_g {d3d_fogcolor1.green += fog_fade_speed*time_step*time_speed;}
if d3d_fogcolor1.blue < fog_eve_b {d3d_fogcolor1.blue += fog_fade_speed*time_step*time_speed;}
}

function sunset_fog_fade{

if d3d_fogcolor1.red > fog_night_r {d3d_fogcolor1.red -= fog_fade_speed*time_step*time_speed;}
if d3d_fogcolor1.green > fog_night_g {d3d_fogcolor1.green -= fog_fade_speed*time_step*time_speed;}
if d3d_fogcolor1.blue > fog_night_b {d3d_fogcolor1.blue -= fog_fade_speed*time_step*time_speed;}

if d3d_fogcolor1.red < fog_night_r {d3d_fogcolor1.red += fog_fade_speed*time_step*time_speed);}
if d3d_fogcolor1.green < fog_night_g {d3d_fogcolor1.green += fog_fade_speed*time_step*time_speed;}
if d3d_fogcolor1.blue < fog_night_b {d3d_fogcolor1.blue += fog_fade_speed*time_step*time_speed;}
}



Re: Fog fade thing... [Re: Loopix] #134288
06/06/07 15:40
06/06/07 15:40
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline
Member
nipx  Offline
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
make it relative to the difference of the colors. Means something like

Code:

if d3d_fogcolor1.red < fog_eve_r {d3d_fogcolor1.red += (abs(fog_eve_r-fog_night_r)/25)*time_step*time_speed;} //play with 25




Haven tested anything but sounds logical imao


nipx

Re: Fog fade thing... [Re: nipx] #134289
06/06/07 15:55
06/06/07 15:55
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
Thanks! I'll try that...sounds indeed logical

Re: Fog fade thing... [Re: Loopix] #134290
06/06/07 16:12
06/06/07 16:12
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
Use a vec_lerp()...

vec_lerp(d3d_fogcolor1, fromColor, toColor, percent/100);


xXxGuitar511
- Programmer
Re: Fog fade thing... [Re: xXxGuitar511] #134291
06/06/07 16:59
06/06/07 16:59
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
sounds even better But I don't quite see how to implement it for my use Would you mind to give me some more hints?

Thanks

Re: Fog fade thing... [Re: Loopix] #134292
06/06/07 17:58
06/06/07 17:58
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
the first parameter is the vector to put the result in. For this, I used d3d_fogcolor1

the second and third are the vectors to mix between. First vector is the source color, and the second is the target color.

the fourth vector is the interpolation factor (0 - 1). This is the percentage to mix each color. At 0, the first color will be used. At 1, then second color will be used. 0.5 would be a perfect mix between the two...


Code:

//evening
var fog_eve[3] = 250, 120, 60;

//night
var fog_night[3] = 4, 9, 14;

var fog_fade_speed = 0.08;

function fadeColors(&colTarget, &col1, &col2)
{
var i = 0;
while(i < 100)
{
i = min(i + fog_fade_speed*time_step, 100);
vec_lerp(colTarget, col1, col2, i/100);
wait(1);
}
}

var currentColor[3];
Function etc_startup()
{
fog_color = 1;
//
vec_set(currentColor, d3d_fogcolor1);
fadeColors(d3d_fogcolor1, currentColor, fog_eve);
//
wait(-2);
//
vec_set(currentColor, d3d_fogcolor1);
fadeColors(d3d_fogcolor1, currentColor, fog_night);
}



This code would fade the current fog color to the evening fog color, then wait 2 seconds, and then fade to the night colors.

Last edited by xXxGuitar511; 06/06/07 20:33.

xXxGuitar511
- Programmer
Re: Fog fade thing... [Re: xXxGuitar511] #134293
06/06/07 18:06
06/06/07 18:06
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
Oh...thanks! Now this looks indeed promissing. I'll try ASAP and let you know if I got it to work

Thanks for your input!

Re: Fog fade thing... [Re: xXxGuitar511] #134294
06/06/07 19:38
06/06/07 19:38
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
I get a crash in vec_lerp(colTarget, col1, col2, i/100);

I think function parameters don't take vectors Do you know a quick and dirty workaround?

Re: Fog fade thing... [Re: Loopix] #134295
06/06/07 20:33
06/06/07 20:33
Joined: Mar 2006
Posts: 2,503
SC, United States
xXxGuitar511 Offline
Expert
xXxGuitar511  Offline
Expert

Joined: Mar 2006
Posts: 2,503
SC, United States
oh, sorry... fixed the above code


xXxGuitar511
- Programmer
Re: Fog fade thing... [Re: xXxGuitar511] #134296
06/06/07 22:49
06/06/07 22:49
Joined: Mar 2005
Posts: 969
ch
Loopix Offline OP
User
Loopix  Offline OP
User

Joined: Mar 2005
Posts: 969
ch
Works perfect now THX!

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1