@call-me-sensei/toonlab 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (205) hide show
  1. package/AGENTS.md +127 -4
  2. package/ATTRIBUTION.md +41 -3
  3. package/README.md +234 -34
  4. package/docs/characters.md +144 -0
  5. package/docs/debug-panel.md +126 -0
  6. package/docs/docs.css +589 -0
  7. package/docs/environment.md +186 -0
  8. package/docs/getting-started.md +180 -0
  9. package/docs/index.html +14 -0
  10. package/docs/lab-architecture.md +100 -0
  11. package/docs/lighting.md +825 -0
  12. package/docs/main.jsx +739 -0
  13. package/docs/mcp.md +97 -0
  14. package/docs/post-processing.md +98 -0
  15. package/docs/settings-reference.md +1878 -0
  16. package/docs/shader-constants.md +77 -0
  17. package/docs/sky.md +182 -0
  18. package/docs/style-labs.md +309 -0
  19. package/docs/texture-lab.md +135 -0
  20. package/docs/toon-shading.md +183 -0
  21. package/docs/tsl-conventions.md +167 -0
  22. package/docs/vegetation-sky.md +275 -0
  23. package/docs/water.md +430 -0
  24. package/docs/weather.md +200 -0
  25. package/docs/world-scale.md +111 -0
  26. package/mcp/server.mjs +610 -0
  27. package/mcp/style-lab-tools.mjs +371 -0
  28. package/mcp/vite-plugin.mjs +174 -0
  29. package/mcp/workspace.mjs +397 -0
  30. package/package.json +64 -5
  31. package/src/ambientfx/INTEGRATION.md +164 -0
  32. package/src/ambientfx/ambientFxPresets.js +83 -0
  33. package/src/ambientfx/ambientFxSettings.js +368 -0
  34. package/src/ambientfx/emitters.js +169 -0
  35. package/src/ambientfx/index.js +5 -0
  36. package/src/ambientfx/particleBackbone.js +493 -0
  37. package/src/ambientfx/stylizedAmbientFx.js +450 -0
  38. package/src/assetlib/ambientcg.js +117 -0
  39. package/src/assetlib/assetRef.js +91 -0
  40. package/src/assetlib/importedEntry.js +40 -0
  41. package/src/assetlib/index.js +23 -0
  42. package/src/assetlib/kaykit.js +192 -0
  43. package/src/assetlib/kaykitStaticIndex.js +700 -0
  44. package/src/assetlib/loadImported.js +143 -0
  45. package/src/assetlib/opensource3d.js +113 -0
  46. package/src/assetlib/polyhaven.js +182 -0
  47. package/src/assetlib/polypizza.js +115 -0
  48. package/src/assetlib/smithsonian.js +214 -0
  49. package/src/assetlib/sources.js +279 -0
  50. package/src/assetlib/zip.js +58 -0
  51. package/src/biome/biomeGenerator.js +385 -0
  52. package/src/biome/biomeRuntime.js +299 -0
  53. package/src/biome/index.js +2 -0
  54. package/src/buildinggen/buildingAsset.js +44 -0
  55. package/src/buildinggen/buildingGrammar.js +311 -0
  56. package/src/buildinggen/buildingMesh.js +451 -0
  57. package/src/buildinggen/buildingPresets.js +46 -0
  58. package/src/buildinggen/buildingRecipe.js +100 -0
  59. package/src/buildinggen/buildingSettings.js +238 -0
  60. package/src/buildinggen/index.js +6 -0
  61. package/src/camera/cameraDirector.js +157 -0
  62. package/src/camera/cameraGenerator.js +367 -0
  63. package/src/camera/cameraRig.js +570 -0
  64. package/src/camera/cameraSettings.js +236 -0
  65. package/src/camera/index.js +7 -0
  66. package/src/catalog/builtinEntries.js +245 -0
  67. package/src/catalog/catalog.js +210 -0
  68. package/src/catalog/index.js +3 -0
  69. package/src/catalog/manifest.js +84 -0
  70. package/src/core/generation.js +529 -0
  71. package/src/environment/environmentRigs.js +21 -1
  72. package/src/environment/environmentSettings.js +4 -0
  73. package/src/environment/environmentSunShadowPass.js +8 -0
  74. package/src/fauna/INTEGRATION.md +174 -0
  75. package/src/fauna/boids.js +861 -0
  76. package/src/fauna/faunaBodies.js +492 -0
  77. package/src/fauna/faunaPresets.js +52 -0
  78. package/src/fauna/faunaSettings.js +525 -0
  79. package/src/fauna/index.js +5 -0
  80. package/src/fauna/stylizedFauna.js +395 -0
  81. package/src/game-feel/gameFeelGenerator.js +402 -0
  82. package/src/game-feel/gameFeelRuntime.js +549 -0
  83. package/src/game-feel/index.js +2 -0
  84. package/src/index.js +17 -6
  85. package/src/lighting/colorIntensity.js +177 -0
  86. package/src/lighting/index.js +161 -0
  87. package/src/lighting/lightDescriptors.js +249 -0
  88. package/src/lighting/lightingCapabilities.js +79 -0
  89. package/src/lighting/lightingDocuments.js +247 -0
  90. package/src/lighting/lightingFixtures.js +446 -0
  91. package/src/lighting/lightingGenerator.js +449 -0
  92. package/src/lighting/lightingPresets.js +319 -0
  93. package/src/lighting/lightingRuntime.js +723 -0
  94. package/src/lighting/lightingStyle.js +386 -0
  95. package/src/lighting/lightingSystem.js +774 -0
  96. package/src/lighting/unrealExport.js +186 -0
  97. package/src/lighting/utils.js +87 -0
  98. package/src/motion/index.js +5 -0
  99. package/src/motion/motionClip.js +441 -0
  100. package/src/motion/motionController.js +628 -0
  101. package/src/motion/motionDocuments.js +225 -0
  102. package/src/motion/motionGraph.js +307 -0
  103. package/src/motion/motionSettings.js +222 -0
  104. package/src/pathgen/index.js +7 -0
  105. package/src/pathgen/pathBridge.js +232 -0
  106. package/src/pathgen/pathPresets.js +35 -0
  107. package/src/pathgen/pathRibbon.js +410 -0
  108. package/src/pathgen/pathRouter.js +380 -0
  109. package/src/pathgen/pathSettings.js +335 -0
  110. package/src/pathgen/pathTextures.js +123 -0
  111. package/src/pathgen/stylizedPaths.js +453 -0
  112. package/src/post/index.js +1 -0
  113. package/src/post/postGenerator.js +177 -0
  114. package/src/post/postProcessing.js +41 -0
  115. package/src/propgen/generatorsWave1.js +379 -0
  116. package/src/propgen/generatorsWave2.js +462 -0
  117. package/src/propgen/index.js +5 -0
  118. package/src/propgen/propAsset.js +323 -0
  119. package/src/propgen/propParts.js +170 -0
  120. package/src/propgen/propPlacement.js +459 -0
  121. package/src/propgen/propPresets.js +82 -0
  122. package/src/propgen/propSettings.js +395 -0
  123. package/src/shaders-tsl/chunks/projected-water-caustics.js +242 -0
  124. package/src/shaders-tsl/chunks/vegetation-style.js +360 -0
  125. package/src/shaders-tsl/chunks/water-shore-state.js +31 -0
  126. package/src/shaders-tsl/chunks/water-waves.js +90 -11
  127. package/src/shaders-tsl/environment.js +15 -1
  128. package/src/shaders-tsl/flower.js +279 -30
  129. package/src/shaders-tsl/grass.js +60 -33
  130. package/src/shaders-tsl/sky.js +125 -31
  131. package/src/shaders-tsl/tree-leaf.js +61 -25
  132. package/src/shaders-tsl/water-breaker.js +7 -4
  133. package/src/shaders-tsl/water-shore-state-simulation.js +523 -0
  134. package/src/shaders-tsl/water.js +439 -49
  135. package/src/shaders-tsl/woody-surface.js +154 -0
  136. package/src/sky/sceneOverrideLayers.js +10 -0
  137. package/src/sky/skyQuality.js +26 -0
  138. package/src/sky/stylizedSky.js +753 -45
  139. package/src/soundscape/index.js +4 -0
  140. package/src/soundscape/soundscapeGenerator.js +179 -0
  141. package/src/soundscape/soundscapeRuntime.js +806 -0
  142. package/src/soundscape/soundscapeSettings.js +292 -0
  143. package/src/styles/index.js +13 -0
  144. package/src/styles/styleBundle.js +325 -0
  145. package/src/stylizedTerrain.js +32 -2
  146. package/src/stylizedWorld.js +423 -20
  147. package/src/texgen/evaluateTexture.js +675 -0
  148. package/src/texgen/index.js +60 -0
  149. package/src/texgen/noise2.js +210 -0
  150. package/src/texgen/textureAi.js +436 -0
  151. package/src/texgen/textureGenerators.js +516 -0
  152. package/src/texgen/texturePresets.js +490 -0
  153. package/src/texgen/textureSettings.js +342 -0
  154. package/src/texgen/textureThree.js +59 -0
  155. package/src/vegetation/flowerSpecies.js +15 -3
  156. package/src/vegetation/grassPalettes.js +153 -0
  157. package/src/vegetation/index.js +6 -0
  158. package/src/vegetation/stylizedBush.js +2 -0
  159. package/src/vegetation/stylizedFlower.js +82 -0
  160. package/src/vegetation/stylizedFlowers.js +48 -7
  161. package/src/vegetation/stylizedForest.js +29 -1
  162. package/src/vegetation/stylizedGrass.js +291 -56
  163. package/src/vegetation/stylizedTree.js +38 -2
  164. package/src/vegetation/stylizedTreeFoliage.js +2 -1
  165. package/src/vegetation/vegetationShaders.js +1110 -0
  166. package/src/vfxgen/INTEGRATION.md +145 -0
  167. package/src/vfxgen/core/burstBackbone.js +380 -0
  168. package/src/vfxgen/core/projectileCore.js +92 -0
  169. package/src/vfxgen/core/spriteShapes.js +98 -0
  170. package/src/vfxgen/core/trailRibbon.js +272 -0
  171. package/src/vfxgen/core/vfxRandom.js +29 -0
  172. package/src/vfxgen/effects/emitHelpers.js +37 -0
  173. package/src/vfxgen/effects/magicEffects.js +162 -0
  174. package/src/vfxgen/effects/movementEffects.js +87 -0
  175. package/src/vfxgen/effects/weaponEffects.js +118 -0
  176. package/src/vfxgen/index.js +18 -0
  177. package/src/vfxgen/moves/moveController.js +146 -0
  178. package/src/vfxgen/moves/moveLibrary.js +335 -0
  179. package/src/vfxgen/vfxPresets.js +98 -0
  180. package/src/vfxgen/vfxSettings.js +384 -0
  181. package/src/vfxgen/vfxSystem.js +449 -0
  182. package/src/vfxgen/weapons/stylizedWeapons.js +137 -0
  183. package/src/villagegen/index.js +4 -0
  184. package/src/villagegen/stylizedVillage.js +490 -0
  185. package/src/villagegen/villageArchetypes.js +160 -0
  186. package/src/villagegen/villageNames.js +40 -0
  187. package/src/villagegen/villageSites.js +105 -0
  188. package/src/water/sceneOverrideLayers.js +23 -0
  189. package/src/water/water.js +5 -0
  190. package/src/water/waterBreakerSystem.js +15 -1
  191. package/src/water/waterCurrentField.js +447 -0
  192. package/src/water/waterMaterial.js +12 -0
  193. package/src/water/waterNearshorePhase.js +320 -0
  194. package/src/water/waterScenePasses.js +83 -30
  195. package/src/water/waterSettings.js +325 -13
  196. package/src/water/waterShoreMaterial.js +322 -0
  197. package/src/water/waterShoreStateField.js +605 -0
  198. package/src/water/waterSurface.js +797 -28
  199. package/src/weather/index.js +6 -0
  200. package/src/weather/weatherPrecipitation.js +221 -0
  201. package/src/weather/weatherPresets.js +258 -0
  202. package/src/weather/weatherSettings.js +269 -0
  203. package/src/weather/weatherSystem.js +871 -0
  204. package/src/worldMinimap.js +62 -0
  205. package/src/worldPresets.js +4 -1
@@ -0,0 +1,186 @@
1
+ # Environment shading
2
+
3
+ A modern anime-style scene shader for rooms, props, and terrain. It targets three
4
+ input classes with no shader edits: convention-named texture packs
5
+ (Liyue-style `Diffuse/SMBE/LSAB/ESA/Normal` siblings), standard glTF scenes,
6
+ and untextured/flat-color scenes.
7
+
8
+ ```js
9
+ import {
10
+ applyEnvironmentShader,
11
+ resolveEnvironmentPreset,
12
+ createEnvironmentSunRig,
13
+ createEnvironmentLampRig,
14
+ captureEnvironmentAmbientProbe,
15
+ createEnvironmentPlanarReflection,
16
+ advanceEnvironmentShaderTime,
17
+ } from '@call-me-sensei/toonlab/environment';
18
+
19
+ const preset = resolveEnvironmentPreset('interiorDay');
20
+ await applyEnvironmentShader(root, { environmentBox, hasSun: true, ...preset });
21
+
22
+ const sun = createEnvironmentSunRig({ scene, environmentBox });
23
+ const lamps = createEnvironmentLampRig({ scene, environmentBox, root, spot: { castShadow: true } });
24
+ captureEnvironmentAmbientProbe({ renderer, scene, position: roomCenter });
25
+
26
+ // per frame:
27
+ advanceEnvironmentShaderTime(delta);
28
+ ```
29
+
30
+ (Inside this repo the labs import from `../../src/environment/...`.)
31
+
32
+ ## Adapter and settings
33
+
34
+ `applyEnvironmentShader(root, options)` walks the scene, resolves texture
35
+ sets, classifies material roles, and converts materials. Configuration is
36
+ `{ features, parameters }`, normalized by `createEnvironmentSettings()`:
37
+
38
+ ```js
39
+ await applyEnvironmentShader(sceneRoot, {
40
+ features: { packedMap: true, shadowMask: true, skyTint: true, spotLights: true },
41
+ parameters: {
42
+ exposure: 0.95,
43
+ ambientLightInfluence: 0.22,
44
+ shadowTintColor: [0.86, 0.82, 0.78],
45
+ saturation: 1.08,
46
+ },
47
+ });
48
+ ```
49
+
50
+ All 72 fields are in the [settings reference](settings-reference.md)
51
+ (`ENVIRONMENT_SETTING_GROUPS` / `ENVIRONMENT_SETTING_FIELD_SCHEMA`); color
52
+ parameters accept `THREE.Color`, hex strings/numbers, `{ r, g, b }`, or
53
+ `[r, g, b]`. Runtime re-tuning goes through
54
+ `applyEnvironmentSettingsToMaterial(material, settings)`.
55
+
56
+ The shader consumes standard maps — `normalMap` (derivative-TBN, no tangents
57
+ required), `aoMap`/`lightMap` (uv1/uv2-aware, warm-tinted occlusion,
58
+ painterly lightmap remap), `emissiveMap` (scaled down by day, full at night)
59
+ — plus convention-pack siblings found by filename probing. Every sampler is
60
+ define-gated per material, so unused maps cost nothing. Author hooks:
61
+ `material.userData.envNormalMap/envAoMap/envLightMap/envEmissiveMap`.
62
+
63
+ ## Classification and roles
64
+
65
+ Materials get environment roles — foliage, window cutout, emissive, shadow
66
+ mesh, AO overlay, glossFloor — resolved in priority order:
67
+
68
+ 1. `userData.envRole` on the material or mesh,
69
+ 2. conversion option `roleOverrides: [{ match, role }]`,
70
+ 3. built-in keyword heuristics (`classifyEnvironmentMaterialRole`).
71
+
72
+ `applyEnvironmentShader` returns a `classification` report
73
+ (`{ object, material, role, source }` per material) so misfires are
74
+ diagnosable at a glance.
75
+
76
+ ## Presets and preset documents
77
+
78
+ `resolveEnvironmentPreset(name)` returns `{ features, parameters, rig }` for
79
+ `default`, `interiorDay`, `interiorEvening`, `interiorNight`,
80
+ `interiorStudio` (tuned for untextured scenes), `exteriorDay`, `showcase`,
81
+ and `call_me_sensei` — the studio-managed signature look, curated and
82
+ updated over releases. The `rig` hints (`sun`, `spotShadows`, `probe`,
83
+ `planarReflection`, `dustMotes`, `bakeVertexAo`, `lampIntensity`,
84
+ `timeOfDayHour`) tell the host app which rigs to construct — the labs
85
+ consume them automatically via `?envPreset=`.
86
+
87
+ Register your own, either in code or as a shareable JSON document
88
+ (`toonlab/environment-preset`, versioned and validated like toon presets):
89
+
90
+ ```js
91
+ import {
92
+ registerEnvironmentPreset,
93
+ createEnvironmentPresetDocument,
94
+ validateEnvironmentPresetDocument,
95
+ registerEnvironmentPresetDocument,
96
+ } from '@call-me-sensei/toonlab/environment';
97
+
98
+ registerEnvironmentPreset('myRoom', { features: {...}, parameters: {...}, rig: {...} });
99
+
100
+ const document = createEnvironmentPresetDocument('myRoom', { label: 'My Room' });
101
+ // ...save/share JSON.stringify(document), then on another machine:
102
+ const result = validateEnvironmentPresetDocument(document);
103
+ if (result.ok) registerEnvironmentPresetDocument(result.value, { overwrite: true });
104
+ ```
105
+
106
+ ## Rigs
107
+
108
+ Stylized light rigs positioned relative to the environment bounds
109
+ (`environmentRelativePoint`):
110
+
111
+ - `createEnvironmentSunRig({ scene, environmentBox })` — key directional
112
+ light plus visible sun disk, spill, beam, and shaft quads.
113
+ - `createEnvironmentLampRig({ scene, environmentBox, root, spot })` — lamp
114
+ point/spot lights with optional shadowed downlight spots;
115
+ `applyEnvironmentLampEmissive(root, multiplier)` couples fixture emissive
116
+ textures to lamp intensity.
117
+ - `createEnvironmentBackdrop(...)` — timed window backdrop
118
+ (morning/day/evening/night images, `environmentBackdropPeriodForHour`).
119
+ - `createEnvironmentDustMotes(...)` — deterministic drifting motes for sun
120
+ shafts.
121
+
122
+ ## Time of day
123
+
124
+ ```js
125
+ import { sampleEnvironmentTimeOfDay, applyEnvironmentTimeOfDay } from '@call-me-sensei/toonlab/environment';
126
+
127
+ const state = sampleEnvironmentTimeOfDay(17.5); // hour 0..24
128
+ applyEnvironmentTimeOfDay(state, { sunRig, lampRig, backdrop, environmentRoot });
129
+ ```
130
+
131
+ `sampleEnvironmentTimeOfDay(hour)` interpolates keyframed sun
132
+ color/intensity/position, ambient and lamp scales, sky tints, fog color, and
133
+ backdrop period (sunrise 06:00, sunset 18:00); `applyEnvironmentTimeOfDay`
134
+ pushes the sampled state everywhere in one call. In the labs: `?envTime=14`,
135
+ `?envFreezeTime=1` for deterministic captures.
136
+
137
+ ## Ambient probe
138
+
139
+ `captureEnvironmentAmbientProbe({ renderer, scene, position })` renders a
140
+ six-direction probe at a point (typically the room center) so ambient light
141
+ follows the room's own palette instead of a flat constant. Blend with the
142
+ `ambientProbeBlend` parameter; colors land on every converted material via
143
+ `setEnvironmentAmbientProbeColors`.
144
+
145
+ ## Planar reflection
146
+
147
+ `createEnvironmentPlanarReflection({ renderer, scene, camera, ... })` adds
148
+ one oblique-clipped mirror pass for glossy floors (`glossFloor` role),
149
+ fresnel-faded, including character reflections. Call `reflection.update()`
150
+ per frame. `detectEnvironmentFloorY(root)` finds the floor height.
151
+
152
+ ## Vertex AO for untextured scenes
153
+
154
+ With `bakeVertexAo: 'auto'` (the default), untextured meshes get per-vertex
155
+ ambient occlusion baked at conversion — BVH-accelerated
156
+ (`three-mesh-bvh`), deterministic, budgeted with explicit skip warnings.
157
+ Direct API: `bakeEnvironmentVertexAo`. Untextured materials also get a
158
+ designed gradient (floor falloff + sky tint) so flat-color rooms read
159
+ art-directed; the `interiorStudio` preset tunes the whole look for this
160
+ class.
161
+
162
+ ## Interior occlusion, fog, cloud shadows
163
+
164
+ - `setEnvironmentOpenings(openings)` + the `interiorOcclusionStrength`
165
+ parameter darken interiors based on where the real openings (windows,
166
+ doors) are.
167
+ - Converted materials participate in `scene.fog`, plus world-height fog via
168
+ `heightFogDensity/Falloff/Color`.
169
+ - `setEnvironmentCloudShadow({ strength, coverage, scale, velocity })`
170
+ drives the same procedural cloud-shadow field the grass, trees, and water
171
+ use; advance the shared clock once per frame with
172
+ `advanceEnvironmentShaderTime(delta)`.
173
+
174
+ ## Debug views
175
+
176
+ `?envDebug=<mode>` in the labs or `setEnvironmentDebugOutput(root, mode)` in
177
+ code renders one term in isolation:
178
+
179
+ ```text
180
+ albedo | lit | ambient | direct | shadowMask | pointLight | spotLight |
181
+ occlusion | bakedGi | normal | vertexAo | specular | emissive | windowMask |
182
+ roomOcclusion | alpha
183
+ ```
184
+
185
+ Debug branches compile out entirely unless requested. Captures freeze the
186
+ shared environment clock automatically (`?envFreezeTime=1`).
@@ -0,0 +1,180 @@
1
+ # Getting started
2
+
3
+ ## Clone and run
4
+
5
+ ```bash
6
+ git clone https://github.com/call-me-sensei/toonlab.git && cd toonlab
7
+ npm install
8
+ npm run dev
9
+ ```
10
+
11
+ Vite opens `http://localhost:5175` on the curated Labs home. Pick **Character
12
+ Shader Lab** (`/shader-lab/`) to see the bundled CC0
13
+ mannequin already toon-shaded. Everything you see out of the box — water,
14
+ sky, grass, trees, flowers, splashes — is procedural; the mannequin is the
15
+ only bundled model.
16
+
17
+ Rendering uses Three's `WebGPURenderer` by default. Use `?renderer=webgl` for
18
+ the TSL WebGL2 fallback, or `?renderer=webgpu` to make the default explicit.
19
+
20
+ `npm run build` produces a production build in `dist/`.
21
+
22
+ ## The labs
23
+
24
+ The lab UIs live in `labs/` and are not part of the npm package. The catalog
25
+ separates Shader Labs, Asset Labs, World Systems, and gameplay demos; some
26
+ supporting editors are available only by direct URL. See
27
+ [Lab responsibilities](lab-architecture.md) for the ownership rules.
28
+
29
+ | Lab | URL | What it shows |
30
+ |---|---|---|
31
+ | Labs home | `/` | The curated catalog, grouped into Shader Labs, Asset Labs, World Systems, and demos. |
32
+ | Character Shader Lab | `/shader-lab/` | A focused editor for the shared character treatment: every toon setting (23 groups), preset selection/export/import, debug views, and animation playback. Exercises `@call-me-sensei/toonlab/toon` and `@call-me-sensei/toonlab/debug`; the mannequin is preview content, not part of the preset. |
33
+ | Environment Shader Lab | `/environment-lab/` | A focused editor for the shared environment-material treatment: feature paths, light response, interior occlusion, surface styling, preset selection/export/import, and debug views. Exercises `@call-me-sensei/toonlab/environment`; the room, lights, camera, and walk controls are preview-only. |
34
+ | Playground: Controller Test | `/playground/` | Third-person character controller (WASD + mouse, Space to jump, Shift to sprint) on a vegetated stage. Exercises `@call-me-sensei/toonlab/character` retargeting + the vegetation systems. |
35
+ | Environment Playground (Indoor) | `/playground/?scene=indoor` | Walkable indoor environment scene with a live Environment Settings panel (every environment shader feature and parameter from the field schema). Loads the first environment from your gitignored `assets-local/environments/` drop-in (bring your own scene — a load banner appears without one). Exercises `@call-me-sensei/toonlab/environment` + `@call-me-sensei/toonlab/debug`. |
36
+ | Lighting Lab | `/lighting-lab/` | A focused lighting authoring and diagnostics surface with editable light outliner, transforms, physical/artistic intensity, shadow and quality budgets, five test stages, many-light stress testing, reusable JSON presets, and Unreal Engine 5.8 MegaLights/Lumen intent export. Exercises `@call-me-sensei/toonlab/lighting`. |
37
+ | Weather Lab | `/weather-lab/` | The standalone weather editor: 22 shared conditions, smooth transitions, live atmosphere/wind/precipitation/lightning/surface controls, a lightning test, and portable preset import/save/export. Exercises `@call-me-sensei/toonlab/weather` across sky, light, fog, vegetation, water, and GPU precipitation. |
38
+ | Water Lab | `/water-lab/` | The standalone water editor: every authored preset field for waves, surface color, foam, lighting/reflections, ripples, and splashes, plus construction-time quality selection, preset save/load/export, debug views, and interactor toys (splashes, buoyant balls, rain). Three stage grounds follow the preset — a gentle beach where the swash runs up and down the sand, a beach-to-deep basin with depth-test rocks/fish/kelp, and open water with a small island and a floating CC0 ship (PolyHaven `dutch_ship_medium` from `assets-local/`, toon boat fallback). **Preview in scene** carries your authored settings into the walkable Water Playground. Exercises the full `@call-me-sensei/toonlab/water` system. |
39
+ | Sky Lab | `/sky-lab/` | The standalone sky-system editor: gradient curves, horizon scattering, sun-disc and glow treatment, painterly cloud structure/motion, star pattern/twinkle, portable presets, and renderer parity. Lighting, weather, and camera are preview-owned rather than saved in the sky preset. Exercises `@call-me-sensei/toonlab/sky`. |
40
+ | Water Playground | `/playground/?scene=water` | The walkable beach diorama — wadeable lake (ripples, wakes, buoyancy), flowing river with current, and ocean beach with shoaling swell, plunging breakers, and swash. Walk in past chest depth and the character swims; C/Ctrl dives, Space swims up. **Edit in Water Lab** round-trips the live settings back to the editor. |
41
+ | Rock Lab | `/rock-lab/` | Procedural stylized rocks, cliffs, heightfields, sculpt edits, and GLB export from `@call-me-sensei/toonlab/rockgen`. |
42
+ | Tree Lab | `/tree-lab/` | Procedural stylized trees and bushes, sketch authoring, attached canopy blossoms, recipes, and GLB export from `@call-me-sensei/toonlab/vegetation`. |
43
+ | Flower Lab | `/flower-lab/` | Standalone procedural flowers with stem, leaf, bloom, recipe, and GLB controls from `@call-me-sensei/toonlab/vegetation`. |
44
+ | Grass Lab | `/grass-lab/` | Procedural blade dimensions, planting-ready grass material data, motion response, coordinated base/tip/shadow palettes, portable presets, and gameplay-scale previews from `@call-me-sensei/toonlab/vegetation`. Current scene light and preview placement are not saved. |
45
+ | Vegetation Shader Lab | `/vegetation-shader-lab/` | One IP-wide vegetation treatment, validated across grass, foliage, flowers, bark, and stems while asset palette and scene-owned wind, wetness, and snow remain outside the shader profile. |
46
+ | Debris Lab | `/debris-lab/` | Procedural debris and scatter pieces with preset thumbnails and GLB export from `@call-me-sensei/toonlab/debrisgen`. |
47
+ | Texture Lab | `/texture-lab/` | Seamless procedural PBR textures for anything — 60+ material presets, layered pattern/color/overlay controls, an AI prompt box (offline mapper built in; add your own Gemini/OpenAI key for smarter mapping), and PNG/ZIP export from `@call-me-sensei/toonlab/texgen`. |
48
+ | Outdoor World | `/examples/outdoor-world/` | Walkable integration scene for terrain, paths, bridges, villages, lighting, water, and vegetation at world scale. |
49
+ | VFX Arena | `/examples/vfx-arena/` | Walkable combat-effects integration scene for `@call-me-sensei/toonlab/vfxgen`. |
50
+ | Fauna Demo | `/examples/fauna-demo/` | Gameplay-scale preview for birds, butterflies, dragonflies, and koi from `@call-me-sensei/toonlab/fauna`. |
51
+ | Ambient VFX Demo | `/examples/ambientfx-demo/` | Gameplay-scale preview for petals, leaves, fireflies, pollen, and mist from `@call-me-sensei/toonlab/ambientfx`. |
52
+ | Prop Lab | `/prop-lab/` | Direct supporting editor for procedural prop recipes, placement contracts, and export. |
53
+ | Building Lab | `/building-lab/` | Direct supporting editor for procedural building recipes and export. |
54
+ | Gallery | `/gallery/` | Search and import open third-party textures, models, and HDRIs from supported public sources. |
55
+
56
+ These categories describe ownership, not just navigation. Shader Labs save a
57
+ reusable IP-wide material treatment; Asset Labs save the identity, geometry,
58
+ and material data of an asset class; World Systems save coupled runtime
59
+ behavior and appearance. Sky and Water therefore keep their shader controls in
60
+ their complete system presets instead of creating separate Sky Shader or Water
61
+ Shader documents.
62
+
63
+ ### World-system composition and quality
64
+
65
+ For both `StylizedSky` and `WaterSurface`, `.settings` is the authored baseline
66
+ used by portable documents. Lighting, Weather, or another live scene owner
67
+ should use a unique id with `setSceneOverrideLayer(id, valuesOrResolver)` and
68
+ remove only that id with `clearSceneOverrideLayer(id)`. The composed result is
69
+ available through `.renderedSettings`; it must not be written back into a
70
+ preset. `setSceneOverrides()` is only the convenience manual layer, and
71
+ `clearAllSceneOverrideLayers()` is reserved for an explicit full teardown.
72
+
73
+ Create a `LightingSystem`, then call `lighting.attachWorld(world)` to drive the
74
+ world-owned sun adapter and private Lighting layers for Sky and Water. When the
75
+ world has Weather, it also installs Lighting as Weather's sun/ambient/fog
76
+ bridge: Lighting remains the sole writer for those outputs, while Weather
77
+ supplies modulation and its own higher-priority Sky/Water layers. Detaching
78
+ Lighting restores its world state and clears only Lighting-owned layers.
79
+
80
+ A Sky preset contains exactly 46 portable art fields; dome radius and quality
81
+ are runtime policy. Named Sky quality tiers compile 2, 3, or 4 cloud octaves,
82
+ and `{ cloudOctaves: 1..5 }` defines a custom tier. `sky.setQuality()` rebuilds
83
+ the Sky material while preserving authored settings and live layers. Water
84
+ quality is also compile-time, but is selected when constructing
85
+ `WaterSurface`; changing it requires replacing/rebuilding the surface. The
86
+ Water Lab performs that rebuild, while `water.applySettings()` remains a live
87
+ art/simulation update rather than a quality switch.
88
+
89
+ The water scenes expose an **Env** lighting select (Noon / Sunset / Moonlit /
90
+ Overcast / Storm), water **Mode** and **Tone** selects, quality tiers, debug
91
+ views (`?waterDebug=foam`, `depth`, `ripple`, ...), and Drop Ball / Drop
92
+ Sinker buttons for buoyancy testing.
93
+
94
+ ## URL params, persistence, and Reset Lab
95
+
96
+ Every URL parameter has a HUD control — the HUD writes the parameter back
97
+ into the URL, so any lab state is shareable as a deep link. Key params:
98
+
99
+ ```text
100
+ ?model=<path or URL> character model (see below)
101
+ ?toonPreset=default toon preset
102
+ ?toonDebug=band toon debug view (docs/toon-shading.md)
103
+ ?envPreset=interiorDay environment preset
104
+ ?envDebug=albedo environment debug view (docs/environment.md)
105
+ ?waterMode=ocean water preset; ?waterTone=, ?waterQuality=, ?waterDebug=
106
+ ?skyPreset=golden_hour sky system preset
107
+ ?post=1&postPreset=softAnime post-processing (docs/post-processing.md)
108
+ ```
109
+
110
+ Lab state (selected model, presets, debug views) is saved per lab in
111
+ `localStorage` and restored when you return with a bare URL. An explicit URL
112
+ parameter always wins over a stored value. The **Reset Lab** button clears
113
+ the stored state for the current lab and reloads it clean.
114
+
115
+ ## Loading your own models
116
+
117
+ Three ways, no code changes required (details in
118
+ [characters.md](characters.md)):
119
+
120
+ 1. **Model URL input** — paste any local path or hosted URL into the HUD's
121
+ Model URL field (or use `?model=`). Supported formats: GLB/glTF, VRM 0
122
+ and 1, PMX/PMD, FBX, OBJ (+ `&mtl=`), and text-based USDZ. Hosted URLs
123
+ must be served with CORS headers (`Access-Control-Allow-Origin`);
124
+ failures show an error banner in the HUD instead of a blank scene.
125
+ 2. **`assets-local/` drop-in folder** — a gitignored folder for private test
126
+ assets. Drop a character in `assets-local/models/` and run
127
+ `npm run assets:local`; it appears in every model-aware lab's Model select alongside
128
+ the bundled mannequin. A model is picked up when its path matches one of
129
+ these shapes (sibling textures/materials load automatically):
130
+
131
+ ```
132
+ assets-local/models/hero.glb # loose file
133
+ assets-local/models/hero/hero.pmx # folder named after the character
134
+ assets-local/models/hero/model.vrm # or a "model.*" main file
135
+ assets-local/models/hero/source/hero.fbx # packaged marketplace download
136
+ assets-local/models/tests/<FORMAT>/<name>/… # format test grid
137
+ ```
138
+
139
+ Nothing in `assets-local/` is ever committed or published. The discovery
140
+ rules live in `labs/shared/localModelCatalog.js`.
141
+ 3. **Bundled default** — the CC0 Quaternius mannequin
142
+ (`public/characters/mannequin.glb`) with 45 embedded clips, so every
143
+ character/model preview works with zero downloads.
144
+
145
+ ### Mixamo animation clips
146
+
147
+ Models without embedded locomotion clips are animated by retargeting Mixamo
148
+ FBX clips. Adobe's terms do not allow redistributing the clips, so download
149
+ them with your own Adobe account from [mixamo.com](https://www.mixamo.com)
150
+ and drop the FBX files into `assets-local/animations/` (e.g. `Idle.fbx`,
151
+ `Walking.fbx`, `Swimming.fbx`). Without them, models fall back to their own
152
+ embedded clips. See [ATTRIBUTION.md](../ATTRIBUTION.md) for the full
153
+ asset-licensing picture.
154
+
155
+ ## Regenerating the settings reference
156
+
157
+ [settings-reference.md](settings-reference.md) is generated from the settings
158
+ schemas — never edit it by hand:
159
+
160
+ ```bash
161
+ node scripts/generate-settings-reference.mjs
162
+ ```
163
+
164
+ The script starts its own dev server on port 5192, extracts every settings
165
+ schema through a headless browser, and writes the markdown. Set
166
+ `TOONLAB_DOCS_BASE_URL=http://localhost:5175` to reuse a dev server that is
167
+ already running.
168
+
169
+ ## Next steps
170
+
171
+ - [Toon character shading](toon-shading.md)
172
+ - [Environment shading](environment.md)
173
+ - [Lighting](lighting.md)
174
+ - [Generative style labs](style-labs.md)
175
+ - [Water](water.md)
176
+ - [Sky](sky.md)
177
+ - [Vegetation](vegetation-sky.md)
178
+ - [Post-processing](post-processing.md)
179
+ - [Characters and animation](characters.md)
180
+ - [Debug panel](debug-panel.md)
@@ -0,0 +1,14 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpath d='M0 0H100V78L78 100H0Z' fill='%23e8332e'/%3E%3Ctext x='50' y='72' font-size='64' font-weight='900' font-family='Hiragino Sans, Yu Gothic, Noto Sans JP, sans-serif' fill='white' text-anchor='middle'%3E%E3%83%88%3C/text%3E%3C/svg%3E" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
+ <meta name="description" content="ToonLab open-source documentation: use the runtime library, connect the local MCP server, and drive it all with an AI coding agent." />
8
+ <title>Documentation — ToonLab</title>
9
+ </head>
10
+ <body>
11
+ <div id="app"></div>
12
+ <script type="module" src="/docs/main.jsx"></script>
13
+ </body>
14
+ </html>
@@ -0,0 +1,100 @@
1
+ # Lab responsibilities
2
+
3
+ ToonLab separates authoring tools by the lifetime and reuse scope of the
4
+ artifact they produce. A lab is not named after every shader program it happens
5
+ to use; it is named after the reusable thing a developer saves and ships.
6
+
7
+ ## What “shader” means here
8
+
9
+ A shader is GPU code plus a stable parameter contract that defines how a class
10
+ of materials responds to light, view direction, shadows, and other world
11
+ inputs. The shader implementation may have several technical variants, while
12
+ one saved profile supplies the coherent art direction for an IP.
13
+
14
+ The shader profile does not own an asset's geometry, textures, base color, or
15
+ species. It also does not own the scene's current sun, wind, wetness, or snow.
16
+ Those values are inputs to the profile.
17
+
18
+ ## Catalog groups
19
+
20
+ | Group | Saved artifact | Labs | Responsibility |
21
+ |---|---|---|---|
22
+ | Shader Labs | An IP-wide rendering profile | Character Shader Lab, Vegetation Shader Lab, Environment Shader Lab | Reusable material treatment across many compatible assets. |
23
+ | Asset Labs | A model, texture, or asset recipe | Rock Lab, Tree Lab, Flower Lab, Grass Lab, Debris Lab, Texture Lab | Geometry, species/shape identity, material data, and export. |
24
+ | World Systems | A complete runtime-system preset | Water Lab, Sky Lab | Coupled appearance, animation/simulation, runtime integration, and quality behavior. |
25
+ | Playgrounds & demos | No production preset of their own | Playground, Water Playground, Outdoor World, VFX Arena, Fauna Demo, Ambient VFX Demo | Validate authored artifacts in gameplay-scale scenes. |
26
+
27
+ Weather Lab and Lighting Lab are direct supporting editors for their npm
28
+ systems. They are not shader profiles: Weather coordinates current world
29
+ state, while Lighting authors light rigs and day-cycle behavior.
30
+
31
+ ## Why Water and Sky are not separate Shader Labs
32
+
33
+ Water and sky both contain substantial GPU shading, but their useful shipping
34
+ artifact is larger than a material profile.
35
+
36
+ - A Water preset keeps surface color, refraction, reflections, and foam
37
+ together with waves, shoreline behavior, ripples, splashes, underwater
38
+ response, and quality limits. Its Surface, Foam, and Lighting groups are the
39
+ embedded water-shader controls.
40
+ - A Sky preset keeps the gradient, horizon scattering, sun, procedural clouds,
41
+ stars, and animation behavior together. Its
42
+ Gradient, Sun, Clouds, and Stars groups are the embedded sky-shader controls.
43
+
44
+ Splitting either system into a second shader lab would create two documents
45
+ that must be kept compatible and would make ownership of shared parameters
46
+ unclear. The system lab therefore owns one versioned preset and exposes its
47
+ shader/appearance section explicitly.
48
+
49
+ ## Parameter scope
50
+
51
+ | Scope | Examples | Saved by |
52
+ |---|---|---|
53
+ | IP shader profile | Cel bands, shadow-color treatment, thin-surface response, role-specific bark or petal lighting | Character, Vegetation, or Environment Shader Lab |
54
+ | Runtime-system preset | Water spectrum and surface response; sky gradient, sun disc, cloud shapes, star field, and cloud motion | Water or Sky Lab |
55
+ | Asset/material | Grass base/tip/shadow palette, flower species colors, bark texture, mesh topology | Asset Lab document |
56
+ | Scene/world state | Current time, sun direction, weather, wind, wetness, snow, exposure | Host game, Weather, or Lighting system |
57
+ | Instance/interaction | Placement, seed, scale, bend target, splash source | Host game or preview scene |
58
+
59
+ Lab previews may expose scene and instance controls so an artifact can be
60
+ tested, but preview-only values are labeled and excluded from exported preset
61
+ documents. Sky-dome radius remains a runtime constructor option for
62
+ compatibility, but because the dome is pinned to the far plane it has no
63
+ art-direction effect and is not surfaced or saved by Sky Lab.
64
+
65
+ System presets may carry authored fallback sun/sky values so Water or Sky
66
+ renders coherently in isolation. In a composed world those are baselines, not
67
+ competing owners: Lighting installs priority-100 Sky/Water layers and drives
68
+ the world sun-direction adapter; Weather supplies Lighting modulation plus
69
+ priority-200 Sky/Water layers; a manual scene layer is priority 300. Portable
70
+ `settings` remain unchanged and effective `renderedSettings` stay inspectable.
71
+ Each system clears only its own Symbol-keyed layer on teardown.
72
+
73
+ World Systems also own deployment behavior without confusing it with art. Sky
74
+ quality is a non-portable compile-time preview/device tier. Water retains a
75
+ portable preferred quality default for compatibility, but hosts choose the
76
+ actual tier when constructing the surface. Neither is a reason to split out a
77
+ second shader document.
78
+
79
+ ## npm boundary
80
+
81
+ Labs are development tools and are not published in the npm package. Every
82
+ artifact they produce maps to a public runtime import:
83
+
84
+ ```text
85
+ Character Shader Lab -> @call-me-sensei/toonlab/toon
86
+ Vegetation Shader Lab -> @call-me-sensei/toonlab/vegetation
87
+ Environment Shader Lab -> @call-me-sensei/toonlab/environment
88
+ Water Lab -> @call-me-sensei/toonlab/water
89
+ Sky Lab -> @call-me-sensei/toonlab/sky
90
+ ```
91
+
92
+ The package owns settings normalization, schemas, preset registries, versioned
93
+ document validation and serialization, runtime application, and lifecycle
94
+ methods. The lab is a consumer of those APIs; it must not maintain a private
95
+ copy of the production contract.
96
+
97
+ `@call-me-sensei/toonlab/styles` can embed the typed documents produced by
98
+ these labs. Its `vegetationShader`, `grass`, `water`, and `sky` slots validate
99
+ the corresponding public document type and resolve it to runtime settings, so
100
+ a published style bundle does not depend on a browser lab's private storage.