@genex-ai/cli-demo 0.6.0 → 0.6.2

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 (45) hide show
  1. package/dist/index.js +5 -0
  2. package/package.json +1 -1
  3. package/templates/skills/genex-threejs-atmosphere-aerial-perspective/SKILL.md +30 -18
  4. package/templates/skills/genex-threejs-atmosphere-aerial-perspective/references/atmosphere.md +204 -20
  5. package/templates/skills/genex-threejs-bloom/SKILL.md +29 -18
  6. package/templates/skills/genex-threejs-bloom/references/bloom.md +176 -20
  7. package/templates/skills/genex-threejs-camera-direction/SKILL.md +38 -26
  8. package/templates/skills/genex-threejs-camera-direction/references/camera-rigs.md +359 -27
  9. package/templates/skills/genex-threejs-exposure-color-grading/SKILL.md +27 -18
  10. package/templates/skills/genex-threejs-exposure-color-grading/references/exposure-grading.md +196 -21
  11. package/templates/skills/genex-threejs-image-pipeline/SKILL.md +38 -17
  12. package/templates/skills/genex-threejs-image-pipeline/references/image-pipeline.md +185 -29
  13. package/templates/skills/genex-threejs-procedural-animation/SKILL.md +34 -21
  14. package/templates/skills/genex-threejs-procedural-animation/references/procedural-motion.md +353 -24
  15. package/templates/skills/genex-threejs-procedural-architecture/SKILL.md +36 -17
  16. package/templates/skills/genex-threejs-procedural-architecture/references/architecture-systems.md +500 -22
  17. package/templates/skills/genex-threejs-procedural-fields/SKILL.md +59 -24
  18. package/templates/skills/genex-threejs-procedural-fields/references/field-systems.md +222 -25
  19. package/templates/skills/genex-threejs-procedural-geometry/SKILL.md +34 -20
  20. package/templates/skills/genex-threejs-procedural-geometry/references/mesh-systems.md +192 -26
  21. package/templates/skills/genex-threejs-procedural-materials/SKILL.md +55 -18
  22. package/templates/skills/genex-threejs-procedural-materials/references/material-systems.md +189 -22
  23. package/templates/skills/genex-threejs-procedural-planets/SKILL.md +36 -18
  24. package/templates/skills/genex-threejs-procedural-planets/references/planet-systems.md +489 -21
  25. package/templates/skills/genex-threejs-procedural-vegetation/SKILL.md +35 -25
  26. package/templates/skills/genex-threejs-procedural-vegetation/references/vegetation-systems.md +304 -27
  27. package/templates/skills/genex-threejs-procedural-vfx/SKILL.md +26 -18
  28. package/templates/skills/genex-threejs-procedural-vfx/references/vfx-systems.md +208 -20
  29. package/templates/skills/genex-threejs-raymarched-space-effects/SKILL.md +25 -18
  30. package/templates/skills/genex-threejs-raymarched-space-effects/references/space-effects.md +185 -21
  31. package/templates/skills/genex-threejs-screen-space-ambient-occlusion/SKILL.md +23 -17
  32. package/templates/skills/genex-threejs-screen-space-ambient-occlusion/references/ambient-occlusion.md +430 -20
  33. package/templates/skills/genex-threejs-shadow-systems/SKILL.md +29 -18
  34. package/templates/skills/genex-threejs-shadow-systems/references/shadow-systems.md +420 -21
  35. package/templates/skills/genex-threejs-skill-router/SKILL.md +21 -21
  36. package/templates/skills/genex-threejs-spectral-ocean/SKILL.md +30 -20
  37. package/templates/skills/genex-threejs-spectral-ocean/references/spectral-ocean.md +462 -22
  38. package/templates/skills/genex-threejs-temporal-surfaces/SKILL.md +26 -17
  39. package/templates/skills/genex-threejs-temporal-surfaces/references/temporal-surfaces.md +198 -20
  40. package/templates/skills/genex-threejs-visual-validation/SKILL.md +34 -18
  41. package/templates/skills/genex-threejs-visual-validation/references/visual-validation.md +396 -32
  42. package/templates/skills/genex-threejs-volumetric-clouds/SKILL.md +33 -17
  43. package/templates/skills/genex-threejs-volumetric-clouds/references/volumetric-clouds.md +570 -21
  44. package/templates/skills/genex-threejs-water-optics/SKILL.md +33 -18
  45. package/templates/skills/genex-threejs-water-optics/references/water-optics.md +184 -20
@@ -1,37 +1,314 @@
1
- # Vegetation Systems
1
+ # Structured Ash growth system
2
2
 
3
- Use this reference for trees, plants, and grass in Genex games.
3
+ Use this reference when the target is a natural deciduous Ash with a stable species identity. Preserve the species table, continuation model, branch geometry, foliage, rooted wind, and composition contracts before tuning.
4
4
 
5
- ## Species definition
5
+ ## Contents
6
6
 
7
- Declare:
7
+ 1. Species table
8
+ 2. Continuation and child placement
9
+ 3. Branch growth and geometry
10
+ 4. Leaves and wind
11
+ 5. Bark, meadow, and scene composition
12
+ 6. Budgets, divergences, and diagnostics
8
13
 
9
- - height and width range;
10
- - trunk taper and bend;
11
- - branch count and angles;
12
- - canopy shape;
13
- - leaf size and clustering;
14
- - bark and leaf material identity;
15
- - wind response;
16
- - gameplay function such as cover, obstacle, collectible, or landmark.
14
+ ## 1. Preserve the exact species table before tuning
17
15
 
18
- ## Branch hierarchy
16
+ The Ash Medium species contract is:
19
17
 
20
- - Emit trunk first with a stable radius curve.
21
- - Spawn primary branches from height bands.
22
- - Spawn secondary branches from primary branch frames.
23
- - Align leaf clusters to branch direction and local light bias.
24
- - Keep branch rings oriented with a stable frame to avoid twisting.
18
+ | Level | Length | Base radius factor | Sections | Radial segments | Child angle | Children | Child start | Gnarliness | Twist |
19
+ | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: | ---: |
20
+ | 0 trunk | 43.47 | 2.00 | 12 | 12 | — | 7 | — | 0.03 | 0.09 |
21
+ | 1 primary | 27.14 | 0.63 | 8 | 6 | 48° | 4 | 0.23 | 0.25 | -0.07 |
22
+ | 2 secondary | 9.51 | 0.76 | 6 | 4 | 75° | 3 | 0.33 | 0.20 | 0 |
23
+ | 3 terminal | 4.60 | 0.70 | 4 | 3 | 60° | 0 | 0 | 0.09 | 0 |
25
24
 
26
- ## Placement
25
+ All levels use taper `0.7`. Growth force points up with strength `0.01`.
27
26
 
28
- - Use terrain slope, moisture, altitude, and gameplay zones as masks.
29
- - Leave readable paths and playable spaces.
30
- - Vary seed and scale without changing species identity.
27
+ Leaves:
31
28
 
32
- ## Wind
29
+ ```text
30
+ type: ash
31
+ count per terminal branch: 16
32
+ start: 0
33
+ angle: 55°
34
+ double perpendicular cards
35
+ size: 2.67
36
+ size variance: ±0.72
37
+ alpha test: 0.5
38
+ rounded normals: enabled
39
+ ```
33
40
 
34
- - Drive wind from a shared vector field.
35
- - Use lower-frequency bend for trunk and branches.
36
- - Use higher-frequency flutter for leaves.
37
- - Keep wind amplitude within the silhouette promised by collision/proxy shapes.
41
+ Do not replace this table with guessed “tree-like” ranges before the contract
42
+ is reproduced. Species identity is encoded in the uneven angles, lengths,
43
+ starts, and child counts.
44
+
45
+ ## 2. Match the branch continuation model
46
+
47
+ The generator creates two types of descendants:
48
+
49
+ 1. stratified lateral children along the parent;
50
+ 2. one terminal continuation branch from the parent tip for every deciduous level until the final level.
51
+
52
+ That continuation is essential to the sparse, irregular crown. A generator that creates only lateral children produces a candelabra or clipped crown.
53
+
54
+ The terminal continuation inherits:
55
+
56
+ ```text
57
+ origin = final parent section origin
58
+ orientation = final parent section orientation
59
+ radius = final parent section radius
60
+ level = parent level + 1
61
+ sections and radial segments = parent values
62
+ length = next-level species length
63
+ ```
64
+
65
+ The inherited section/segment counts differ from ordinary lateral children, which use the next level's table values.
66
+
67
+ ## 3. Match section evolution
68
+
69
+ The implementation contains:
70
+
71
+ ```text
72
+ sectionLength =
73
+ branchLength
74
+ / sectionCount
75
+ / (branchLevels - 1)
76
+ ```
77
+
78
+ but guards the divisor with a comparison against the string `'Deciduous'`.
79
+ The preset stores `'deciduous'`, so this build does **not** take that
80
+ branch. Effective runtime behavior is:
81
+
82
+ ```text
83
+ sectionLength = branchLength / sectionCount
84
+ ```
85
+
86
+ For Ash Medium this doubles the height relative to the apparent intent. The
87
+ complete build produces branch bounds reaching roughly `y=80.30` and leaf
88
+ bounds reaching `y=83.69`. Preserve the actual runtime behavior.
89
+ Do not infer behavior from one line without executing the complete growth path.
90
+
91
+ At every section:
92
+
93
+ 1. emit an XZ ring through the current Euler orientation;
94
+ 2. store origin, orientation, and radius;
95
+ 3. advance along rotated local +Y;
96
+ 4. perturb Euler X/Z by seeded gnarliness;
97
+ 5. apply level twist around local Y;
98
+ 6. rotate the section toward world growth force.
99
+
100
+ Gnarliness amplification:
101
+
102
+ ```text
103
+ effectiveGnarliness =
104
+ max(1, 1 / sqrt(sectionRadius))
105
+ * levelGnarliness
106
+ ```
107
+
108
+ The force angular step is:
109
+
110
+ ```text
111
+ forceStrength / sectionRadius
112
+ ```
113
+
114
+ clamped to the full angle between current local up and the target direction. Thin branches therefore respond more strongly than the trunk.
115
+
116
+ ## 4. Match taper and child radius semantics
117
+
118
+ Deciduous taper:
119
+
120
+ ```text
121
+ sectionRadius =
122
+ branchStartRadius
123
+ * (1 - levelTaper * sectionIndex / sectionCount)
124
+ ```
125
+
126
+ The final section of the final level collapses to a near-zero radius.
127
+
128
+ Lateral child radius is not simply the species radius:
129
+
130
+ ```text
131
+ childRadius =
132
+ levelRadiusFactor
133
+ * interpolatedParentSectionRadius
134
+ ```
135
+
136
+ This couples the child thickness to emergence height and parent taper.
137
+
138
+ ## 5. Match stratification and interpolation
139
+
140
+ For both lateral children and leaves:
141
+
142
+ ```text
143
+ along =
144
+ start
145
+ + (slotIndex + seededJitter)
146
+ * ((1 - start) / count)
147
+ ```
148
+
149
+ Independently shuffle angular slot IDs with the same seeded RNG:
150
+
151
+ ```text
152
+ azimuth =
153
+
154
+ * (radialOffset + (permutedSlot + jitter[-0.5, 0.5]) / count)
155
+ ```
156
+
157
+ Interpolate between adjacent stored sections:
158
+
159
+ - origin: linear interpolation;
160
+ - radius: linear interpolation;
161
+ - orientation: interpolation starts from section B and slerps toward
162
+ section A by `alpha`, reversing the usual A→B expectation.
163
+
164
+ Then compose:
165
+
166
+ ```text
167
+ parent orientation
168
+ × azimuth around local Y
169
+ × emergence angle around local X
170
+ ```
171
+
172
+ Do not derive child orientation from a newly constructed tangent frame; that changes the characteristic branch roll and twist.
173
+
174
+ ## 6. Match ring and bark UV construction
175
+
176
+ Each section emits `radialSegments + 1` vertices by duplicating the first radial vertex at the seam.
177
+
178
+ Choose one integer circumference wrap count for the entire branch:
179
+
180
+ ```text
181
+ wrapsX = max(1, round(branchStartRadius * barkTextureScaleX))
182
+ u = radialIndex / radialSegments * wrapsX
183
+ v = sectionIndex is even ? 0 : 1
184
+ ```
185
+
186
+ The texture's runtime Y repeat is `1 / barkTextureScaleY`.
187
+
188
+ This is not a real-distance longitudinal UV. If adapting the visual exactly, retain the alternating ring V pattern. If improving it, record the change as an intentional divergence and re-evaluate bark scale across trunk and twigs.
189
+
190
+ ## 7. Match leaf placement, card geometry, and normals
191
+
192
+ Leaves are emitted along every final-level branch, not in synthetic clusters at branch tips.
193
+
194
+ Each leaf is a square card extending from local base `y=0` to tip `y=L`, with width `W`. The double-card mode emits a second card rotated 90° around local Y.
195
+
196
+ Rounded vertex normal:
197
+
198
+ ```text
199
+ normalize(cardNormal + (vertexPosition - leafOrigin))
200
+ ```
201
+
202
+ Use the same unrotated card normal for both perpendicular cards before adding
203
+ the vertex direction. Preserve that quirk when reproducing the contract. A
204
+ corrected per-card normal is a legitimate extension but changes canopy
205
+ lighting and must be documented.
206
+
207
+ Use the bundled `ash.png` alpha silhouette. Replacing it with an ellipse or
208
+ analytic lozenge changes crown porosity and edge frequency enough to invalidate
209
+ visual comparison.
210
+
211
+ ## 8. Match material and wind behavior accurately
212
+
213
+ The complete scene uses:
214
+
215
+ - textured `MeshPhongMaterial` for bark;
216
+ - double-sided alpha-tested `MeshPhongMaterial` for leaves;
217
+ - Neutral tone mapping with exposure `2`;
218
+ - PCF shadows;
219
+ - fog color `0x94b9f8`, density `0.0015`;
220
+ - a daylight sky gradient and directional sun.
221
+
222
+ The wind shader deforms leaf vertices only:
223
+
224
+ ```text
225
+ windPhase = simplex3(position / 70)
226
+ wind =
227
+ 0.5 * sin(t * 0.5 + phase)
228
+ + 0.3 * sin(2t * 0.5 + 1.3phase)
229
+ + 0.2 * sin(5t * 0.5 + 1.5phase)
230
+ displacement = leafUvY * windStrength * wind
231
+ ```
232
+
233
+ `leafUvY` roots the card base and moves the tip. The demonstrated branch
234
+ geometry is static; do not describe this mechanism as hierarchy-weighted
235
+ trunk/branch wind.
236
+
237
+ If extending it with branch motion:
238
+
239
+ 1. keep the leaf-root weighting;
240
+ 2. add branch-level attributes separately;
241
+ 3. deform color and shadow geometry consistently;
242
+ 4. label the result as an extension to the contract.
243
+
244
+ ## 9. Match composition before judging the generator
245
+
246
+ Present the tree in a complete environment:
247
+
248
+ ```text
249
+ startup camera: (100, 20, 0)
250
+ target: (0, 25, 0)
251
+ horizontal camera constraint near the horizon
252
+ foreground tree at origin
253
+ 100 background trees using radius = 175 + random * 500 (effective 175–675)
254
+ procedural grass/dirt ground
255
+ 5,000 visible grass instances
256
+ flowers and rocks
257
+ blue atmospheric fog
258
+ daylight sky and sun
259
+ ```
260
+
261
+ The exact startup camera clips the leaf bound slightly because its
262
+ upper vertical coverage is approximately `y=82.7` while the leaf maximum is
263
+ approximately `y=83.69`. For a fixed 3:2 evaluation frame, move the camera
264
+ along the same target ray to approximately `x=115`; do not alter the tree to
265
+ solve a framing problem.
266
+
267
+ A black-background isolated tree is not a valid quality test. It removes
268
+ foliage edge contrast, atmospheric depth, ground contact, and scale cues.
269
+
270
+ ## 10. Required contract diagnostics
271
+
272
+ Capture:
273
+
274
+ ```text
275
+ final composition
276
+ branch-level colors
277
+ lateral children versus terminal continuations
278
+ child longitudinal slot IDs
279
+ child angular slot IDs
280
+ leaf origins along final branches
281
+ card normals versus rounded normals
282
+ bark UV checker
283
+ wind displacement magnitude
284
+ foreground bounds and camera frustum
285
+ ```
286
+
287
+ Report:
288
+
289
+ ```text
290
+ branch jobs by level
291
+ terminal continuations by level
292
+ lateral children by level
293
+ leaf cards
294
+ vertices and triangles
295
+ seed
296
+ preset name
297
+ intentional divergences from the growth contract
298
+ ```
299
+
300
+ ## 11. Numeric contract gate
301
+
302
+ For the Ash Medium contract, assert:
303
+
304
+ ```text
305
+ branch vertices: 6,639
306
+ branch triangles: 9,120
307
+ leaf vertices: 21,760
308
+ leaf triangles: 10,880
309
+ branch bounds max Y: approximately 80.2981
310
+ leaf bounds max Y: approximately 83.6902
311
+ ```
312
+
313
+ Matching only counts is insufficient; the earlier half-height implementation
314
+ matched all counts while violating runtime section-length behavior.
@@ -5,27 +5,35 @@ description: Author procedural real-time VFX for Genex Three.js games. Use for p
5
5
 
6
6
  # Genex Three.js Procedural VFX
7
7
 
8
- VFX should make player actions legible. Build effects as timed systems with
9
- budgets, not as one-off bursts.
8
+ Build effects from an event envelope, motion field, geometry representation, and shading response. Avoid independent particle emitters that happen to share a color.
10
9
 
11
- Read [references/vfx-systems.md](references/vfx-systems.md) for event timing,
12
- particles, trails, pooling, emission, and diagnostics.
10
+ ## Effect graph
13
11
 
14
- ## Build order
12
+ ```text
13
+ ship/event state
14
+ → effect-specific geometry or instance attributes
15
+ → flow-facing masks or analytic age
16
+ → material response
17
+ → pool/lifetime ownership
18
+ → HDR and bloom contribution
19
+ ```
15
20
 
16
- 1. Define the event: cause, start, peak, decay, gameplay meaning, and interrupt
17
- behavior.
18
- 2. Split effect layers into core shape, particles, trails, light, distortion,
19
- sound hooks, and decal/debris.
20
- 3. Use seeded variation for repeatable runs.
21
- 4. Pool high-count objects and dispose temporary resources.
22
- 5. Keep emission intensities scene-relative.
23
- 6. Expose debug controls for phase, layer toggles, counts, bounds, and overdraw.
21
+ Read [references/vfx-systems.md](references/vfx-systems.md)
22
+ for ship-conforming reentry shells, capsule wakes, dense instanced
23
+ spark/debris pools, HDR hierarchy, and implementation limits.
24
24
 
25
25
  ## Rules
26
26
 
27
- - Do not let bloom carry the shape of the effect.
28
- - Keep impact timing aligned to gameplay state.
29
- - Bound particle counts and lifetimes.
30
- - Use additive blending deliberately and inspect overdraw.
31
- - Provide low-quality versions for dense combat or mobile browsers.
27
+ - Every layer must have a role in silhouette, motion, illumination, or residue.
28
+ - Use normalized lifetime curves instead of scattered time constants.
29
+ - Derive secondary motion from the same flow or event direction.
30
+ - Keep bloom as a response to HDR emission, not as the effect's only shape.
31
+ - Pool instances and trails; do not allocate per burst.
32
+ - Expose spawn, simulation, overdraw, and luminance debug views.
33
+ - Include a non-bloom baseline that remains legible.
34
+
35
+ ## Routing boundary
36
+
37
+ Use `$genex-threejs-temporal-surfaces` only for the screen-space
38
+ frost/touch-history pipeline. Keep ship-space plasma, generated wakes, sparks,
39
+ and pooled debris in this skill.
@@ -1,30 +1,218 @@
1
- # Procedural VFX
1
+ # Layered procedural VFX systems
2
2
 
3
- Use this reference for action effects in Genex games.
3
+ Use this reference for ship-conforming reentry plasma, generated wakes, instanced analytic sparks, dissolving debris, dense-swap pools, and scene-relative HDR contribution.
4
4
 
5
- ## Event timeline
5
+ ## Contents
6
6
 
7
- - Anticipation: small cue before action when gameplay allows it.
8
- - Impact: strongest shape and brightness.
9
- - Decay: particles, trails, smoke, heat, or fragments.
10
- - Recovery: cleanup and return to readable scene state.
7
+ - Reentry representation
8
+ - Reentry shell shading
9
+ - Wake construction
10
+ - Instanced spark contract
11
+ - Debris dissolve and pool ownership
12
+ - HDR contribution
13
+ - Observed limitations
14
+ - Diagnostics
11
15
 
12
- ## Layers
13
16
 
14
- - Shape layer: shockwave, shell, beam, ring, or volume.
15
- - Particle layer: sparks, embers, fragments, droplets, or dust.
16
- - Trail layer: motion history or projectile path.
17
- - Light layer: short-lived local light or emissive material.
18
- - Surface layer: decal, scorch, foam, or dissolve mask.
17
+ ## Reentry representation
19
18
 
20
- ## Pooling
19
+ planet-space implementation does not model reentry as one particle emitter. It composes:
21
20
 
22
- - Preallocate repeated particles or meshes.
23
- - Reuse materials and geometries.
24
- - Track active counts and peak counts.
25
- - Avoid per-frame allocation during dense events.
21
+ ```text
22
+ ship-shaped front shell
23
+ + expanding capsule core wake
24
+ + larger low-opacity haze wake
25
+ + two asymmetric side shear lobes
26
+ ```
27
+
28
+ The shell is a clone of the actual ship mesh, scaled by `1.005`. This is the
29
+ key silhouette decision: plasma follows authored hull topology instead of a
30
+ generic sphere or cone.
31
+
32
+ The wake origin is found from sampled ship vertices. For the current local fall
33
+ direction, select the support point with the greatest dot product. Build an
34
+ orthonormal wake frame by projecting local up away from the fall direction,
35
+ falling back to local right when nearly parallel.
36
+
37
+ ```text
38
+ wake forward = normalized fall direction
39
+ wake up = projected local up
40
+ wake right = cross(up, forward)
41
+ wake origin = hull support point along fall direction
42
+ ```
43
+
44
+ ## Reentry shell shading
45
+
46
+ The shell mask uses actual flow-facing geometry:
47
+
48
+ ```text
49
+ facing = saturate(dot(normalWorld, -fallDirectionWorld))
50
+ facing mask = smoothstep(0.18, 0.96, facing)
51
+ ```
52
+
53
+ Two world-space noise bands move along fall direction:
54
+
55
+ ```text
56
+ coarse frequency = 3.6
57
+ fine frequency = 11.2
58
+ coarse/fine mix = 0.62 / 0.38
59
+ fine filament exponent = 3.1
60
+ flow speed basis = time * 5.4 + external flow * 0.08
61
+ ```
62
+
63
+ The shell shader separates:
64
+
65
+ - core heat from flow-facing area;
66
+ - Fresnel envelope around silhouette;
67
+ - a shock band requiring high facing, rim response, and filaments.
68
+
69
+ Color hierarchy is explicit:
70
+
71
+ ```text
72
+ hot core: orange -> near white
73
+ ion envelope: magenta -> violet
74
+ outer sheath: violet -> cyan
75
+ shock: white -> blue
76
+ ```
77
+
78
+ The final shell uses additive blending, no depth write, depth test on, double
79
+ sided, and negative polygon offset. Treat the additive multiplier as part of
80
+ the scene’s HDR calibration, not a portable physical unit.
81
+
82
+ ## Wake construction
83
+
84
+ Each wake is a generated capsule-profile tube. Along normalized length `t`:
85
+
86
+ ```text
87
+ z = -trailLength * t
88
+ radial spread = 1 + t^1.24 * expansion
89
+ axial spread = 1 + 0.1 * t
90
+ profile turbulence = 1 + sin(theta * 3.3 + t * 8.7) * 0.1 * t
91
+ ```
92
+
93
+ Dimensions relative to ship length:
94
+
95
+ ```text
96
+ profile length = 0.74
97
+ profile radius = 0.068
98
+ trail length = 1.55
99
+
100
+ core: 52 radial x 26 longitudinal, expansion 1.9
101
+ haze: 40 x 20, radius 1.2x, length 1.05x, opacity 0.28
102
+ lobes: 28 x 14, half profile, length 0.88x, opacity 0.34
103
+ ```
104
+
105
+ Wake shading uses elliptical profile distance, a front gate, tail fade,
106
+ coarse/fine longitudinal noise, Fresnel, and separate core/envelope/filament
107
+ colors. The core and haze use different scales and speeds instead of one mesh
108
+ with changed opacity.
109
+
110
+ ## Instanced spark contract
111
+
112
+ pooled VFX system preallocates a sprite pool of `12000`. Every instance stores:
113
+
114
+ ```text
115
+ startPosition vec3
116
+ startVelocity vec3
117
+ acceleration vec3
118
+ spawnTimeSeconds float
119
+ ```
120
+
121
+ Lifetime is `1.3 s`; velocity decay rate is `16`. Spark size falls linearly to
122
+ zero:
123
+
124
+ ```text
125
+ scale = max((1.3 - age) * 0.4 / 1.3, 0)
126
+ ```
127
+
128
+ The fragment is a circular sprite with radius `0.4`. HDR color interpolates
129
+ from `(1, 0.5, 0) * 80` toward dark red. Spawn adds random X/Z velocity in
130
+ `[-2, 2]`.
131
+
132
+ The pool is fixed-capacity and material attributes are per instance. No entity
133
+ owns an individual mesh.
134
+
135
+ ## Debris dissolve and pool ownership
136
+
137
+ Debris spheres use:
138
+
139
+ ```text
140
+ radius = 0.45
141
+ lifetime = random 2 -> 4 seconds
142
+ mass = 0.1
143
+ friction = 0.4
144
+ restitution = 0.8
145
+ gravity scale = 1.2
146
+ ```
147
+
148
+ Per-instance material data:
149
+
150
+ ```text
151
+ isOrange
152
+ removalTimeSeconds
153
+ ```
154
+
155
+ Geometry-space noise creates a spatial dissolve against remaining lifetime.
156
+ The material also adds a Fresnel-shaped color response, a directional fake-AO
157
+ tint, and a low environment term of `0.05`.
158
+
159
+ When an instance is removed, the render system swaps the last live instance
160
+ into the vacant slot and copies:
161
+
162
+ - the 4x4 instance matrix;
163
+ - every custom attribute slice;
164
+ - the entity-to-index mapping.
165
+
166
+ This dense-swap invariant is the reusable pooling mechanism. Updating only
167
+ `mesh.count` without copying custom attributes would attach old effect state to
168
+ the moved instance.
169
+
170
+ ## HDR contribution
171
+
172
+ The compact signals are intentionally bright before bloom:
173
+
174
+ ```text
175
+ spark core multiplier: 80
176
+ homing projectile multiplier: 30
177
+ laser multiplier: 10
178
+ ```
179
+
180
+ These values are evidence of relative hierarchy inside that scene, not
181
+ universal exposure-independent constants. Preserve the relationship:
182
+
183
+ ```text
184
+ spark flash > projectile > laser > ordinary surface
185
+ ```
186
+
187
+ Validate all three in the raw HDR buffer and with bloom disabled.
188
+
189
+ ## Observed limitations
190
+
191
+ - Spark position multiplies an already integrated decayed velocity by elapsed
192
+ time again. This is dimensionally inconsistent but visually deliberate.
193
+ Preserve it only when that trajectory is explicitly required.
194
+ - Acceleration uses `a * t^2` rather than `0.5 * a * t^2`, also an artistic
195
+ choice.
196
+ - Spark randomization uses `Math.random`, so captures are not deterministic.
197
+ Replace it with a seeded generator for regression work.
198
+ - The reentry wake disables depth test. This avoids hull intersections but can
199
+ draw through unrelated geometry. Validate camera and occluder assumptions.
200
+ - The shell and wakes are analytic procedural meshes, not fluid simulation.
201
+ Do not describe them as physically simulated plasma.
26
202
 
27
203
  ## Diagnostics
28
204
 
29
- Expose layer toggles, overdraw view, bounding volumes, active counts, lifetime
30
- histograms, and final/no-bloom captures.
205
+ Expose:
206
+
207
+ ```text
208
+ fall direction and support point
209
+ shell facing/core/envelope/shock masks
210
+ coarse and fine wake noise
211
+ wake profile distance and tail fade
212
+ raw HDR emission by layer
213
+ bloom contribution by layer
214
+ spark age, velocity, and pool occupancy
215
+ debris remaining time and dissolve threshold
216
+ instance index/entity mapping
217
+ overdraw and depth-test modes
218
+ ```
@@ -5,26 +5,33 @@ description: Build raymarched space effects for Genex Three.js games. Use for bl
5
5
 
6
6
  # Genex Three.js Raymarched Space Effects
7
7
 
8
- Use raymarched space effects for strong authored moments. Keep the math bounded,
9
- diagnosable, and tied to a game purpose.
8
+ Treat these effects as numerical renderers with explicit integration state. The visual character depends on coordinate choice, step policy, and how rays interact with emissive structures.
10
9
 
11
- Read [references/space-effects.md](references/space-effects.md) for curved-ray,
12
- disk, wormhole, and budget patterns.
10
+ ## Workflow
13
11
 
14
- ## Build order
12
+ 1. Define the effect-space transform and camera ray.
13
+ 2. Choose a physical, physically inspired, or purely artistic bending model.
14
+ 3. Bound the integration domain.
15
+ 4. Track ray position, direction, throughput, and accumulated radiance.
16
+ 5. Detect crossings with disks, shells, throats, or event boundaries.
17
+ 6. Sample the background only after integration terminates.
18
+ 7. Add diagnostics for trajectory, step count, and termination reason.
15
19
 
16
- 1. Define the game role: landmark, hazard, portal, sky feature, set piece, or
17
- background effect.
18
- 2. Choose ray domain, bounds, step count, and quality tiers.
19
- 3. Implement a no-distortion baseline first.
20
- 4. Add ray steering, density, emission, and environment lookup.
21
- 5. Add compositing with depth and exposure rules.
22
- 6. Expose debug views for steps, ray exit, density, emission, and fallback.
20
+ Read [references/space-effects.md](references/space-effects.md)
21
+ for the RK4 wormhole, artistic curved-ray accretion integrator, disk
22
+ composition, and implementation defects.
23
23
 
24
- ## Rules
24
+ ## Constraints
25
25
 
26
- - Bound every integration loop.
27
- - Keep a cheaper fallback for low-end browsers.
28
- - Avoid unbounded brightness that breaks exposure.
29
- - Keep controls and collision separate from visual distortion.
30
- - Validate camera motion and edge cases near the effect.
26
+ - Do not call a UV swirl “gravitational lensing.”
27
+ - Cap iterations and provide early termination.
28
+ - Use continuous crossing tests for thin structures.
29
+ - Keep numerical stability independent from frame rate.
30
+ - Separate the integrator from shading of the accretion disk or wormhole interior.
31
+ - Provide a cheaper approximation for non-hero views.
32
+
33
+ ## Routing boundary
34
+
35
+ Use `$genex-threejs-procedural-vfx` for ordinary particles, trails, plasma, and event
36
+ effects. This skill is for per-pixel numerical ray integration through curved
37
+ or bounded space-effect domains.