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,61 @@
|
||||
## Renders a scene for a number of frames and saves the last one as a PNG.
|
||||
## Runs inside the tidewall-capture container via tools/capture.sh, never on the host
|
||||
## display. Prints one JSON line with the image statistics and exits:
|
||||
## 0 saved and not blank, 1 blank or failed, 2 bad arguments.
|
||||
##
|
||||
## --scene=res://...tscn --out=res://captures/x.png [--frames=N] [--allow-blank]
|
||||
extends SceneTree
|
||||
|
||||
var _scene: String = ""
|
||||
var _out: String = ""
|
||||
var _frames: int = 30
|
||||
var _allow_blank: bool = false
|
||||
|
||||
|
||||
func _initialize() -> void:
|
||||
for arg: String in OS.get_cmdline_user_args():
|
||||
if arg.begins_with("--scene="):
|
||||
_scene = arg.trim_prefix("--scene=")
|
||||
elif arg.begins_with("--out="):
|
||||
_out = arg.trim_prefix("--out=")
|
||||
elif arg.begins_with("--frames=") and arg.trim_prefix("--frames=").is_valid_int():
|
||||
_frames = maxi(arg.trim_prefix("--frames=").to_int(), 1)
|
||||
elif arg == "--allow-blank":
|
||||
_allow_blank = true
|
||||
else:
|
||||
printerr("capture: unknown argument '%s'" % arg)
|
||||
quit(2)
|
||||
return
|
||||
if _scene.is_empty() or _out.is_empty():
|
||||
printerr("capture: --scene and --out are required")
|
||||
quit(2)
|
||||
return
|
||||
if DisplayServer.get_name() == "headless":
|
||||
printerr("capture: no display; run this through tools/capture.sh")
|
||||
quit(2)
|
||||
return
|
||||
_capture.call_deferred()
|
||||
|
||||
|
||||
func _capture() -> void:
|
||||
var packed: PackedScene = load(_scene) as PackedScene
|
||||
if packed == null:
|
||||
printerr("capture: can't load scene '%s'" % _scene)
|
||||
quit(1)
|
||||
return
|
||||
root.add_child(packed.instantiate())
|
||||
for _index: int in _frames:
|
||||
await process_frame
|
||||
await RenderingServer.frame_post_draw
|
||||
var image: Image = root.get_texture().get_image()
|
||||
var stats: Dictionary = ImageStats.measure(image)
|
||||
var blank: bool = ImageStats.is_blank(stats)
|
||||
var error: Error = image.save_png(_out)
|
||||
stats["scene"] = _scene
|
||||
stats["size"] = [image.get_width(), image.get_height()]
|
||||
stats["renderer"] = RenderingServer.get_current_rendering_method()
|
||||
stats["adapter"] = RenderingServer.get_video_adapter_name()
|
||||
stats["blank"] = blank
|
||||
stats["saved"] = error == OK
|
||||
print("CAPTURE " + JSON.stringify(stats))
|
||||
quit(0 if error == OK and (not blank or _allow_blank) else 1)
|
||||
Reference in New Issue
Block a user