From 879839d36d6f3d8442c662ab73743e36f6f1b6e1 Mon Sep 17 00:00:00 2001 From: karl Date: Tue, 28 Jan 2020 16:05:41 +0100 Subject: [PATCH] Also interpolate light energy depending on daytime --- Util/Environment.gd | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Util/Environment.gd b/Util/Environment.gd index 5087f15..85b70e4 100644 --- a/Util/Environment.gd +++ b/Util/Environment.gd @@ -58,16 +58,24 @@ func _light_rotation(): #set light color depending on daytime func _sky_light(): + var new_light_energy = 0.0 + if _degree <= SUNRISE_DEGREE: #_worldEnvironment.environment.background_sky.sky_curve = 1 _setSkyColor = SUNRISE elif _degree > SUNRISE_DEGREE and _degree < RISE_INTERPOL: #interpolate colors from sunrise sky to daytime sky _setSkyColor = SUNRISE.linear_interpolate(STANDARD_SKY_TOP, ((_degree-SUNRISE_DEGREE)/(RISE_INTERPOL-SUNRISE_DEGREE))) + new_light_energy = inverse_lerp(SUNRISE_DEGREE, RISE_INTERPOL, _degree) elif _degree >= RISE_INTERPOL and _degree <= SET_INTERPOL: #_worldEnvironment.environment.background_sky.sky_curve = 0.09 _setSkyColor = STANDARD_SKY_TOP + new_light_energy = 1.0 elif _degree > SET_INTERPOL and _degree < SUNSET_DEGREE: #interpolate colors from daytime sky to sunset sky _setSkyColor = STANDARD_SKY_TOP.linear_interpolate(SUNSET, ((_degree-SET_INTERPOL)/(SUNSET_DEGREE-SET_INTERPOL))) + new_light_energy = 1.0 - inverse_lerp(SET_INTERPOL, SUNSET_DEGREE, _degree) elif _degree >= SUNSET_DEGREE: _setSkyColor = SUNSET - _worldEnvironment.environment.background_sky.sky_horizon_color = _setSkyColor \ No newline at end of file + + _worldEnvironment.environment.background_sky.sky_horizon_color = _setSkyColor + _light.light_energy = new_light_energy + _worldEnvironment.environment.ambient_light_energy = 0.2 + 0.3 * new_light_energy \ No newline at end of file