extends SceneTree ## Regression audit for the grazing-angle dark band that the ink post-process ## used to paint across flat roads and walls. The sampled view reproduces the ## original report exactly; both distant road samples must remain close to an ## unobstructed road sample nearer the camera. const MAP := "res://scenes/maps/sakura_crossing/sakura_crossing.tscn" const FAR_ROAD_UVS := [Vector2(0.46875, 0.52778), Vector2(0.4948, 0.537)] const REFERENCE_ROAD_UV := Vector2(0.5, 0.62) const MIN_LUMINANCE_RATIO := 0.75 func _sample(image: Image, uv: Vector2) -> Color: var x := clampi(roundi(uv.x * image.get_width()), 0, image.get_width() - 1) var y := clampi(roundi(uv.y * image.get_height()), 0, image.get_height() - 1) return image.get_pixel(x, y) func _initialize() -> void: _run() func _run() -> void: var level := (load(MAP) as PackedScene).instantiate() root.add_child(level) for _i in 120: await process_frame var camera := Camera3D.new() camera.fov = 70.0 camera.far = 1200.0 level.add_child(camera) camera.current = true camera.global_position = Vector3(-4.0, 1.7, -30.0) camera.look_at(Vector3(80.0, 1.7, -30.0), Vector3.UP) for _i in 6: await process_frame var image := root.get_texture().get_image() var reference_luma := _sample(image, REFERENCE_ROAD_UV).get_luminance() var minimum_far_luma := 1.0 for uv in FAR_ROAD_UVS: minimum_far_luma = minf(minimum_far_luma, _sample(image, uv).get_luminance()) var ratio := minimum_far_luma / maxf(reference_luma, 0.001) var failed := ratio < MIN_LUMINANCE_RATIO if failed: push_error("GROUND_BAND_AUDIT dark distant road: far/reference=%.3f (minimum %.3f)" % [ ratio, MIN_LUMINANCE_RATIO]) else: print("GROUND_BAND_AUDIT PASS far/reference=%.3f" % ratio) var args := OS.get_cmdline_user_args() if not args.is_empty(): var output := args[0] if not output.is_absolute_path(): output = ProjectSettings.globalize_path(output) DirAccess.make_dir_recursive_absolute(output.get_base_dir()) image.save_png(output) print("GROUND_BAND_AUDIT saved ", output) level.queue_free() for _i in 6: await process_frame quit(1 if failed else 0)