H2: Graphics presets, OpenGL fallback notice, tested configurations
Presets now tune shadows, cascades, render scale and anti-aliasing: Low (no shadows, 75%, FXAA), Medium (200 m, 2 cascades, FXAA), High (400 m, 4 cascades, MSAA 2x). GameSettings.apply_to_viewport sets the viewport; MatchView.apply_settings sets the sun's cascades. No preset changes how far props or pieces are drawn, so a lower one never shows a player through cover; a test guards it. When Vulkan can't start, Godot falls back to OpenGL (fallback_to_opengl3) and RendererCheck has the main menu say so. tools/capture.sh gains CAPTURE_RENDERER=no_vulkan, which hides the Vulkan driver and expects the fallback. New scenarios quality_low/medium/high draw a match moment with each preset, reviewed in both renderers. docs/PLAY.md lists the presets, renderers, Wayland and hybrid-GPU notes, and the tested configurations, marking each as software-rendered only or not tested. Closes #55 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -13,6 +13,8 @@ const PLAYER: int = 1
|
||||
|
||||
@export var log_path: String = "res://build/match/match.tclog"
|
||||
@export var stage: String = "lobby"
|
||||
## H2: a GameSettings quality preset to draw with (-1: the view's defaults).
|
||||
@export var quality: int = -1
|
||||
|
||||
var _replay: MatchReplay
|
||||
var _view: MatchView
|
||||
@@ -55,6 +57,11 @@ func _ready() -> void:
|
||||
_view = MatchView.new()
|
||||
_view.setup(sim, player_id)
|
||||
add_child(_view)
|
||||
if quality >= 0:
|
||||
var settings: GameSettings = GameSettings.new()
|
||||
settings.quality = quality
|
||||
settings.apply_to_viewport(get_viewport())
|
||||
_view.apply_settings(settings)
|
||||
var watched: int = _watched()
|
||||
var who: String = "nobody"
|
||||
if stage == "lobby" or stage == "tide":
|
||||
@@ -79,7 +86,7 @@ func _ready() -> void:
|
||||
else:
|
||||
_view.overview()
|
||||
_view.settle()
|
||||
_caption(_describe(who))
|
||||
_caption(_describe(who) + ("" if quality < 0 else "\nquality: %s, renderer: %s" % [GameSettings.QUALITY_NAMES[quality], RenderingServer.get_current_rendering_method()]))
|
||||
|
||||
|
||||
func _player() -> SimEntity:
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/match_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureQuality" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
stage = "landed"
|
||||
quality = 2
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/match_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureQuality" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
stage = "landed"
|
||||
quality = 0
|
||||
@@ -0,0 +1,8 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/match_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureQuality" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
stage = "landed"
|
||||
quality = 1
|
||||
@@ -128,3 +128,64 @@ func _assert_defaults(loaded: GameSettings) -> void:
|
||||
assert_eq(loaded.mouse.mouse_sensitivity, fresh.mouse.mouse_sensitivity)
|
||||
for action: Dictionary in KeyBindings.ACTIONS:
|
||||
assert_eq(loaded.bindings.code_of(action["id"]), int(action["default"]))
|
||||
|
||||
|
||||
func test_presets_rise_from_low_to_high() -> void:
|
||||
var settings: GameSettings = GameSettings.new()
|
||||
var previous: Dictionary = {}
|
||||
for quality: int in GameSettings.QUALITY_NAMES.size():
|
||||
settings.quality = quality
|
||||
var preset: Dictionary = GameSettings.QUALITY[quality]
|
||||
assert_true([1, 2, 4].has(settings.shadow_splits()), "%s has 1, 2 or 4 shadow splits" % GameSettings.QUALITY_NAMES[quality])
|
||||
assert_true(preset["msaa"] == Viewport.MSAA_DISABLED or not preset["fxaa"], "no preset pays for both MSAA and FXAA")
|
||||
if not previous.is_empty():
|
||||
assert_true(float(preset["shadow_distance"]) >= float(previous["shadow_distance"]))
|
||||
assert_true(int(preset["shadow_splits"]) >= int(previous["shadow_splits"]))
|
||||
assert_true(float(preset["render_scale"]) >= float(previous["render_scale"]))
|
||||
previous = preset
|
||||
settings.quality = GameSettings.QUALITY_HIGH
|
||||
assert_eq(settings.shadow_splits(), 4)
|
||||
|
||||
|
||||
func test_a_preset_sets_the_viewport_and_the_sun() -> void:
|
||||
var viewport: SubViewport = SubViewport.new()
|
||||
var settings: GameSettings = GameSettings.new()
|
||||
settings.quality = GameSettings.QUALITY_LOW
|
||||
settings.apply_to_viewport(viewport)
|
||||
assert_near(viewport.scaling_3d_scale, 0.75, 0.001)
|
||||
assert_eq(viewport.msaa_3d, Viewport.MSAA_DISABLED)
|
||||
assert_eq(viewport.screen_space_aa, Viewport.SCREEN_SPACE_AA_FXAA)
|
||||
settings.quality = GameSettings.QUALITY_HIGH
|
||||
settings.apply_to_viewport(viewport)
|
||||
assert_near(viewport.scaling_3d_scale, 1.0, 0.001)
|
||||
assert_eq(viewport.msaa_3d, Viewport.MSAA_2X)
|
||||
assert_eq(viewport.screen_space_aa, Viewport.SCREEN_SPACE_AA_DISABLED)
|
||||
viewport.free()
|
||||
var view: MatchView = MatchView.new()
|
||||
view.sun = Look.sun()
|
||||
view.add_child(view.sun)
|
||||
settings.quality = GameSettings.QUALITY_MEDIUM
|
||||
view.apply_settings(settings)
|
||||
assert_true(view.sun.shadow_enabled)
|
||||
assert_eq(view.sun.directional_shadow_mode, DirectionalLight3D.SHADOW_PARALLEL_2_SPLITS)
|
||||
settings.quality = GameSettings.QUALITY_LOW
|
||||
view.apply_settings(settings)
|
||||
assert_false(view.sun.shadow_enabled, "low has no shadows")
|
||||
view.free()
|
||||
|
||||
|
||||
func test_presets_never_change_how_far_cover_is_drawn() -> void:
|
||||
# A lower preset must never let a player see through trees and rocks it stopped
|
||||
# drawing: nothing about props is in the presets.
|
||||
for preset: Dictionary in GameSettings.QUALITY:
|
||||
for key: String in preset:
|
||||
assert_false(key.contains("range") or key.contains("detail") or (key.contains("distance") and key != "shadow_distance"), "preset key %s" % key)
|
||||
|
||||
|
||||
func test_renderer_fallback_notice() -> void:
|
||||
var none: PackedStringArray = PackedStringArray()
|
||||
assert_eq(RendererCheck.notice_for("forward_plus", "forward_plus", none), "", "the renderer asked for")
|
||||
assert_eq(RendererCheck.notice_for("forward_plus", "gl_compatibility", none), RendererCheck.NOTICE, "fell back to OpenGL")
|
||||
assert_eq(RendererCheck.notice_for("forward_plus", "gl_compatibility", PackedStringArray(["--rendering-method", "gl_compatibility"])), "", "the player chose OpenGL")
|
||||
assert_eq(RendererCheck.notice_for("forward_plus", "gl_compatibility", PackedStringArray(["--rendering-driver=opengl3"])), "", "the player chose OpenGL")
|
||||
assert_eq(RendererCheck.fallback_notice(), "", "nothing to say headless")
|
||||
|
||||
Reference in New Issue
Block a user