Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mobile-optimized settings and controls #183

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions menu/menu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,17 @@ func _ready():
]:
_make_button_group(menu)

if Settings.is_mobile:
# Hide settings that are not effective or relevant on mobile platforms.
for menu in [
display_mode_menu, vsync_menu, scale_filter_menu, taa_menu, gi_type_menu, gi_quality_menu,
ssao_menu, ssil_menu, volumetric_fog_menu,
]:
menu.visible = false

# Mobile GPUs only support MSAA up to 4×.
msaa_8x.visible = false

func _process(_delta):
if loading.visible:
var progress = []
Expand Down
25 changes: 13 additions & 12 deletions menu/settings.gd
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,32 @@ enum GIQuality {

const CONFIG_FILE_PATH = "user://settings.ini"

const DEFAULTS = {
var is_mobile := OS.has_feature("mobile")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be:

Suggested change
var is_mobile := OS.has_feature("mobile")
var is_mobile: bool = ProjectSettings.get_setting("rendering/renderer/rendering_method") == "mobile"

(Had to make type hint explicit, somehow it wouldn't infer from the == check that it would be a bool.)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even with this, I still get this error once when playing the project:

ERROR: FSR2 is only available when using the Forward+ renderer.
   at: viewport_set_scaling_3d_mode (servers/rendering/renderer_viewport.cpp:867)

And it's spammed a lot of times in the editor when using the mobile backend on PC.

Copy link
Member

@akien-mga akien-mga Jan 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then this shouldn't be used to handle the mobile controls though - but from what I see in the code currently it doesn't seem to be the case. Maybe is_mobile_renderer might prevent misuse.


var defaults := {
video = {
display_mode = Window.MODE_EXCLUSIVE_FULLSCREEN,
vsync = DisplayServer.VSYNC_ENABLED,
max_fps = 0,
resolution_scale = 1.0,
scale_filter = Viewport.SCALING_3D_MODE_FSR2,
max_fps = 0 if not is_mobile else 30, # Cap to 30 FPS on mobile to ensure consistency and reduce power consumption
resolution_scale = 1.0 if not is_mobile else 0.5, # Native on desktop, Performance on mobile
scale_filter = Viewport.SCALING_3D_MODE_FSR2 if not is_mobile else Viewport.SCALING_3D_MODE_BILINEAR,
},
rendering = {
taa = false,
msaa = Viewport.MSAA_DISABLED,
fxaa = false,
fxaa = is_mobile,
shadow_mapping = true,
gi_type = GIType.VOXEL_GI,
gi_quality = GIQuality.LOW,
ssao_quality = RenderingServer.ENV_SSAO_QUALITY_MEDIUM,
gi_quality = GIQuality.LOW if not is_mobile else GIQuality.DISABLED,
ssao_quality = RenderingServer.ENV_SSAO_QUALITY_MEDIUM if not is_mobile else -1, # Disabled on mobile
ssil_quality = -1, # Disabled
bloom = true,
volumetric_fog = true,
volumetric_fog = not is_mobile,
},
}

var config_file := ConfigFile.new()


func _ready():
load_settings()

Expand All @@ -53,10 +54,10 @@ func load_settings():
config_file.load(CONFIG_FILE_PATH)
# Initialize defaults for values not found in the existing configuration file,
# so we don't have to specify them every time we use `ConfigFile.get_value()`.
for section in DEFAULTS:
for key in DEFAULTS[section]:
for section in defaults:
for key in defaults[section]:
if not config_file.has_section_key(section, key):
config_file.set_value(section, key, DEFAULTS[section][key])
config_file.set_value(section, key, defaults[section][key])


func save_settings():
Expand Down
Loading