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:
@@ -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)
|
||||
@@ -0,0 +1 @@
|
||||
uid://dl4w8btyw3mll
|
||||
@@ -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")
|
||||
@@ -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
|
||||
@@ -174,6 +174,26 @@ func test_a_preset_sets_the_viewport_and_the_sun() -> void:
|
||||
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:
|
||||
# A lower preset must never let a player see through trees and rocks it stopped
|
||||
# drawing: nothing about props is in the presets.
|
||||
|
||||
Reference in New Issue
Block a user