extends SceneTree ## Regression capture for directional cloud lighting. ## ## Runs the same Akiba street camera twice with the sun rotated 180 degrees. ## The bright cloud rim and colored lee-side band should visibly swap sides. ## ## godot --path . -s res://debug/cloud_sun_response_capture.gd -- var _frame := 0 var _out_dir := "." var _sun: DirectionalLight3D func _initialize() -> void: var args := OS.get_cmdline_user_args() if not args.is_empty(): _out_dir = args[0] if not _out_dir.is_absolute_path(): _out_dir = ProjectSettings.globalize_path(_out_dir) var mkdir_error := DirAccess.make_dir_recursive_absolute(_out_dir) if mkdir_error != OK: printerr("cloud_sun_capture: could not create output directory") quit(mkdir_error) return change_scene_to_file("res://ui/main_menu/main_menu.tscn") func _process(_delta: float) -> bool: _frame += 1 if _frame == 60: var network = root.get_node_or_null("NetworkManager") if network and network.has_method("start_singleplayer_match"): network.start_singleplayer_match(GameMode.DEATHMATCH) change_scene_to_file("res://scenes/maps/neon_alley/neon_alley.tscn") elif _frame == 240: _sun = current_scene.get_node_or_null("Sun") as DirectionalLight3D var camera := root.get_camera_3d() if _sun == null or camera == null: printerr("cloud_sun_capture: missing sun or camera") return true camera.global_position = Vector3(3, 2.2, 20) camera.look_at(Vector3(-8, 4, -18), Vector3.UP) _sun.rotation_degrees = Vector3(-28, -65, 0) elif _frame == 280: _shot("sun_west") _sun.rotation_degrees = Vector3(-28, 115, 0) elif _frame == 320: _shot("sun_east") unload_current_scene() elif _frame == 440: return true return false func _shot(tag: String) -> void: var image := root.get_viewport().get_texture().get_image() var path := _out_dir.path_join(tag + ".png") var error := image.save_png(path) if error == OK: print("cloud_sun_capture: saved ", path) else: printerr("cloud_sun_capture: save failed with error ", error)