F7: Offscreen render capture harness
tools/capture.sh <scene-or-scenario> <out.png> renders the real client in a throwaway tidewall-capture-* Docker container (debian:13, Xvfb, Mesa software rendering), with no network, no host display, GPU or audio, and removes the container afterwards. The tidewall-capture image rebuilds only when its recipe changes. Forward+ through Lavapipe is the default, matching the game; CAPTURE_RENDERER=compatibility uses OpenGL through llvmpipe. The script fails if Godot silently falls back to another renderer, and fails on a blank frame, judged by ImageStats (luminance variance and colour count). make capture-test renders the shore test scene with both renderers and proves an empty scene is rejected. ImageStats has unit tests in make check. CLAUDE.md now requires a capture for visual issues, and requires that it be opened and looked at. Closes #7 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
[gd_scene format=3]
|
||||
|
||||
[node name="CaptureBlank" type="Node"]
|
||||
@@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3]
|
||||
|
||||
[ext_resource type="Script" path="res://test/capture/smoke_scene.gd" id="1"]
|
||||
|
||||
[node name="CaptureSmoke" type="Node3D"]
|
||||
script = ExtResource("1")
|
||||
@@ -0,0 +1,67 @@
|
||||
## The capture harness's test scene: a small shore with sea, sand, a breakwater and a
|
||||
## post, under a procedural sky. Everything is built in code, so there are no assets.
|
||||
extends Node3D
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
var environment: Environment = Environment.new()
|
||||
var sky_material: ProceduralSkyMaterial = ProceduralSkyMaterial.new()
|
||||
sky_material.sky_top_color = Color(0.32, 0.5, 0.68)
|
||||
sky_material.sky_horizon_color = Color(0.82, 0.78, 0.68)
|
||||
sky_material.ground_bottom_color = Color(0.18, 0.2, 0.2)
|
||||
var sky: Sky = Sky.new()
|
||||
sky.sky_material = sky_material
|
||||
environment.background_mode = Environment.BG_SKY
|
||||
environment.sky = sky
|
||||
environment.ambient_light_source = Environment.AMBIENT_SOURCE_SKY
|
||||
environment.ambient_light_energy = 0.35
|
||||
environment.tonemap_mode = Environment.TONE_MAPPER_FILMIC
|
||||
var world: WorldEnvironment = WorldEnvironment.new()
|
||||
world.environment = environment
|
||||
add_child(world)
|
||||
|
||||
var sun: DirectionalLight3D = DirectionalLight3D.new()
|
||||
sun.rotation_degrees = Vector3(-38.0, -50.0, 0.0)
|
||||
sun.light_energy = 0.75
|
||||
sun.shadow_enabled = true
|
||||
add_child(sun)
|
||||
|
||||
_box(Vector3(60.0, 1.0, 60.0), Vector3(0.0, -0.5, -10.0), Color(0.58, 0.5, 0.36))
|
||||
_box(Vector3(200.0, 0.2, 200.0), Vector3(0.0, -0.3, 80.0), Color(0.07, 0.2, 0.26))
|
||||
for index: int in 6:
|
||||
var height: float = 1.4 + 0.25 * (index % 2)
|
||||
var x: float = -7.5 + index * 3.0
|
||||
_box(Vector3(2.6, height, 2.0), Vector3(x, height * 0.5, 4.0), Color(0.45, 0.42, 0.38))
|
||||
_cylinder(0.35, 5.0, Vector3(5.0, 2.5, -2.0), Color(0.55, 0.36, 0.22))
|
||||
_cylinder(0.6, 0.8, Vector3(5.0, 5.4, -2.0), Color(0.72, 0.22, 0.18))
|
||||
|
||||
var camera: Camera3D = Camera3D.new()
|
||||
camera.position = Vector3(-6.0, 6.0, -16.0)
|
||||
add_child(camera)
|
||||
camera.look_at(Vector3(1.0, 1.0, 2.0))
|
||||
camera.make_current()
|
||||
|
||||
|
||||
func _box(size: Vector3, at: Vector3, colour: Color) -> void:
|
||||
var mesh: BoxMesh = BoxMesh.new()
|
||||
mesh.size = size
|
||||
_place(mesh, at, colour)
|
||||
|
||||
|
||||
func _cylinder(radius: float, height: float, at: Vector3, colour: Color) -> void:
|
||||
var mesh: CylinderMesh = CylinderMesh.new()
|
||||
mesh.top_radius = radius
|
||||
mesh.bottom_radius = radius
|
||||
mesh.height = height
|
||||
_place(mesh, at, colour)
|
||||
|
||||
|
||||
func _place(mesh: PrimitiveMesh, at: Vector3, colour: Color) -> void:
|
||||
var material: StandardMaterial3D = StandardMaterial3D.new()
|
||||
material.albedo_color = colour
|
||||
material.roughness = 0.85
|
||||
mesh.material = material
|
||||
var instance: MeshInstance3D = MeshInstance3D.new()
|
||||
instance.mesh = mesh
|
||||
instance.position = at
|
||||
add_child(instance)
|
||||
@@ -0,0 +1 @@
|
||||
uid://f5bdhjyvldby
|
||||
@@ -0,0 +1,48 @@
|
||||
extends TestCase
|
||||
|
||||
|
||||
func _solid(colour: Color) -> Image:
|
||||
var image: Image = Image.create(64, 64, false, Image.FORMAT_RGBA8)
|
||||
image.fill(colour)
|
||||
return image
|
||||
|
||||
|
||||
func test_solid_frame_is_blank() -> void:
|
||||
var stats: Dictionary = ImageStats.measure(_solid(Color(0.3, 0.3, 0.3)))
|
||||
assert_near(stats["variance"], 0.0, 0.000001)
|
||||
assert_eq(stats["colours"], 1)
|
||||
assert_true(ImageStats.is_blank(stats))
|
||||
|
||||
|
||||
func test_two_flat_halves_are_still_blank() -> void:
|
||||
# A cleared frame with one flat rectangle has variance but almost no colours.
|
||||
var image: Image = _solid(Color.BLACK)
|
||||
image.fill_rect(Rect2i(0, 0, 32, 64), Color.WHITE)
|
||||
var stats: Dictionary = ImageStats.measure(image)
|
||||
assert_true(stats["variance"] > ImageStats.BLANK_VARIANCE)
|
||||
assert_true(ImageStats.is_blank(stats))
|
||||
|
||||
|
||||
func test_gradient_with_detail_is_not_blank() -> void:
|
||||
var image: Image = Image.create(128, 128, false, Image.FORMAT_RGBA8)
|
||||
for y: int in 128:
|
||||
for x: int in 128:
|
||||
image.set_pixel(x, y, Color(x / 128.0, y / 128.0, float((x * y) % 7) / 7.0))
|
||||
var stats: Dictionary = ImageStats.measure(image)
|
||||
assert_eq(stats["samples"], (128 / ImageStats.STRIDE) * (128 / ImageStats.STRIDE))
|
||||
assert_false(ImageStats.is_blank(stats))
|
||||
|
||||
|
||||
func test_mean_of_known_image() -> void:
|
||||
var stats: Dictionary = ImageStats.measure(_solid(Color.WHITE))
|
||||
assert_near(stats["mean"], 1.0, 0.0001)
|
||||
|
||||
|
||||
func test_empty_image() -> void:
|
||||
var stats: Dictionary = ImageStats.measure(Image.create(1, 1, false, Image.FORMAT_RGBA8))
|
||||
assert_eq(stats["samples"], 1)
|
||||
|
||||
|
||||
func test_capture_scenes_exist() -> void:
|
||||
assert_true(ResourceLoader.exists("res://test/capture/smoke.tscn"))
|
||||
assert_true(ResourceLoader.exists("res://test/capture/blank.tscn"))
|
||||
@@ -0,0 +1 @@
|
||||
uid://bimwta516hla6
|
||||
Reference in New Issue
Block a user