Divergent/mods/Atmospherics/gamedata/scripts/ssfx_lut.script

168 lines
4.6 KiB
Plaintext

-- @ Version: SCREEN SPACE SHADERS - UPDATE 19
-- @ Description: LUT script
-- @ Author: https://www.moddb.com/members/ascii1457
-- @ Mod: https://www.moddb.com/mods/stalker-anomaly/addons/screen-space-shaders
local ssfx_lut_default = { group = 1, intensity = 1.00 }
local ssfx_lut_transition_speed = 0.005
-- Internal vars
local ssfx_lut_group1 = 0
local ssfx_lut_group2 = 0
local ssfx_lut_lerp = 0
local ssfx_lut_lerp_target = 0
local ssfx_lut_int = 0
local ssfx_lut_lerp_done = true
local DebugGroup = 0;
-- Set a LUT table for a specific map
local ssfx_maps = {
["jupiter"] = { group = 25, intensity = 1.0 },
["jupiter_underground"] = { group = 14, intensity = 1.0 },
["k00_marsh"] = { group = 23, intensity = 1.0 },
["k01_darkscape"] = { group = 21, intensity = 1.0 },
["k02_trucks_cemetery"] = { group = 29, intensity = 1.0 },
["l01_escape"] = { group = 21, intensity = 1.0 },
["l02_garbage"] = { group = 28, intensity = 1.0 },
["l03_agroprom"] = { group = 24, intensity = 1.0 },
["l03u_agr_underground"] = { group = 32, intensity = 1.0 },
["l04_darkvalley"] = { group = 27, intensity = 1.0 },
["l04u_labx18"] = { group = 14, intensity = 1.0 },
["l05_bar"] = { group = 18, intensity = 1.0 },
["l06_rostok"] = { group = 19, intensity = 1.0 },
["l07_military"] = { group = 20, intensity = 1.0 },
["l08_yantar"] = { group = 30, intensity = 1.0 },
["l08u_brainlab"] = { group = 14, intensity = 1.0 },
["l09_deadcity"] = { group = 18, intensity = 1.0 },
["l10_limansk"] = { group = 17, intensity = 1.0 },
["l10_radar"] = { group = 17, intensity = 1.0 },
["l10_red_forest"] = { group = 26, intensity = 1.0 },
["l10u_bunker"] = { group = 14, intensity = 1.0 },
["l11_hospital"] = { group = 31, intensity = 1.0 },
["l11_pripyat"] = { group = 22, intensity = 1.0 },
["l12_stancia"] = { group = 17, intensity = 1.0 },
["l12_stancia_2"] = { group = 25, intensity = 1.0 },
["l12u_control_monolith"] = { group = 14, intensity = 1.0 },
["l12u_sarcofag"] = { group = 14, intensity = 1.0 },
["l13_generators"] = { group = 20, intensity = 1.0 },
["l13u_warlab"] = { group = 14, intensity = 1.0 },
["labx8"] = { group = 14, intensity = 1.0 },
["pripyat"] = { group = 18, intensity = 1.0 },
["zaton"] = { group = 21, intensity = 1 },
["y04_pole"] = { group = 30, intensity = 1.0 },
["bunker_a1"] = { group = 14, intensity = 1.0 },
}
local function ssfx_lut_transition()
get_console():execute("ssfx_lut (" .. ssfx_lut_int .. "," .. ssfx_lut_group1 .. "," .. ssfx_lut_group2 .. "," .. ssfx_lut_lerp .. ")")
end
function ssfx_lut_diminish()
-- Frame independent smoothing
local smoothing = math.min(ssfx_lut_transition_speed * device().time_delta / 20, 0.19)
-- Let's go!
if (ssfx_lut_lerp < ssfx_lut_lerp_target) then
ssfx_lut_lerp = ssfx_lut_lerp + smoothing
else
ssfx_lut_lerp = ssfx_lut_lerp - smoothing
end
if math.abs(ssfx_lut_lerp - ssfx_lut_lerp_target) <= ssfx_lut_transition_speed then
ssfx_lut_group1 = ssfx_lut_group2
ssfx_lut_group2 = 0
ssfx_lut_lerp = 0
ssfx_lut_lerp_target = 0
ssfx_lut_lerp_done = true
end
end
function ssfx_lut_change(group, insta)
if (ssfx_lut_lerp_done == false) then return end
if (insta == true) then
ssfx_lut_group1 = group
ssfx_lut_lerp = 0
ssfx_lut_lerp_target = 0
ssfx_lut_lerp_done = true
ssfx_lut_transition()
else
ssfx_lut_group2 = group
ssfx_lut_lerp_target = 1
ssfx_lut_lerp_done = false
end
end
-- DEBUG
local function ssfx_on_key_press(dik)
local bind = dik_to_bind(dik)
local kb = key_bindings
if bind == kb.kWPN_RELOAD then
DebugGroup = DebugGroup + 1
ssfx_lut_change(DebugGroup, false)
end
end
local function actor_on_update()
--local game_hours = level.get_time_hours()
--printf("LUT TIME : %s", game_hours)
if (ssfx_lut_lerp_done == false) then
ssfx_lut_diminish()
ssfx_lut_transition()
end
end
local function actor_on_first_update()
if (ssfx_maps[level.name()]) then
Map_LUT = ssfx_maps[level.name()].group or ssfx_lut_default.group
ssfx_lut_int = ssfx_maps[level.name()].intensity or ssfx_lut_default.intensity
else
Map_LUT = ssfx_lut_default.group
ssfx_lut_int = ssfx_lut_default.intensity
end
ssfx_lut_change(Map_LUT, true)
end
function on_option_change()
end
function on_game_start()
--RegisterScriptCallback("on_key_press", ssfx_on_key_press)
-- General Functions
RegisterScriptCallback("actor_on_first_update", actor_on_first_update)
RegisterScriptCallback("actor_on_update", actor_on_update)
RegisterScriptCallback("on_option_change", on_option_change)
-- Read and apply settigns
on_option_change()
end