Repository navigation
feat(kit): per-light Cycles baked GI lightmaps and L1 SH probes - #505
Merged
Merged
Conversation
…robes, and canopy openness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What it does. Adds per-light indirect lightmaps (
128×128×4rgb9e5ufloattexture array) and a4×2×43D L1 spherical-harmonics probe grid (packages/kit/gpu/gi/lightmap.ts) baked with headless Blender 5.2 Cycles (scripts/bake-room.py), plus a canopy sky-openness baker (bakeCanopyOpenness) for forests. No game turns it on by default; to see it, open the Lab world preset Baked indirect GI (Cycles) (?preset=baked-gi).How it works.
extractBakeSceneSpecexports the room's packed mesh and physicalSceneLightfixtures toscripts/house-bake-scene.jsonwith a SHA-256 input hash (00d64d3e69a5aa26..., verified byassertBakedLightmapFresh).scripts/bake-room.pyimports those triangles and emitters into headless Blender 5.2.2 LTS, unwraps UV2 islands withbpy.ops.uv.lightmap_pack(PREF_BOX_DIV=64, PREF_MARGIN_DIV=0.10), and bakes 3-bounce indirect diffuse light (384samples,use_adaptive_sampling = False, island-clamped despiking and 4-pass separable binomial smoothing) at unit reference power (energy = 4π · Pfor spot/point,π · Pfor cosineAREApanels, multiplied byENGINE_LIGHT_GAIN = 5.0in WGSL with zero fudge factor;0.04%vs closed-formanalyticSpotFloorBounce).evaluateBakedLightWeightsscales each light layer and probe strictly linearly by(livePower / bakedPower) * giIntensity(returning0immediately when aLiveBounceSourcesuch asscreenBounceSourceis off). Static lightmapped surfaces sample only the UV2 lightmap array; dynamic objects (MAT.actor) sample only the trilinear L1 SH probe volume.Risk. Kit, Lab world, scripts and docs only.
bakedRoomand the:bakedrenderer variant inpackages/kit/lab/world/world.tsare gated ongiMode === "baked". Verified by hashing the compiled scene shaders of every game and every non-baked-giLab preset plus the Lab world's static mesh bytes againstorigin/main(b566ecf0):origin/main(b566ecf0)kit-lightmapskit: sceneShader(true, false)(Brawl / Blackout / Getaway / Carrier)3a519e694b51a7283a519e694b51a728kit: sceneShader(false, false)(Renderer baseline)9d6b6514cf214e3c9d6b6514cf214e3ckit: sceneShader(true, true)(Renderer motion)89cf8b6c89a1492b89cf8b6c89a1492bkit: makeSceneShader({}, false, false)5a939988fe3567415a939988fe356741game: Outbreak town scene (shaders.scene)0aaef9e1081107420aaef9e108110742game: Outbreak vignette scene (vignetteShaders.scene)bf78443910bd56debf78443910bd56degame: BARBARA forest scene (forestHooks + treeVertex + cutoutDepth)9a0de263cba56c049a0de263cba56c04game: BARBARA batch scene (batchHooks)7a37736025481bf27a37736025481bf2game: BARBARA moonlit lake scene (forestLakeHooks)c44ddc6f1ea747f0c44ddc6f1ea747f0game: Lot scene (makeSceneShader(lotHooks))984e98afc28efce0984e98afc28efce0game: Nightshift scene (makeSceneShader(nightshiftHooks))81e9fe6d870dc59981e9fe6d870dc599game: Archers custom scene (archersSceneShader)60e2061ffe1189d160e2061ffe1189d1lab preset: day / night-today (Today scene shader)3a519e694b51a7283a519e694b51a728lab preset: night-physical / spot-shadows / screen-bench (Physical scene shader)46074b9e088af2b946074b9e088af2b9lab preset: finished-props (Physical + finish scene shader)b5ee1abc4c3cdfc0b5ee1abc4c3cdfc0lab preset: finished-props (Today + finish scene shader)e831946f2283ec5fe831946f2283ec5flab: WORLD_POST shader319648dfaf929515319648dfaf929515lab: default world (day) level.chunks[0].data(541,296 B)0299f39c500ff0180299f39c500ff018lab: screen-bench level.chunks[0].data(616,608 B)c7eba7a1afd1b8c7c7eba7a1afd1b8c7lab: finished-props level.chunks[0].data(809,280 B)f51eca92c8f718a1f51eca92c8f718a1Proof. All stills captured at the reframed
BAKED_GI_CAMERA(target: [-4.72, 1.42, -11.15], yaw: -0.52, pitch: -0.01, dist: 4.35,960×600) with fixed exposure (grade = [1.0, 0, 0, 1.45],shadowLift = 0,lensBloom = 0.25,skyLight = 0.015,giIntensity = 1.0,giProbes = 1.0). Paired GPU cost:1.989 msToday vs2.015 msBaked GI (+0.026 ms, budget≤ 0.30 ms;257.5 KiBGPU memory).screenBounceSource:960×600crop)(R, G, B)/255)(R, G, B)/255)420..740, 12..95)(2.20, 2.40, 2.91)2.39(99.66, 43.59, 24.07)54.10+51.71360..530, 150..275)(2.83, 3.14, 3.93)3.13(62.91, 23.73, 13.60)31.33+28.2015..140, 20..130)(2.51, 2.76, 3.42)2.76(35.75, 12.07, 7.54)16.78+14.02(0.31×ceiling)40..320, 240..485)(10.13, 9.98, 12.32)10.18(23.04, 12.65, 13.19)14.90+4.72(+12.91 R)560..840, 480..588)(213.21, 194.54, 171.74)196.86(214.65, 195.28, 172.25)197.74+0.880..960, 0..600)(5.65, 5.42, 6.21)5.53(5.65, 5.42, 6.21)5.530.00420..740, 12..95)(2.20, 2.40, 2.91)2.39(2.20, 2.40, 2.91)2.390.00360..530, 150..275)(2.83, 3.14, 3.93)3.13(8.48, 23.88, 28.71)20.96+17.83(B: +24.78)360..530, 150..275)(2.83, 3.14, 3.93)3.13(43.80, 9.99, 7.10)16.97+13.84(R: +40.97)bun test packages/kit/gpu/gi/lightmap.test.ts packages/kit/lab/world/world.test.ts packages/kit/architecture-map.test.ts(HiveMindmini): 30 passbun run --cwd packages/kit typecheck && bun run --cwd games/lab typecheck && bun run check:scripts(HiveMindmini): cleanhivemind run --kind browser --browser-approval "Kit requested baked-gi v2 framing & ceiling rebake proof" --worker mini -- bun run verify:smoke --game lab: build + smoke ok (5.0s)LIGHTMAP_PROOF_DIR=/Users/kit/code/home/artifacts/kit-lightmaps-2026-10-23 deno run --unstable-webgpu --sloppy-imports --allow-env --allow-read --allow-write scripts/lightmap-gpu-proof.ts: 0 WebGPU errors,todayBaselineMaxByteDiff = 0, all assertions pass