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>
49 lines
1.6 KiB
GDScript
49 lines
1.6 KiB
GDScript
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"))
|