mirror of
https://git.minetest.land/VoxeLibre/VoxeLibre.git
synced 2024-11-22 10:31:06 +01:00
Another correction to color interpolation, change day color from layer position 0.15 to 0.50
This commit is contained in:
parent
f6c3f4bd16
commit
7807093b50
2 changed files with 25 additions and 3 deletions
|
@ -2,6 +2,7 @@
|
||||||
local modname = minetest.get_current_modname()
|
local modname = minetest.get_current_modname()
|
||||||
local modpath = minetest.get_modpath(modname)
|
local modpath = minetest.get_modpath(modname)
|
||||||
local NIGHT_VISION_RATIO = 0.45
|
local NIGHT_VISION_RATIO = 0.45
|
||||||
|
local DEBUG = false
|
||||||
|
|
||||||
-- Settings
|
-- Settings
|
||||||
local minimum_update_interval = { 250e3 }
|
local minimum_update_interval = { 250e3 }
|
||||||
|
@ -199,7 +200,7 @@ function skycolor_utils.convert_to_rgb(minval, maxval, current_val, colors)
|
||||||
-- Get the first color's values
|
-- Get the first color's values
|
||||||
local index1 = math.floor(scaled_value)
|
local index1 = math.floor(scaled_value)
|
||||||
local color1 = colors[index1]
|
local color1 = colors[index1]
|
||||||
local frac1 = scaled_value - index1
|
local frac1 = 1.0 - (scaled_value - index1)
|
||||||
|
|
||||||
-- Get the second color's values
|
-- Get the second color's values
|
||||||
local index2 = math.min(index1 + 1, #colors) -- clamp to maximum color index (will occur if index1 == #colors)
|
local index2 = math.min(index1 + 1, #colors) -- clamp to maximum color index (will occur if index1 == #colors)
|
||||||
|
@ -207,11 +208,32 @@ function skycolor_utils.convert_to_rgb(minval, maxval, current_val, colors)
|
||||||
local color2 = colors[index2]
|
local color2 = colors[index2]
|
||||||
|
|
||||||
-- Interpolate between color1 and color2
|
-- Interpolate between color1 and color2
|
||||||
return {
|
local res = {
|
||||||
r = math.floor(frac1 * color1.r + frac2 * color2.r),
|
r = math.floor(frac1 * color1.r + frac2 * color2.r),
|
||||||
g = math.floor(frac1 * color1.g + frac2 * color2.g),
|
g = math.floor(frac1 * color1.g + frac2 * color2.g),
|
||||||
b = math.floor(frac1 * color1.b + frac2 * color2.b),
|
b = math.floor(frac1 * color1.b + frac2 * color2.b),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if DEBUG then
|
||||||
|
minetest.log(dump({
|
||||||
|
minval = minval,
|
||||||
|
maxval = maxval,
|
||||||
|
current_val = current_val,
|
||||||
|
colors = colors,
|
||||||
|
res = res,
|
||||||
|
scaled_value = scaled_value,
|
||||||
|
|
||||||
|
frac1 = frac1,
|
||||||
|
index1 = index1,
|
||||||
|
color1 = color1,
|
||||||
|
|
||||||
|
frac2 = frac2,
|
||||||
|
index2 = index2,
|
||||||
|
color2 = color2,
|
||||||
|
}))
|
||||||
|
end
|
||||||
|
|
||||||
|
return res
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Simple getter. Either returns user given players list or get all connected players if none provided
|
-- Simple getter. Either returns user given players list or get all connected players if none provided
|
||||||
|
|
|
@ -40,7 +40,7 @@ function dimension_handlers.overworld(player, sky_data)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Use overworld defaults
|
-- Use overworld defaults
|
||||||
local day_color = mcl_weather.skycolor.get_sky_layer_color(0.15)
|
local day_color = mcl_weather.skycolor.get_sky_layer_color(0.5)
|
||||||
local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.27)
|
local dawn_color = mcl_weather.skycolor.get_sky_layer_color(0.27)
|
||||||
local night_color = mcl_weather.skycolor.get_sky_layer_color(0.1)
|
local night_color = mcl_weather.skycolor.get_sky_layer_color(0.1)
|
||||||
sky_data.sky = {
|
sky_data.sky = {
|
||||||
|
|
Loading…
Reference in a new issue