mirror of
https://github.com/t-affeldt/regional_weather.git
synced 2025-02-03 22:10:23 +01:00
Enable shadows, increase puddle transparency, tweak player speed buffs
This commit is contained in:
parent
351c11b3c7
commit
932546a3d5
@ -53,7 +53,7 @@ for i = 1, VARIANT_COUNT do
|
|||||||
local name = BLOCK_PREFIX .. i
|
local name = BLOCK_PREFIX .. i
|
||||||
local index = i
|
local index = i
|
||||||
if i < 10 then index = "0" .. i end
|
if i < 10 then index = "0" .. i end
|
||||||
local texture = "weather_puddle_" .. index .. ".png^[opacity:128"
|
local texture = "weather_puddle_" .. index .. ".png^[opacity:24"
|
||||||
if flip == 1 then
|
if flip == 1 then
|
||||||
name = name .. "_flipped"
|
name = name .. "_flipped"
|
||||||
texture = texture .. "^[transformFX"
|
texture = texture .. "^[transformFX"
|
||||||
|
@ -12,21 +12,47 @@ local function calc_cloud_height(heat, humidity, dewpoint)
|
|||||||
return base + climate_api.utility.rangelim(variation, -scale, scale)
|
return base + climate_api.utility.rangelim(variation, -scale, scale)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- maps range of 0 to 1 to any other range
|
||||||
|
local function map_range(val, low, high)
|
||||||
|
return (val + low) * (high - low)
|
||||||
|
end
|
||||||
|
|
||||||
local function generate_effects(params)
|
local function generate_effects(params)
|
||||||
local override = {}
|
local override = {}
|
||||||
|
|
||||||
|
local cloud_density = climate_api.utility.rangelim(params.humidity / 100, 0.15, 0.65)
|
||||||
|
local cloud_thickness = climate_api.utility.rangelim(params.base_humidity * 0.2, 1, 18)
|
||||||
local cloud_height = calc_cloud_height(params.heat, params.humidity, params.dewpoint)
|
local cloud_height = calc_cloud_height(params.heat, params.humidity, params.dewpoint)
|
||||||
local wind = climate_api.environment.get_wind({ x = 0, y = cloud_height, z = 0 })
|
local wind = climate_api.environment.get_wind({ x = 0, y = cloud_height, z = 0 })
|
||||||
|
|
||||||
|
-- diffuse shadows when cloudy
|
||||||
|
-- zero at density 0.65 and one at 0.15
|
||||||
|
local cloud_shadows = 1.075 - (cloud_density / 0.5)
|
||||||
|
|
||||||
|
-- diffuse shadows at dawn / dusk
|
||||||
|
-- 15 hours between dawn and dusk accoring to https://wiki.minetest.net/Time_of_day
|
||||||
|
local daylight_duration = 15 / 24
|
||||||
|
local daytime = climate_api.utility.rangelim(minetest.get_timeofday(), 0.1875, 0.8125)
|
||||||
|
-- zero at dawn / dusk and one at midday
|
||||||
|
local daytime_shadows = 1 - (math.abs(0.5 - daytime) * 2 / daylight_duration)
|
||||||
|
|
||||||
|
local shadow_intensity = map_range(cloud_shadows + daytime_shadows, 0.15, 0.5)
|
||||||
|
local light_saturation = map_range(cloud_shadows + daytime_shadows, 0.8, 1.2)
|
||||||
|
|
||||||
local skybox = {priority = 10}
|
local skybox = {priority = 10}
|
||||||
skybox.cloud_data = {
|
skybox.cloud_data = {
|
||||||
density = climate_api.utility.rangelim(params.humidity / 100, 0.15, 0.65),
|
density = cloud_density,
|
||||||
speed = wind,
|
speed = wind,
|
||||||
thickness = climate_api.utility.rangelim(params.base_humidity * 0.2, 1, 18),
|
thickness = cloud_thickness,
|
||||||
height = cloud_height,
|
height = cloud_height,
|
||||||
ambient = "#0f0f1050"
|
ambient = "#0f0f1050"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
skybox.light_data = {
|
||||||
|
shadow_intensity = shadow_intensity,
|
||||||
|
saturation = light_saturation
|
||||||
|
}
|
||||||
|
|
||||||
if params.height > -100 and params.humidity > 40 then
|
if params.height > -100 and params.humidity > 40 then
|
||||||
skybox.cloud_data.color = "#b2a4a4b0"
|
skybox.cloud_data.color = "#b2a4a4b0"
|
||||||
end
|
end
|
||||||
@ -50,6 +76,7 @@ local function generate_effects(params)
|
|||||||
|
|
||||||
override["climate_api:skybox"] = skybox
|
override["climate_api:skybox"] = skybox
|
||||||
|
|
||||||
|
if params.height > - 50 and not params.indoors then
|
||||||
local movement = params.player:get_velocity()
|
local movement = params.player:get_velocity()
|
||||||
local movement_direction
|
local movement_direction
|
||||||
if (vector.length(movement) < 0.1) then
|
if (vector.length(movement) < 0.1) then
|
||||||
@ -60,6 +87,8 @@ local function generate_effects(params)
|
|||||||
local vector_product = vector.dot(movement_direction, wind)
|
local vector_product = vector.dot(movement_direction, wind)
|
||||||
local movement_penalty = climate_api.utility.sigmoid(vector_product, 1.5, 0.15, 0.9) + 0.2
|
local movement_penalty = climate_api.utility.sigmoid(vector_product, 1.5, 0.15, 0.9) + 0.2
|
||||||
override["regional_weather:speed_buff"] = movement_penalty
|
override["regional_weather:speed_buff"] = movement_penalty
|
||||||
|
end
|
||||||
|
|
||||||
return override
|
return override
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -18,6 +18,10 @@ effects["climate_api:skybox"] = {
|
|||||||
},
|
},
|
||||||
moon_data = { visible = false },
|
moon_data = { visible = false },
|
||||||
star_data = { visible = false },
|
star_data = { visible = false },
|
||||||
|
light_data = {
|
||||||
|
shadow_intensity = 0,
|
||||||
|
saturation = 1
|
||||||
|
},
|
||||||
priority = 100
|
priority = 100
|
||||||
}
|
}
|
||||||
|
|
||||||
|
2
init.lua
2
init.lua
@ -19,7 +19,7 @@ end
|
|||||||
|
|
||||||
regional_weather = {}
|
regional_weather = {}
|
||||||
regional_weather.settings = {}
|
regional_weather.settings = {}
|
||||||
regional_weather.settings.player_speed = get_setting_bool("player_speed", true)
|
regional_weather.settings.player_speed = get_setting_bool("player_speed", false)
|
||||||
regional_weather.settings.snow = get_setting_bool("snow_layers", true)
|
regional_weather.settings.snow = get_setting_bool("snow_layers", true)
|
||||||
regional_weather.settings.snow_griefing = get_setting_bool("snow_griefing", true)
|
regional_weather.settings.snow_griefing = get_setting_bool("snow_griefing", true)
|
||||||
regional_weather.settings.puddles = get_setting_bool("puddles", true)
|
regional_weather.settings.puddles = get_setting_bool("puddles", true)
|
||||||
|
1
mod.conf
1
mod.conf
@ -1,7 +1,6 @@
|
|||||||
name = regional_weather
|
name = regional_weather
|
||||||
title = Regional Weather
|
title = Regional Weather
|
||||||
author = TestificateMods
|
author = TestificateMods
|
||||||
release = 100000
|
|
||||||
depends = climate_api
|
depends = climate_api
|
||||||
optional_depends = default, lightning, farming, fire, pedology
|
optional_depends = default, lightning, farming, fire, pedology
|
||||||
description = """
|
description = """
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
[Features]
|
[Features]
|
||||||
|
|
||||||
# If set to true, wind will boost or penalize player movements based on direction.
|
# If set to true, wind will boost or penalize player movements based on direction.
|
||||||
regional_weather_player_speed (Change movement speed based on wind) bool true
|
regional_weather_player_speed (Change movement speed based on wind) bool false
|
||||||
|
|
||||||
# If set to true, snow layers will stack up during snowy weather.
|
# If set to true, snow layers will stack up during snowy weather.
|
||||||
regional_weather_snow_layers (Place snow layers) bool true
|
regional_weather_snow_layers (Place snow layers) bool true
|
||||||
|
Loading…
Reference in New Issue
Block a user