Divergent/mods/Shaders Look Better/gamedata/scripts/fps_based_mblur.script

41 lines
1.1 KiB
Plaintext
Raw Normal View History

local BASE_MBLUR_MAX = 10
local CALLBACK_REGISTERED = true
local ENABLED
local BASE_MBLUR
local CACHE
local print_dbg = fps_based_mblur_mcm.print_dbg
local get_config = fps_based_mblur_mcm.get_config
function load_settings()
ENABLED = get_config("ENABLED")
BASE_MBLUR = get_config("BASE_MBLUR")
CACHE = 1 / 50 * BASE_MBLUR / BASE_MBLUR_MAX
if ENABLED and not CALLBACK_REGISTERED then
RegisterScriptCallback("actor_on_update", actor_on_update)
CALLBACK_REGISTERED = true
elseif not ENABLED and CALLBACK_REGISTERED then
UnregisterScriptCallback("actor_on_update", actor_on_update)
CALLBACK_REGISTERED = false
get_console():execute("r2_mblur " .. BASE_MBLUR / BASE_MBLUR_MAX)
end
end
function actor_on_update()
local delta = device().f_time_delta
print_dbg("delta: %s", delta)
print_dbg("not clamped amount: %s", CACHE / delta)
get_console():execute("r2_mblur " .. clamp(CACHE / delta, 0, 1))
end
function on_game_start()
RegisterScriptCallback("on_option_change", load_settings)
RegisterScriptCallback("actor_on_first_update", load_settings)
RegisterScriptCallback("actor_on_update", actor_on_update)
end