change 'graphics.ssao' from flag to number

This commit is contained in:
MihailRis 2025-12-19 18:55:55 +03:00
parent 837f49e736
commit 58dee92c26
5 changed files with 21 additions and 10 deletions

View file

@ -44,6 +44,6 @@ function on_open()
create_checkbox("graphics.soft-lighting", "Soft lighting", "graphics.soft-lighting.tooltip")
create_checkbox("graphics.dense-render", "Dense blocks render", "graphics.dense-render.tooltip")
create_checkbox("graphics.advanced-render", "Advanced render", "graphics.advanced-render.tooltip")
create_checkbox("graphics.ssao", "SSAO", "graphics.ssao.tooltip")
create_setting("graphics.ssao", "SSAO", 1, "", "graphics.ssao.tooltip")
create_setting("graphics.shadows-quality", "Shadows quality", 1)
end

View file

@ -6,6 +6,7 @@
"cinematic"
],
"post-effect-slot": [
"default"
"default",
"ssao"
]
}

View file

@ -1,6 +1,6 @@
local function configure_SSAO()
-- Temporary using slot to configure built-in SSAO effect
local slot = gfx.posteffects.index("core:default")
local slot = gfx.posteffects.index("core:ssao")
gfx.posteffects.set_effect(slot, "ssao")
-- Generating random SSAO samples
@ -18,8 +18,18 @@ local function configure_SSAO()
Bytearray.append(buffer, byteutil.pack("fff", x, y, z))
end
gfx.posteffects.set_array(slot, "u_ssaoSamples", Bytearray_as_string(buffer))
-- SSAO effect configured, so 'core:default' slot may be reused now
-- for test purposes
local function update_ssao_quality(value)
value = math.min(value, 3)
gfx.posteffects.set_params(slot, {
u_kernelSize = value * 16,
u_radius = 0.4 / value,
u_bias = 0.006 / value / value,
})
end
events.on("core:setting.graphics.ssao.set", update_ssao_quality)
update_ssao_quality(core.get_setting("graphics.ssao"))
end
local function update_hand()

View file

@ -1,7 +1,7 @@
#param vec3 u_ssaoSamples[64]
#param int u_kernelSize = 16
#param float u_radius = 0.4
#param float u_bias = 0.006
#param int u_kernelSize = 32
#param float u_radius = 0.2
#param float u_bias = 0.001
vec4 effect() {
vec2 noiseScale = u_screenSize / 4.0;