mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Light curve: Simplify and improve code, fix darkened daytime sky (#7693)
This commit is contained in:
parent
220ec79e4a
commit
79e393cf4b
3 changed files with 46 additions and 30 deletions
16
src/light.h
16
src/light.h
|
@ -63,21 +63,7 @@ inline u8 decode_light(u8 light)
|
|||
|
||||
// 0.0 <= light <= 1.0
|
||||
// 0.0 <= return value <= 1.0
|
||||
inline float decode_light_f(float light_f)
|
||||
{
|
||||
s32 i = (u32)(light_f * LIGHT_MAX + 0.5);
|
||||
|
||||
if (i <= 0)
|
||||
return (float)light_decode_table[0] / 255.0;
|
||||
if (i >= LIGHT_SUN)
|
||||
return (float)light_decode_table[LIGHT_SUN] / 255.0;
|
||||
|
||||
float v1 = (float)light_decode_table[i - 1] / 255.0;
|
||||
float v2 = (float)light_decode_table[i] / 255.0;
|
||||
float f0 = (float)i - 0.5;
|
||||
float f = light_f * LIGHT_MAX - f0;
|
||||
return f * v2 + (1.0 - f) * v1;
|
||||
}
|
||||
float decode_light_f(float light_f);
|
||||
|
||||
void set_light_table(float gamma);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue