From d49ff648f255ca06b35b4c36e86ebcd6e89ede08 Mon Sep 17 00:00:00 2001 From: teknomunk Date: Sat, 5 Oct 2024 10:15:53 -0500 Subject: [PATCH] Another correction to color interpolation, change day color from layer position 0.15 to 0.50 --- mods/ENVIRONMENT/mcl_weather/skycolor.lua | 26 +++++++++++++++++-- .../mcl_weather/skycolor/dimensions.lua | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor.lua b/mods/ENVIRONMENT/mcl_weather/skycolor.lua index fdf7c33c8..eb217b3b2 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor.lua @@ -2,6 +2,7 @@ local modname = minetest.get_current_modname() local modpath = minetest.get_modpath(modname) local NIGHT_VISION_RATIO = 0.45 +local DEBUG = false -- Settings 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 local index1 = math.floor(scaled_value) local color1 = colors[index1] - local frac1 = scaled_value - index1 + local frac1 = 1.0 - (scaled_value - index1) -- Get the second color's values 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] -- Interpolate between color1 and color2 - return { + local res = { r = math.floor(frac1 * color1.r + frac2 * color2.r), g = math.floor(frac1 * color1.g + frac2 * color2.g), 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 -- Simple getter. Either returns user given players list or get all connected players if none provided diff --git a/mods/ENVIRONMENT/mcl_weather/skycolor/dimensions.lua b/mods/ENVIRONMENT/mcl_weather/skycolor/dimensions.lua index 6a8856434..5596e756e 100644 --- a/mods/ENVIRONMENT/mcl_weather/skycolor/dimensions.lua +++ b/mods/ENVIRONMENT/mcl_weather/skycolor/dimensions.lua @@ -40,7 +40,7 @@ function dimension_handlers.overworld(player, sky_data) end -- 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 night_color = mcl_weather.skycolor.get_sky_layer_color(0.1) sky_data.sky = {