H14: No sun shadows under the OpenGL fallback

Godot's Compatibility renderer draws a shadowed directional light in a
pass of its own and adds it after the frame is in sRGB, so sunlit pixels
come out as srgb(ambient) + srgb(sun) (measured to within 1/255 on
llvmpipe) and ground and rocks wash out. No environment or project
setting avoids it, so Look.sun_shadows_supported() is false under
gl_compatibility and the sun casts no shadows there on any preset.

Adds the sun_probe and sun_shadow_probe capture scenarios to recheck
after an engine upgrade, a test, and the explanation in PLAY.md and the
README.

Closes #81

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-14 20:28:31 -05:00
co-authored by Claude Opus 5.5
parent 358234d246
commit 8710c099b3
9 changed files with 106 additions and 8 deletions
+1 -1
View File
@@ -32,7 +32,7 @@ All of this is checked headless or with **software rendering in a container**. N
- **Bots don't build** ([#29](https://gitea.eom.dev/claude/tidewall/issues/29)), and most of them fall early in a match ([#74](https://gitea.eom.dev/claude/tidewall/issues/74)). - **Bots don't build** ([#29](https://gitea.eom.dev/claude/tidewall/issues/29)), and most of them fall early in a match ([#74](https://gitea.eom.dev/claude/tidewall/issues/74)).
- **No gamepad support or tutorial** ([#53](https://gitea.eom.dev/claude/tidewall/issues/53), [#52](https://gitea.eom.dev/claude/tidewall/issues/52)). No character customization ([#43](https://gitea.eom.dev/claude/tidewall/issues/43)) or editing of placed pieces ([#18](https://gitea.eom.dev/claude/tidewall/issues/18)). - **No gamepad support or tutorial** ([#53](https://gitea.eom.dev/claude/tidewall/issues/53), [#52](https://gitea.eom.dev/claude/tidewall/issues/52)). No character customization ([#43](https://gitea.eom.dev/claude/tidewall/issues/43)) or editing of placed pieces ([#18](https://gitea.eom.dev/claude/tidewall/issues/18)).
- **The Join menu only searches the LAN** ([#82](https://gitea.eom.dev/claude/tidewall/issues/82)). List servers work from the command line (`--browse --list=...`); in the menu, join other servers by address. - **The Join menu only searches the LAN** ([#82](https://gitea.eom.dev/claude/tidewall/issues/82)). List servers work from the command line (`--browse --list=...`); in the menu, join other servers by address.
- Under OpenGL with shadows on, ground and rocks look paler than under Vulkan ([#81](https://gitea.eom.dev/claude/tidewall/issues/81)). - Under OpenGL (the fallback when Vulkan can't start) the sun casts no shadows, because that renderer drew them with washed-out colours ([#81](https://gitea.eom.dev/claude/tidewall/issues/81)).
- One network soak saw a single transient world-hash mismatch that hasn't been reproduced since ([#80](https://gitea.eom.dev/claude/tidewall/issues/80)). - One network soak saw a single transient world-hash mismatch that hasn't been reproduced since ([#80](https://gitea.eom.dev/claude/tidewall/issues/80)).
- The name is a working name until it has been cleared. - The name is a working name until it has been cleared.
+9 -4
View File
@@ -134,7 +134,7 @@ Settings → Graphics → Quality.
| Preset | Sun shadows | Shadow cascades | 3D resolution | Anti-aliasing | Effect particles | | Preset | Sun shadows | Shadow cascades | 3D resolution | Anti-aliasing | Effect particles |
|---|---|---|---|---|---| |---|---|---|---|---|---|
| Low | Off | n/a | 75% of the window | FXAA | 256 at once | | Low | Off (and off on every preset under OpenGL) | n/a | 75% of the window | FXAA | 256 at once |
| Medium | Up to 200 m | 2 | 100% | FXAA | 512 | | Medium | Up to 200 m | 2 | 100% | FXAA | 512 |
| High (default) | Up to 400 m | 4 | 100% | MSAA 2x | 1,024 | | High (default) | Up to 400 m | 4 | 100% | MSAA 2x | 1,024 |
@@ -154,8 +154,13 @@ Tidewall is made for Godot's **Forward+** renderer on **Vulkan**. If Vulkan can'
(no Vulkan driver, or a GPU too old for it), the game falls back to **OpenGL** (no Vulkan driver, or a GPU too old for it), the game falls back to **OpenGL**
(Godot's Compatibility renderer) rather than crashing. The main menu then says so in (Godot's Compatibility renderer) rather than crashing. The main menu then says so in
red under the motto. Everything works there, but the light, fog and sea look a little red under the motto. Everything works there, but the light, fog and sea look a little
different. Known difference: with shadows on (Medium, High) the ground and rocks come different. **Under OpenGL the sun casts no shadows, on every preset** (the presets'
out paler under OpenGL than under Vulkan (issue #81). other settings still apply). Godot's Compatibility renderer draws a shadowed sun in
a pass of its own and adds it to the picture after the picture is already converted
for the screen (sRGB), so sunlit ground and rocks came out pale and washed out
(issue #81). No setting in the engine avoids that, so the game turns those shadows
off rather than show wrong colours. The `sun_probe` and `sun_shadow_probe` capture
scenarios show the difference, to recheck after an engine upgrade.
To choose a renderer yourself: To choose a renderer yourself:
@@ -187,7 +192,7 @@ is checked in the hands-on playtest (R6), and this table will be updated from it
| Configuration | Renderer | How it was tested | Result | | Configuration | Renderer | How it was tested | Result |
|---|---|---|---| |---|---|---|---|
| Debian 13, Xvfb (X11), Mesa Lavapipe | Forward+ / Vulkan | Software only: every capture, all three presets (`quality_*` captures) | Draws correctly | | Debian 13, Xvfb (X11), Mesa Lavapipe | Forward+ / Vulkan | Software only: every capture, all three presets (`quality_*` captures) | Draws correctly |
| Debian 13, Xvfb (X11), Mesa llvmpipe | Compatibility / OpenGL | Software only: all three presets | Draws correctly. Paler ground with shadows on (see above) | | Debian 13, Xvfb (X11), Mesa llvmpipe | Compatibility / OpenGL | Software only: all three presets | Draws correctly, with no sun shadows (see above) |
| Debian 13, Xvfb (X11), no Vulkan driver | Falls back to OpenGL | Software only: `CAPTURE_RENDERER=no_vulkan` capture of the main menu | Falls back and shows the notice | | Debian 13, Xvfb (X11), no Vulkan driver | Falls back to OpenGL | Software only: `CAPTURE_RENDERER=no_vulkan` capture of the main menu | Falls back and shows the notice |
| Release package outside the repo, headless | None (server and autoplay client) | `make dist-check` | Plays a full match; the game joins its server | | Release package outside the repo, headless | None (server and autoplay client) | `make dist-check` | Plays a full match; the game joins its server |
| Wayland (native or XWayland) | Any | **Not tested** | Unknown | | Wayland (native or XWayland) | Any | **Not tested** | Unknown |
+2 -1
View File
@@ -27,10 +27,11 @@ var effects: EffectsView
## Applies the player's graphics settings: the sun's shadows and the print pass. ## Applies the player's graphics settings: the sun's shadows and the print pass.
## Under the OpenGL fallback the sun never casts shadows (Look.sun_shadows_supported).
func apply_settings(settings: GameSettings) -> void: func apply_settings(settings: GameSettings) -> void:
var distance: float = settings.shadow_distance() var distance: float = settings.shadow_distance()
if sun != null: if sun != null:
sun.shadow_enabled = distance > 0.0 sun.shadow_enabled = distance > 0.0 and Look.sun_shadows_supported()
sun.directional_shadow_max_distance = maxf(distance, 1.0) sun.directional_shadow_max_distance = maxf(distance, 1.0)
var splits: Dictionary = {1: DirectionalLight3D.SHADOW_ORTHOGONAL, 2: DirectionalLight3D.SHADOW_PARALLEL_2_SPLITS, 4: DirectionalLight3D.SHADOW_PARALLEL_4_SPLITS} var splits: Dictionary = {1: DirectionalLight3D.SHADOW_ORTHOGONAL, 2: DirectionalLight3D.SHADOW_PARALLEL_2_SPLITS, 4: DirectionalLight3D.SHADOW_PARALLEL_4_SPLITS}
sun.directional_shadow_mode = splits.get(settings.shadow_splits(), DirectionalLight3D.SHADOW_PARALLEL_4_SPLITS) sun.directional_shadow_mode = splits.get(settings.shadow_splits(), DirectionalLight3D.SHADOW_PARALLEL_4_SPLITS)
+14 -2
View File
@@ -40,16 +40,28 @@ static func environment(graded: bool = true) -> Environment:
return environment return environment
## The low afternoon sun from the sea side. ## The low afternoon sun from the sea side. It casts shadows only where the renderer
## draws them correctly (sun_shadows_supported).
static func sun(shadow_distance: float = 400.0) -> DirectionalLight3D: static func sun(shadow_distance: float = 400.0) -> DirectionalLight3D:
var light: DirectionalLight3D = DirectionalLight3D.new() var light: DirectionalLight3D = DirectionalLight3D.new()
light.rotation_degrees = Vector3(-35.0, -130.0, 0.0) light.rotation_degrees = Vector3(-35.0, -130.0, 0.0)
light.light_energy = 0.95 light.light_energy = 0.95
light.shadow_enabled = true light.shadow_enabled = sun_shadows_supported()
light.directional_shadow_max_distance = shadow_distance light.directional_shadow_max_distance = shadow_distance
return light return light
## Whether `rendering_method` draws the sun's shadows without changing the colours (H14).
## Godot's Compatibility renderer (the OpenGL fallback) draws a shadowed directional
## light in a pass of its own and adds it to the frame after the frame is already in
## sRGB, so a sunlit pixel comes out as srgb(ambient) + srgb(sun) instead of
## srgb(ambient + sun): sunlit ground and rocks turn pale. Measured on llvmpipe, the
## sum matches to within one level in 255. No project or environment setting changes
## it, so under that renderer the sun casts no shadows, as on the Low preset.
static func sun_shadows_supported(rendering_method: String = RenderingServer.get_current_rendering_method()) -> bool:
return rendering_method != "gl_compatibility"
## Adds the woodcut print pass to `camera`, as a full-screen quad drawn after ## Adds the woodcut print pass to `camera`, as a full-screen quad drawn after
## everything else. Returns the quad, whose material takes `sea_level` (see ## everything else. Returns the quad, whose material takes `sea_level` (see
## set_sea_level) and `strength`. ## set_sea_level) and `strength`.
+46
View File
@@ -0,0 +1,46 @@
## H14: flat ground, a boulder and a post under Look's environment and sun. With
## `force_shadows`, the sun casts shadows even where Look.sun_shadows_supported says the
## renderer gets them wrong, to recheck the Compatibility renderer after an engine
## upgrade: `CAPTURE_RENDERER=compatibility tools/capture.sh sun_shadow_probe out.png`
## shows pale sunlit ground for as long as the engine adds the shadowed sun in sRGB.
## Compare with the `sun_probe` scenario, the same scene without the override.
extends Node3D
@export var force_shadows: bool = false
func _ready() -> void:
var world: WorldEnvironment = WorldEnvironment.new()
world.environment = Look.environment()
add_child(world)
var sun: DirectionalLight3D = Look.sun(200.0)
if force_shadows:
sun.shadow_enabled = true
add_child(sun)
var plane: PlaneMesh = PlaneMesh.new()
plane.size = Vector2(80.0, 80.0)
_mesh(plane, Vector3.ZERO, Color(0.31, 0.42, 0.22))
var rock: SphereMesh = SphereMesh.new()
rock.radius = 1.5
rock.height = 2.4
_mesh(rock, Vector3(-2.0, 0.8, 2.0), Color(0.47, 0.44, 0.39))
var post: BoxMesh = BoxMesh.new()
post.size = Vector3(0.6, 4.0, 0.6)
_mesh(post, Vector3(3.0, 2.0, 4.0), Color(0.55, 0.36, 0.22))
var camera: Camera3D = Camera3D.new()
camera.position = Vector3(0.0, 5.0, -10.0)
add_child(camera)
camera.look_at(Vector3(0.0, 0.0, 4.0))
camera.make_current()
func _mesh(mesh: Mesh, at: Vector3, colour: Color) -> void:
var material: StandardMaterial3D = StandardMaterial3D.new()
material.albedo_color = colour
material.roughness = 1.0
material.metallic_specular = 0.15
var instance: MeshInstance3D = MeshInstance3D.new()
instance.mesh = mesh
instance.material_override = material
instance.position = at
add_child(instance)
+1
View File
@@ -0,0 +1 @@
uid://dl4w8btyw3mll
+6
View File
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/light_probe_scene.gd" id="1"]
[node name="SunProbe" type="Node3D"]
script = ExtResource("1")
+7
View File
@@ -0,0 +1,7 @@
[gd_scene load_steps=2 format=3]
[ext_resource type="Script" path="res://test/capture/light_probe_scene.gd" id="1"]
[node name="SunShadowProbe" type="Node3D"]
script = ExtResource("1")
force_shadows = true
+20
View File
@@ -174,6 +174,26 @@ func test_a_preset_sets_the_viewport_and_the_sun() -> void:
view.free() view.free()
func test_no_sun_shadows_under_the_opengl_fallback() -> void:
# H14: Compatibility adds a shadowed sun's pass in sRGB, which washes out sunlit
# ground, so the sun casts no shadows there whatever the preset.
assert_true(Look.sun_shadows_supported("forward_plus"))
assert_true(Look.sun_shadows_supported("mobile"))
assert_false(Look.sun_shadows_supported("gl_compatibility"))
var expected: bool = Look.sun_shadows_supported()
var sun: DirectionalLight3D = Look.sun()
assert_eq(sun.shadow_enabled, expected, "Look.sun follows the renderer")
sun.free()
var view: MatchView = MatchView.new()
view.sun = Look.sun()
view.add_child(view.sun)
var settings: GameSettings = GameSettings.new()
settings.quality = GameSettings.QUALITY_HIGH
view.apply_settings(settings)
assert_eq(view.sun.shadow_enabled, expected, "presets don't turn them back on")
view.free()
func test_presets_never_change_how_far_cover_is_drawn() -> void: 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 # A lower preset must never let a player see through trees and rocks it stopped
# drawing: nothing about props is in the presets. # drawing: nothing about props is in the presets.