diff options
author | Liso <anlismon@gmail.com> | 2021-06-06 18:51:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-06 18:51:21 +0200 |
commit | c47313db65f968559711ac1b505ef341a9872017 (patch) | |
tree | 63d9b1b2be512918e2361d96e4fb52ff1ec3f9de /builtin/mainmenu | |
parent | 46f42e15c41cf4ab23c5ff4cd8a7d99d94d10d7b (diff) | |
download | minetest-c47313db65f968559711ac1b505ef341a9872017.tar.gz minetest-c47313db65f968559711ac1b505ef341a9872017.tar.bz2 minetest-c47313db65f968559711ac1b505ef341a9872017.zip |
Shadow mapping render pass (#11244)
Co-authored-by: x2048 <codeforsmile@gmail.com>
Diffstat (limited to 'builtin/mainmenu')
-rw-r--r-- | builtin/mainmenu/tab_settings.lua | 58 |
1 files changed, 56 insertions, 2 deletions
diff --git a/builtin/mainmenu/tab_settings.lua b/builtin/mainmenu/tab_settings.lua index 29744048a..8bc5bf8b6 100644 --- a/builtin/mainmenu/tab_settings.lua +++ b/builtin/mainmenu/tab_settings.lua @@ -43,6 +43,14 @@ local labels = { fgettext("2x"), fgettext("4x"), fgettext("8x") + }, + shadow_levels = { + fgettext("Disabled"), + fgettext("Very Low"), + fgettext("Low"), + fgettext("Medium"), + fgettext("High"), + fgettext("Ultra High") } } @@ -66,6 +74,10 @@ local dd_options = { antialiasing = { table.concat(labels.antialiasing, ","), {"0", "2", "4", "8"} + }, + shadow_levels = { + table.concat(labels.shadow_levels, ","), + { "0", "1", "2", "3", "4", "5" } } } @@ -110,6 +122,15 @@ local getSettingIndex = { end end return 1 + end, + ShadowMapping = function() + local shadow_setting = core.settings:get("shadow_levels") + for i = 1, #dd_options.shadow_levels[2] do + if shadow_setting == dd_options.shadow_levels[2][i] then + return i + end + end + return 1 end } @@ -197,7 +218,10 @@ local function formspec(tabview, name, tabdata) "checkbox[8.25,1.5;cb_waving_leaves;" .. fgettext("Waving Leaves") .. ";" .. dump(core.settings:get_bool("enable_waving_leaves")) .. "]" .. "checkbox[8.25,2;cb_waving_plants;" .. fgettext("Waving Plants") .. ";" - .. dump(core.settings:get_bool("enable_waving_plants")) .. "]" + .. dump(core.settings:get_bool("enable_waving_plants")) .. "]".. + "label[8.25,3.0;" .. fgettext("Dynamic shadows: ") .. "]" .. + "dropdown[8.25,3.5;3.5;dd_shadows;" .. dd_options.shadow_levels[1] .. ";" + .. getSettingIndex.ShadowMapping() .. "]" else tab_string = tab_string .. "label[8.38,0.7;" .. core.colorize("#888888", @@ -207,7 +231,9 @@ local function formspec(tabview, name, tabdata) "label[8.38,1.7;" .. core.colorize("#888888", fgettext("Waving Leaves")) .. "]" .. "label[8.38,2.2;" .. core.colorize("#888888", - fgettext("Waving Plants")) .. "]" + fgettext("Waving Plants")) .. "]".. + "label[8.38,2.7;" .. core.colorize("#888888", + fgettext("Dynamic shadows")) .. "]" end return tab_string @@ -333,6 +359,34 @@ local function handle_settings_buttons(this, fields, tabname, tabdata) ddhandled = true end + for i = 1, #labels.shadow_levels do + if fields["dd_shadows"] == labels.shadow_levels[i] then + core.settings:set("shadow_levels", dd_options.shadow_levels[2][i]) + ddhandled = true + end + end + + if fields["dd_shadows"] == labels.shadow_levels[1] then + core.settings:set("enable_dynamic_shadows", "false") + else + core.settings:set("enable_dynamic_shadows", "true") + local shadow_presets = { + [2] = { 80, 512, "true", 0, "false" }, + [3] = { 120, 1024, "true", 1, "false" }, + [4] = { 350, 2048, "true", 1, "false" }, + [5] = { 350, 2048, "true", 2, "true" }, + [6] = { 450, 4096, "true", 2, "true" }, + } + local s = shadow_presets[table.indexof(labels.shadow_levels, fields["dd_shadows"])] + if s then + core.settings:set("shadow_map_max_distance", s[1]) + core.settings:set("shadow_map_texture_size", s[2]) + core.settings:set("shadow_map_texture_32bit", s[3]) + core.settings:set("shadow_filters", s[4]) + core.settings:set("shadow_map_color", s[5]) + end + end + return ddhandled end |