Update most demos for Godot 4.0.beta10 (#782)

This commit is contained in:
Hugo Locurcio
2023-01-05 16:50:17 +01:00
committed by GitHub
parent 85ca2fb2a1
commit 1d5184e235
758 changed files with 24258 additions and 9624 deletions

View File

@@ -4,6 +4,7 @@ extends Control
# - Stretch mode is set to `canvas_items` (`2d` in Godot 3.x)
# - Stretch aspect is set to `expand`
@onready var world_environment := $WorldEnvironment
@onready var directional_light := $Node3D/DirectionalLight3D
@onready var camera := $Node3D/Camera3D
@onready var fps_label := $FPSLabel
@onready var resolution_label := $ResolutionLabel
@@ -18,7 +19,7 @@ var viewport_start_size := Vector2(
func _ready() -> void:
get_viewport().connect(&"size_changed", update_resolution_label)
get_viewport().size_changed.connect(self.update_resolution_label)
update_resolution_label()
# Disable V-Sync to uncap framerate on supported platforms. This makes performance comparison
@@ -46,6 +47,7 @@ func _on_HideShowButton_toggled(show_settings: bool) -> void:
button.text = "Show settings"
settings_menu.visible = show_settings
# Video settings.
func _on_ui_scale_option_button_item_selected(index: int) -> void:
# For changing the UI, we take the viewport size, which we set in the project settings.
@@ -54,7 +56,7 @@ func _on_ui_scale_option_button_item_selected(index: int) -> void:
new_size *= 1.5
elif index == 1: # Small (80%)
new_size *= 1.25
elif index == 2: # Medium (100%)
elif index == 2: # Medium (100%) (default)
new_size *= 1.0
elif index == 3: # Large (133%)
new_size *= 0.75
@@ -72,9 +74,18 @@ func _on_filter_option_button_item_selected(index: int) -> void:
# Viewport scale mode setting.
if index == 0: # Bilinear (Fastest)
get_viewport().scaling_3d_mode = Viewport.SCALING_3D_MODE_BILINEAR
# FSR Sharpness is only effective when the scaling mode is FSR 1.0.
%FSRSharpnessLabel.visible = false
%FSRSharpnessSlider.visible = false
elif index == 1: # FSR 1.0 (Fast)
push_warning("FSR is currently not working. The shader is run, but no visual difference appears on screen.")
get_viewport().scaling_3d_mode = Viewport.SCALING_3D_MODE_FSR
# FSR Sharpness is only effective when the scaling mode is FSR 1.0.
%FSRSharpnessLabel.visible = true
%FSRSharpnessSlider.visible = true
func _on_fsr_sharpness_slider_value_changed(value):
get_viewport().fsr_sharpness = value
func _on_vsync_option_button_item_selected(index: int) -> void:
@@ -84,7 +95,7 @@ func _on_vsync_option_button_item_selected(index: int) -> void:
# Adaptive V-Sync automatically disables V-Sync when the framerate target is not met, and enables
# V-Sync otherwise. This prevents suttering and reduces input latency when the framerate target
# is not met, at the cost of visible tearing.
if index == 0: # Disabled
if index == 0: # Disabled (default)
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
elif index == 1: # Adaptive
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ADAPTIVE)
@@ -92,21 +103,27 @@ func _on_vsync_option_button_item_selected(index: int) -> void:
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_ENABLED)
func _on_aa_option_button_item_selected(index: int) -> void:
func _on_msaa_option_button_item_selected(index: int) -> void:
# Multi-sample anti-aliasing. High quality, but slow. It also does not smooth out the edges of
# transparent (alpha scissor) textures.
if index == 0: # Disabled
get_viewport().msaa = Viewport.MSAA_DISABLED
if index == 0: # Disabled (default)
get_viewport().msaa_3d = Viewport.MSAA_DISABLED
elif index == 1: # 2×
get_viewport().msaa = Viewport.MSAA_2X
get_viewport().msaa_3d = Viewport.MSAA_2X
elif index == 2: # 4×
get_viewport().msaa = Viewport.MSAA_4X
get_viewport().msaa_3d = Viewport.MSAA_4X
elif index == 3: # 8×
get_viewport().msaa = Viewport.MSAA_8X
get_viewport().msaa_3d = Viewport.MSAA_8X
func _on_taa_option_button_item_selected(index: int) -> void:
# Temporal antialiasing. Smooths out everything including specular aliasing, but can introduce
# ghosting artifacts and blurring in motion. Moderate performance cost.
get_viewport().use_taa = index == 1
func _on_fxaa_option_button_item_selected(index: int) -> void:
# Fast approximate anti-aliasing. Much faster than FXAA (and works on alpha scissor edges),
# Fast approximate anti-aliasing. Much faster than MSAA (and works on alpha scissor edges),
# but blurs the whole scene rendering slightly.
get_viewport().screen_space_aa = index == 1
@@ -114,22 +131,93 @@ func _on_fxaa_option_button_item_selected(index: int) -> void:
func _on_fullscreen_option_button_item_selected(index: int) -> void:
# To change between winow, fullscreen and other window modes,
# set the root mode to one of the options of Window.MODE_*.
# other modes are maximized, minimized and exclusive fullscreen.
if index == 0:
# Other modes are maximized and minimized.
if index == 0: # Disabled (default)
get_tree().root.set_mode(Window.MODE_WINDOWED)
elif index == 1:
elif index == 1: # Fullscreen
get_tree().root.set_mode(Window.MODE_FULLSCREEN)
elif index == 2: # Exclusive Fullscreen
get_tree().root.set_mode(Window.MODE_EXCLUSIVE_FULLSCREEN)
func _on_fov_slider_value_changed(value: float) -> void:
camera.fov = value
# Quality settings.
func _on_shadow_size_option_button_item_selected(index):
if index == 0: # Minimum
RenderingServer.directional_shadow_atlas_set_size(512, true)
# Adjust shadow bias according to shadow resolution.
# Higher resultions can use a lower bias without suffering from shadow acne.
directional_light.shadow_bias = 0.06
# Disable positional (omni/spot) light shadows entirely to further improve performance.
# These often don't contribute as much to a scene compared to directional light shadows.
get_viewport().positional_shadow_atlas_size = 0
if index == 1: # Very Low
RenderingServer.directional_shadow_atlas_set_size(1024, true)
directional_light.shadow_bias = 0.04
get_viewport().positional_shadow_atlas_size = 1024
if index == 2: # Low
RenderingServer.directional_shadow_atlas_set_size(2048, true)
directional_light.shadow_bias = 0.03
get_viewport().positional_shadow_atlas_size = 2048
if index == 3: # Medium (default)
RenderingServer.directional_shadow_atlas_set_size(4096, true)
directional_light.shadow_bias = 0.02
get_viewport().positional_shadow_atlas_size = 4096
if index == 4: # High
RenderingServer.directional_shadow_atlas_set_size(8192, true)
directional_light.shadow_bias = 0.01
get_viewport().positional_shadow_atlas_size = 8192
if index == 5: # Ultra
RenderingServer.directional_shadow_atlas_set_size(16384, true)
directional_light.shadow_bias = 0.005
get_viewport().positional_shadow_atlas_size = 16384
func _on_shadow_filter_option_button_item_selected(index):
if index == 0: # Very Low
RenderingServer.directional_soft_shadow_filter_set_quality(RenderingServer.SHADOW_QUALITY_HARD)
RenderingServer.positional_soft_shadow_filter_set_quality(RenderingServer.SHADOW_QUALITY_HARD)
if index == 1: # Low
RenderingServer.directional_soft_shadow_filter_set_quality(RenderingServer.SHADOW_QUALITY_SOFT_VERY_LOW)
RenderingServer.positional_soft_shadow_filter_set_quality(RenderingServer.SHADOW_QUALITY_SOFT_VERY_LOW)
if index == 2: # Medium (default)
RenderingServer.directional_soft_shadow_filter_set_quality(RenderingServer.SHADOW_QUALITY_SOFT_LOW)
RenderingServer.positional_soft_shadow_filter_set_quality(RenderingServer.SHADOW_QUALITY_SOFT_LOW)
if index == 3: # High
RenderingServer.directional_soft_shadow_filter_set_quality(RenderingServer.SHADOW_QUALITY_SOFT_MEDIUM)
RenderingServer.positional_soft_shadow_filter_set_quality(RenderingServer.SHADOW_QUALITY_SOFT_MEDIUM)
if index == 4: # Very High
RenderingServer.directional_soft_shadow_filter_set_quality(RenderingServer.SHADOW_QUALITY_SOFT_HIGH)
RenderingServer.positional_soft_shadow_filter_set_quality(RenderingServer.SHADOW_QUALITY_SOFT_HIGH)
if index == 5: # Ultra
RenderingServer.directional_soft_shadow_filter_set_quality(RenderingServer.SHADOW_QUALITY_SOFT_ULTRA)
RenderingServer.positional_soft_shadow_filter_set_quality(RenderingServer.SHADOW_QUALITY_SOFT_ULTRA)
func _on_mesh_lod_option_button_item_selected(index):
if index == 0: # Very Low
get_viewport().mesh_lod_threshold = 8.0
if index == 0: # Low
get_viewport().mesh_lod_threshold = 4.0
if index == 1: # Medium
get_viewport().mesh_lod_threshold = 2.0
if index == 2: # High (default)
get_viewport().mesh_lod_threshold = 1.0
if index == 3: # Ultra
# Always use highest LODs to avoid any form of pop-in.
get_viewport().mesh_lod_threshold = 0.0
# Effect settings.
func _on_ss_reflections_option_button_item_selected(index: int) -> void:
# This is a setting that is attached to the environment.
# If your game requires you to change the environment,
# then be sure to run this function again to set the settings correct.
if index == 0: # Disabled
# then be sure to run this function again to make the setting effective.
if index == 0: # Disabled (default)
world_environment.environment.set_ssr_enabled(false)
elif index == 1: # Low
world_environment.environment.set_ssr_enabled(true)
@@ -145,8 +233,8 @@ func _on_ss_reflections_option_button_item_selected(index: int) -> void:
func _on_ssao_option_button_item_selected(index: int) -> void:
# This is a setting that is attached to the environment.
# If your game requires you to change the environment,
# then be sure to run this function again to set the settings correct.
if index == 0: # Disabled
# then be sure to run this function again to make the setting effective.
if index == 0: # Disabled (default)
world_environment.environment.ssao_enabled = false
if index == 1: # Very Low
world_environment.environment.ssao_enabled = true
@@ -165,8 +253,8 @@ func _on_ssao_option_button_item_selected(index: int) -> void:
func _on_ssil_option_button_item_selected(index: int) -> void:
# This is a setting that is attached to the environment.
# If your game requires you to change the environment,
# then be sure to run this function again to set the settings correct.
if index == 0: # Disabled
# then be sure to run this function again to make the setting effective.
if index == 0: # Disabled (default)
world_environment.environment.ssil_enabled = false
if index == 1: # Very Low
world_environment.environment.ssil_enabled = true
@@ -185,8 +273,8 @@ func _on_ssil_option_button_item_selected(index: int) -> void:
func _on_sdfgi_option_button_item_selected(index: int) -> void:
# This is a setting that is attached to the environment.
# If your game requires you to change the environment,
# then be sure to run this function again to set the settings correct.
if index == 0: # Disabled
# then be sure to run this function again to make the setting effective.
if index == 0: # Disabled (default)
world_environment.environment.sdfgi_enabled = false
if index == 1: # Low
world_environment.environment.sdfgi_enabled = true
@@ -199,8 +287,8 @@ func _on_sdfgi_option_button_item_selected(index: int) -> void:
func _on_glow_option_button_item_selected(index: int) -> void:
# This is a setting that is attached to the environment.
# If your game requires you to change the environment,
# then be sure to run this function again to set the settings correct.
if index == 0: # Disabled
# then be sure to run this function again to make the setting effective.
if index == 0: # Disabled (default)
world_environment.environment.glow_enabled = false
if index == 1: # Low
world_environment.environment.glow_enabled = true
@@ -211,7 +299,7 @@ func _on_glow_option_button_item_selected(index: int) -> void:
func _on_volumetric_fog_option_button_item_selected(index: int) -> void:
if index == 0: # Disabled
if index == 0: # Disabled (default)
world_environment.environment.volumetric_fog_enabled = false
if index == 1: # Low
world_environment.environment.volumetric_fog_enabled = true
@@ -220,26 +308,117 @@ func _on_volumetric_fog_option_button_item_selected(index: int) -> void:
world_environment.environment.volumetric_fog_enabled = true
RenderingServer.environment_set_volumetric_fog_filter_active(true)
# Adjustment settings.
func _on_brightness_slider_value_changed(value: float) -> void:
# This is a setting that is attached to the environment.
# If your game requires you to change the environment,
# then be sure to run this function again to set the settings correct.
# The slider value is clammed between 0.5 and 4.
# then be sure to run this function again to make the setting effective.
# The slider value is clamped between 0.5 and 4.
world_environment.environment.set_adjustment_brightness(value)
func _on_contrast_slider_value_changed(value: float) -> void:
# This is a setting that is attached to the environment.
# If your game requires you to change the environment,
# then be sure to run this function again to set the settings correct.
# The slider value is clammed between 0.5 and 4.
# then be sure to run this function again to make the setting effective.
# The slider value is clamped between 0.5 and 4.
world_environment.environment.set_adjustment_contrast(value)
func _on_saturation_slider_value_changed(value: float) -> void:
# This is a setting that is attached to the environment.
# If your game requires you to change the environment,
# then be sure to run this function again to set the settings correct.
# The slider value is clammed between 0.5 and 10.
# then be sure to run this function again to make the setting effective.
# The slider value is clamped between 0.5 and 10.
world_environment.environment.set_adjustment_saturation(value)
# Quality presets.
func _on_very_low_preset_pressed() -> void:
%TAAOptionButton.selected = 0
%MSAAOptionButton.selected = 0
%ShadowSizeOptionButton.selected = 0
%ShadowFilterOptionButton.selected = 0
%MeshLODOptionButton.selected = 0
%SDFGIOptionButton.selected = 0
%GlowOptionButton.selected = 0
%SSAOOptionButton.selected = 0
%SSReflectionsOptionButton.selected = 0
%SSILOptionButton.selected = 0
%VolumetricFogOptionButton.selected = 0
update_preset()
func _on_low_preset_pressed() -> void:
%TAAOptionButton.selected = 0
%MSAAOptionButton.selected = 1
%ShadowSizeOptionButton.selected = 1
%ShadowFilterOptionButton.selected = 1
%MeshLODOptionButton.selected = 1
%SDFGIOptionButton.selected = 0
%GlowOptionButton.selected = 0
%SSAOOptionButton.selected = 0
%SSReflectionsOptionButton.selected = 0
%SSILOptionButton.selected = 0
%VolumetricFogOptionButton.selected = 0
update_preset()
func _on_medium_preset_pressed() -> void:
%TAAOptionButton.selected = 1
%MSAAOptionButton.selected = 0
%ShadowSizeOptionButton.selected = 2
%ShadowFilterOptionButton.selected = 2
%MeshLODOptionButton.selected = 1
%SDFGIOptionButton.selected = 1
%GlowOptionButton.selected = 1
%SSAOOptionButton.selected = 1
%SSReflectionsOptionButton.selected = 1
%SSILOptionButton.selected = 0
%VolumetricFogOptionButton.selected = 1
update_preset()
func _on_high_preset_pressed() -> void:
%TAAOptionButton.selected = 1
%MSAAOptionButton.selected = 0
%ShadowSizeOptionButton.selected = 3
%ShadowFilterOptionButton.selected = 3
%MeshLODOptionButton.selected = 2
%SDFGIOptionButton.selected = 1
%GlowOptionButton.selected = 2
%SSAOOptionButton.selected = 2
%SSReflectionsOptionButton.selected = 2
%SSILOptionButton.selected = 2
%VolumetricFogOptionButton.selected = 2
update_preset()
func _on_ultra_preset_pressed() -> void:
%TAAOptionButton.selected = 1
%MSAAOptionButton.selected = 1
%ShadowSizeOptionButton.selected = 4
%ShadowFilterOptionButton.selected = 4
%MeshLODOptionButton.selected = 3
%SDFGIOptionButton.selected = 2
%GlowOptionButton.selected = 2
%SSAOOptionButton.selected = 3
%SSReflectionsOptionButton.selected = 3
%SSILOptionButton.selected = 3
%VolumetricFogOptionButton.selected = 2
update_preset()
func update_preset() -> void:
# Simulate options being manually selected to run their respective update code.
%TAAOptionButton.emit_signal("item_selected", %TAAOptionButton.selected)
%MSAAOptionButton.emit_signal("item_selected", %MSAAOptionButton.selected)
%ShadowSizeOptionButton.emit_signal("item_selected", %ShadowSizeOptionButton.selected)
%ShadowFilterOptionButton.emit_signal("item_selected", %ShadowFilterOptionButton.selected)
%MeshLODOptionButton.emit_signal("item_selected", %MeshLODOptionButton.selected)
%SDFGIOptionButton.emit_signal("item_selected", %SDFGIOptionButton.selected)
%GlowOptionButton.emit_signal("item_selected", %GlowOptionButton.selected)
%SSAOOptionButton.emit_signal("item_selected", %SSAOOptionButton.selected)
%SSReflectionsOptionButton.emit_signal("item_selected", %SSReflectionsOptionButton.selected)
%SSILOptionButton.emit_signal("item_selected", %SSILOptionButton.selected)
%VolumetricFogOptionButton.emit_signal("item_selected", %VolumetricFogOptionButton.selected)