extends SceneTree ## Main-scene review at fixed simulation time; never writes a save. const OUTPUT := "res://docs/baselines/" func _initialize() -> void: call_deferred("_run") func _run() -> void: root.size = Vector2i(1600, 900) var label := "after" for argument in OS.get_cmdline_user_args(): if argument.begins_with("--label="): label = argument.trim_prefix("--label=").validate_filename() var main := load("res://main.tscn").instantiate() as Node3D main.get_node("SimulationManager").set("debug_logs", false) root.add_child(main) var rig := main.get_node("CameraRig") rig.set_process_unhandled_input(false) Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE) await process_frame main.get_node("SimulationManager").set_process(false) var cycle := main.get_node("JajceWorld/DayNightCycle") cycle.set_process(false) cycle.call("_apply_light_rotation", 0.4) cycle.call("_apply_environment", 0.4) var demo := main.get_node("DemoController") if demo.get("debug_overlay_visible"): demo.call("toggle_debug_overlay") for child in main.get_children(): if child is CanvasLayer: child.hide() for _frame in 45: await process_frame main.get_node("Player").set_physics_process(false) rig.set_physics_process(false) rig.call("apply_presentation_preset", main.get_node("Player").global_position, 0.0, 0.5) await _save(label + "_gameplay") var camera := root.get_camera_3d() camera.reparent(main) camera.global_position = Vector3(38, 24, 44) camera.look_at(Vector3(-4, 3, 0)) camera.fov = 53.0 await _save(label + "_valley") camera.global_position = Vector3(38, 24, 44) camera.look_at(Vector3(-4, 12, 0)) camera.fov = 58.0 await _save(label + "_vista") camera.global_position = Vector3(5, 4.8, 24) camera.look_at(Vector3(-7, 2.8, 9)) camera.fov = 55.0 await _save(label + "_meadow") cycle.call("_apply_light_rotation", 0.92) cycle.call("_apply_environment", 0.92) await _save(label + "_night") cycle.call("_apply_light_rotation", 0.4) cycle.call("_apply_environment", 0.4) camera.global_position = Vector3(38, 24, 44) camera.look_at(Vector3(-4, 3, 0)) camera.fov = 53.0 await _sample_profiles(main, label) quit(0) func _sample_profiles(main: Node3D, label: String) -> void: var world := main.get_node("JajceWorld") as JajceWorld var samples: Array[Dictionary] = [] for quality in [0, 1, 2]: world.apply_presentation_quality(quality) for _frame in 45: await process_frame var frame_times: Array[float] = [] for _frame in 120: var start := Time.get_ticks_usec() await process_frame frame_times.append(float(Time.get_ticks_usec() - start) / 1000.0) frame_times.sort() var sample := { "profile": world.get_active_presentation_quality_name(), "render_scale": root.scaling_3d_scale, "msaa_enum": root.msaa_3d, "wall_frame_p50_ms": frame_times[60], "wall_frame_p95_ms": frame_times[114], "draw_calls": Performance.get_monitor(Performance.RENDER_TOTAL_DRAW_CALLS_IN_FRAME), "primitives": Performance.get_monitor(Performance.RENDER_TOTAL_PRIMITIVES_IN_FRAME), "active_npcs": main.get_node("ActiveNPCs").get_child_count(), } if world.has_node("PainterlyMeadow"): sample["meadow"] = world.get_node("PainterlyMeadow").get_presentation_stats() samples.append(sample) var file := FileAccess.open(OUTPUT + "painterly_" + label + "_metrics.json", FileAccess.WRITE) assert(file != null) ( file . store_string( ( ( JSON . stringify( { "renderer": RenderingServer.get_current_rendering_driver_name(), "device": RenderingServer.get_video_adapter_name(), "resolution": "1600x900", "workload": "Paused main scene, static valley camera; wall time includes vsync", "samples": samples, }, "\t" ) ) + "\n" ) ) ) func _save(label: String) -> void: for _frame in 75: await process_frame await RenderingServer.frame_post_draw var capture := root.get_texture().get_image() assert(not capture.is_empty()) var path := OUTPUT + "painterly_" + label + ".png" assert(capture.save_png(path) == OK) print("[TOOL] Saved " + path)