build: baked lighting pass on kit_demo test map

Restructured kit_demo.tscn from linear demo to enclosed 5.12x5.12 room:
- 2x2 floor tiles, 8 wall segments (including doorway + window)
- Pillar at room center, beam overhead, accent panels
- West/east walls rotated 90° Y for proper enclosure

Lighting infrastructure:
- WorldEnvironment with ambient light
- DirectionalLight3D (sun key light, 45° angle, shadows enabled)
- OmniLight3D (warm interior fill light)
- ReflectionProbe (box projection, room-sized extents)
- LightmapGI (Quality=High, bounces=3, denoiser=true)
- Tool script prints bake status in editor

Scripts:
- bake_lighting.gd: validates LightmapGI config from CLI
- validate_scene.gd: full scene validation (17 checks, all pass)

Note: Godot 4.7 removed LightmapGI.bake() from runtime API.
Baking must be done in the editor: select LightmapGI node > Bake Lightmap.
This commit is contained in:
2026-07-01 00:28:55 -04:00
parent aa0b80b570
commit 16e062c739
4 changed files with 188 additions and 99 deletions
+55 -53
View File
@@ -1,70 +1,72 @@
extends Node
extends SceneTree
func _ready():
print("=== LightmapGI Baked Lighting Baker ===")
print("Opening scene: res://assets/scenes/modular/kit_demo.tscn")
# Check LightmapGI config on kit_demo.tscn scene.
# No bake possible at runtime in Godot 4.7 — LightmapGI baking is editor-only.
# This script validates that the scene is configured correctly for baking.
#
# Usage:
# xvfb-run godot --display-driver x11 --rendering-driver opengl3 \
# --audio-driver Dummy --script scripts/bake_lighting.gd
#
# Bake from editor:
# Open kit_demo.tscn in Godot editor, select LightmapGI node,
# click "Bake Lightmap" in the Inspector toolbar.
const SCENE_PATH := "res://assets/scenes/modular/kit_demo.tscn"
func _init():
print("=== LightmapGI Config Check ===")
print("Note: Godot 4.7 LightmapGI baking is editor-only.")
print("This script validates configuration only.")
print("")
# Load the scene
var scene = ResourceLoader.load("res://assets/scenes/modular/kit_demo.tscn")
var scene = ResourceLoader.load(SCENE_PATH)
if not scene:
print("ERROR: Failed to load scene!")
get_tree().quit(1)
printerr("ERROR: Failed to load scene!")
quit(1)
return
var instance = scene.instantiate()
get_tree().root.add_child(instance)
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)
var lightmap = _find_node(instance, "LightmapGI")
if not lightmap or not (lightmap is LightmapGI):
printerr("ERROR: LightmapGI node not found!")
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("LightmapGI configuration:")
match lightmap.quality:
0: print(" Quality: Low")
1: print(" Quality: Medium")
2: print(" Quality: High")
3: print(" Quality: Ultra")
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(" Denoiser: ", lightmap.is_using_denoiser())
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
if lightmap.light_data != null:
print("LightmapGI has baked data!")
else:
print("LightmapGI NOT YET BAKED.")
print("To bake: Open scene in Godot editor > Select LightmapGI >")
print("click 'Bake Lightmap' button in the Inspector toolbar.")
print("")
print("Or use the Godot editor menu: Scene > Bake LightmapGI")
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)
print("=== Config check complete ===")
quit(0)
func _find_node(parent: Node, name: String) -> Node:
for child in parent.get_children():
if child.name == name:
return child
var found = _find_node(child, name)
if found:
return found
return null