d631ff784a
- Restructured kit_demo.tscn from linear demo to enclosed 5.12x5.12 room with walls, floor tiles, pillar, beam, doorway, window - Added WorldEnvironment with ProceduralSky for ambient lighting - Added DirectionalLight3D (sun key light, 45° angle, shadows enabled) - Added OmniLight3D (warm interior fill light) - Added ReflectionProbe for interior specular reflections (box projection, room-sized extents) - Added LightmapGI with balanced quality settings (bounces=3, texel_scale=1.0, max_texture_size=2048, denoiser=true) - Added tool script (kit_demo.gd) that prints bake status in editor - Added bake_lighting.gd CLI bake script (requires GPU-enabled instance) - Updated project.godot with reflection atlas and shadow map quality settings Headless baking note: Godot's standard editor build requires a GPU/display for LightmapGI.bake(). Open the scene in the Godot editor and click 'Bake Lightmap' on the LightmapGI node to generate the baked lightmap data.
71 lines
2.0 KiB
GDScript
71 lines
2.0 KiB
GDScript
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)
|