extends Node func _ready(): print("=== LightmapGI Baked Lighting Baker ===") print("Opening scene: res://assets/scenes/modular/kit_demo.tscn") # Load the scene var scene = ResourceLoader.load("res://assets/scenes/modular/kit_demo.tscn") if not scene: print("ERROR: Failed to load scene!") get_tree().quit(1) return var instance = scene.instantiate() get_tree().root.add_child(instance) # Find the LightmapGI node var lightmap = instance.find_child("LightmapGI", true, false) if not lightmap: print("ERROR: No LightmapGI node found in scene!") get_tree().quit(1) return if not lightmap is LightmapGI: print("ERROR: Found node 'LightmapGI' is not a LightmapGI type!") get_tree().quit(1) return print("LightmapGI found. Configuration:") print(" Bounces: ", lightmap.bounces) print(" Texel Scale: ", lightmap.texel_scale) print(" Texel Subdiv: ", lightmap.texel_subdiv) print(" Max Texture Size: ", lightmap.max_texture_size) print(" Interior: ", lightmap.interior) # Start baking print("") print("=== Starting LightmapGI bake ===") print("(This may take a while...)") # Wait one frame for scene to fully initialize await get_tree().process_frame var result = lightmap.bake(instance, null) if result != OK: print("ERROR: Lightmap bake failed with error code: ", result) get_tree().quit(1) return print("") print("=== Lightmap bake successful! ===") # Save the scene with baked data print("Saving scene with baked lightmap data...") var packed = PackedScene.new() packed.pack(instance) var save_result = ResourceSaver.save(packed, "res://assets/scenes/modular/kit_demo.tscn") if save_result != OK: print("ERROR: Failed to save scene! Error code: ", save_result) get_tree().quit(1) return print("Scene saved successfully!") print("Baked lighting data is now embedded in kit_demo.tscn") print("(The LightmapGI node's light_data property contains the baked data)") print("") print("=== Done ===") get_tree().quit(0)