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
+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)