@genex-ai/cli-demo 0.93.0-dev.247 → 0.94.0-dev.249
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.
- package/dist/index.js +25 -4
- package/package.json +1 -1
- package/templates/skills/genex-ai-model/SKILL.md +3 -2
- package/templates/skills/genex-ai-skybox/SKILL.md +3 -3
- package/templates/skills/genex-game-director/SKILL.md +321 -411
- package/templates/skills/genex-game-director/references/design-contract.md +130 -179
- package/templates/skills/genex-game-director/references/routing-map.md +242 -362
- package/templates/skills/genex-threejs-exposure-color-grading/SKILL.md +3 -7
- package/templates/skills/genex-threejs-procedural-assets/SKILL.md +112 -0
- package/templates/skills/genex-threejs-procedural-materials/SKILL.md +3 -7
- package/templates/skills/genex-threejs-procedural-vfx/SKILL.md +6 -11
- package/templates/skills/genex-threejs-shadow-systems/SKILL.md +2 -3
- package/templates/skills/genex-threejs-visual-validation/SKILL.md +0 -4
- package/templates/skills/genex-threejs-atmosphere-aerial-perspective/SKILL.md +0 -46
- package/templates/skills/genex-threejs-atmosphere-aerial-perspective/references/atmosphere.md +0 -213
- package/templates/skills/genex-threejs-bloom/SKILL.md +0 -44
- package/templates/skills/genex-threejs-bloom/references/bloom.md +0 -187
- package/templates/skills/genex-threejs-exposure-color-grading/references/exposure-grading.md +0 -205
- package/templates/skills/genex-threejs-game-content/SKILL.md +0 -198
- package/templates/skills/genex-threejs-game-content/references/content-tables.md +0 -269
- package/templates/skills/genex-threejs-image-pipeline/SKILL.md +0 -56
- package/templates/skills/genex-threejs-image-pipeline/references/image-pipeline.md +0 -197
- package/templates/skills/genex-threejs-lighting-design/SKILL.md +0 -144
- package/templates/skills/genex-threejs-lighting-design/references/light-recipes.md +0 -137
- package/templates/skills/genex-threejs-open-world/SKILL.md +0 -149
- package/templates/skills/genex-threejs-open-world/references/terrain-streaming.md +0 -215
- package/templates/skills/genex-threejs-precipitation-surfaces/SKILL.md +0 -59
- package/templates/skills/genex-threejs-precipitation-surfaces/references/precipitation-surfaces.md +0 -181
- package/templates/skills/genex-threejs-procedural-architecture/SKILL.md +0 -50
- package/templates/skills/genex-threejs-procedural-architecture/references/architecture-systems.md +0 -509
- package/templates/skills/genex-threejs-procedural-fields/SKILL.md +0 -61
- package/templates/skills/genex-threejs-procedural-fields/references/field-systems.md +0 -232
- package/templates/skills/genex-threejs-procedural-geometry/SKILL.md +0 -39
- package/templates/skills/genex-threejs-procedural-geometry/references/mesh-systems.md +0 -202
- package/templates/skills/genex-threejs-procedural-materials/references/material-systems.md +0 -198
- package/templates/skills/genex-threejs-procedural-planets/SKILL.md +0 -48
- package/templates/skills/genex-threejs-procedural-planets/references/planet-systems.md +0 -498
- package/templates/skills/genex-threejs-procedural-vegetation/SKILL.md +0 -52
- package/templates/skills/genex-threejs-procedural-vegetation/references/vegetation-systems.md +0 -314
- package/templates/skills/genex-threejs-procedural-vfx/references/vfx-systems.md +0 -218
- package/templates/skills/genex-threejs-raymarched-space-effects/SKILL.md +0 -37
- package/templates/skills/genex-threejs-raymarched-space-effects/references/space-effects.md +0 -194
- package/templates/skills/genex-threejs-screen-space-ambient-occlusion/SKILL.md +0 -35
- package/templates/skills/genex-threejs-screen-space-ambient-occlusion/references/ambient-occlusion.md +0 -441
- package/templates/skills/genex-threejs-spectral-ocean/SKILL.md +0 -52
- package/templates/skills/genex-threejs-spectral-ocean/references/spectral-ocean.md +0 -473
- package/templates/skills/genex-threejs-temporal-surfaces/SKILL.md +0 -41
- package/templates/skills/genex-threejs-temporal-surfaces/references/temporal-surfaces.md +0 -207
- package/templates/skills/genex-threejs-visual-validation/references/visual-validation.md +0 -427
- package/templates/skills/genex-threejs-volumetric-clouds/SKILL.md +0 -49
- package/templates/skills/genex-threejs-volumetric-clouds/references/volumetric-clouds.md +0 -579
- package/templates/skills/genex-threejs-water-optics/SKILL.md +0 -57
- package/templates/skills/genex-threejs-water-optics/references/water-optics.md +0 -195
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: genex-threejs-spectral-ocean
|
|
3
|
-
description: Build large procedural oceans for Genex Three.js games. Use for FFT-style wave spectra, multi-cascade wave bands, hybrid FFT plus Gerstner clear water, stylized above/below-surface ocean optics, choppy displacement, derivatives, Jacobian whitecaps, temporal foam, underwater absorption, crest scatter, ocean shading, camera-scale transitions, and GPU-budgeted open-water scenes.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Genex Three.js Spectral Ocean
|
|
7
|
-
|
|
8
|
-
**If the game just needs a sea/lake to float on or fly over, use `$genex-threejs-water-optics` instead** — this skill is the expensive hero-water path, for scenes where open water IS the subject.
|
|
9
|
-
|
|
10
|
-
Treat an ocean as a sampled stochastic wave field with explicit frequency-space ownership. Do not approximate this target with a pile of Gerstner waves, scrolling normal maps, or unrelated foam noise.
|
|
11
|
-
|
|
12
|
-
## Build order
|
|
13
|
-
|
|
14
|
-
1. Define the sea-state spectrum and deterministic Gaussian seed.
|
|
15
|
-
2. Partition wavelengths into disjoint cascades.
|
|
16
|
-
3. Validate the inverse FFT independently with analytic inputs.
|
|
17
|
-
4. Generate and conjugate-pack the initial spectrum.
|
|
18
|
-
5. Evolve packed displacement and derivative fields in frequency space.
|
|
19
|
-
6. Inverse-transform every packed field with explicit inter-step barriers.
|
|
20
|
-
7. Assemble displacement, derivatives, and persistent Jacobian foam maps.
|
|
21
|
-
8. Shade from summed cascade displacement and derivatives.
|
|
22
|
-
9. Add sub-grid detail only below the resolved simulation bands.
|
|
23
|
-
10. Expose spectrum, height, slopes, Jacobian, and foam-history diagnostics.
|
|
24
|
-
|
|
25
|
-
Read [references/spectral-ocean.md](references/spectral-ocean.md) before implementing or auditing a spectral ocean.
|
|
26
|
-
|
|
27
|
-
## Hybrid and stylized variants
|
|
28
|
-
|
|
29
|
-
For clear shallow water, a hybrid ocean may add a few authored Gerstner swells on
|
|
30
|
-
top of the FFT cascades — never instead of them — with Beer–Lambert depth color,
|
|
31
|
-
sand-bed caustics, and sharp sun highlights. A stylized ocean meant to be seen
|
|
32
|
-
from above and below can drive color from height gradients, add sun-path glints
|
|
33
|
-
and crest scatter, and composite an underwater Beer–Lambert tint from scene
|
|
34
|
-
depth. Both variants keep the spectral core, its derivatives, and Jacobian foam
|
|
35
|
-
as the single source of surface truth.
|
|
36
|
-
|
|
37
|
-
## Non-negotiable gates
|
|
38
|
-
|
|
39
|
-
- Require a power-of-two grid and a passing FFT impulse/frequency test.
|
|
40
|
-
- Keep cascade wavenumber intervals disjoint.
|
|
41
|
-
- Derive normals from transformed derivatives, not a detached normal texture.
|
|
42
|
-
- Detect breaking from the horizontal-displacement Jacobian.
|
|
43
|
-
- Persist foam in simulation state; do not infer all foam anew per frame.
|
|
44
|
-
- Submit FFT stages with the synchronization required by the active backend.
|
|
45
|
-
- Share sun and sky parameters between the visible sky and ocean reflection.
|
|
46
|
-
- Keep a deterministic seed and fixed-camera capture for comparisons.
|
|
47
|
-
|
|
48
|
-
## Route elsewhere
|
|
49
|
-
|
|
50
|
-
- Use `$genex-threejs-water-optics` for bounded water, screen-space refraction, depth thickness, shoreline absorption, and analytic wave surfaces.
|
|
51
|
-
- Add `$genex-threejs-procedural-vfx` only when crest spray or interaction splashes are required.
|
|
52
|
-
- Add `$genex-threejs-visual-validation` for cross-seed, temporal, and GPU evidence.
|
|
@@ -1,473 +0,0 @@
|
|
|
1
|
-
# Spectral cascade ocean system
|
|
2
|
-
|
|
3
|
-
Use this reference for a large, unbounded-looking ocean whose identity comes from directional spectral synthesis, staged inverse FFTs, derivative maps, Jacobian whitecaps, and coherent optical shading.
|
|
4
|
-
|
|
5
|
-
> **Renderer note:** this reference assumes `WebGPURenderer` + TSL node materials. Check the project's actual renderer first — the Genex scaffold ships vanilla WebGL three.js. On WebGL, adapt the technique with standard materials / `EffectComposer` passes or pick a simpler alternative; never switch renderers mid-project. Either way the effect obeys the device tier (`$genex-threejs-adaptive-quality`): expensive passes are desktop-tier, and on WebGPU the per-target MSAA sample count is a runtime knob the governor may drive.
|
|
6
|
-
|
|
7
|
-
## Contents
|
|
8
|
-
|
|
9
|
-
1. Architecture and cascade partition
|
|
10
|
-
2. Directional spectrum and Hermitian packing
|
|
11
|
-
3. GPU inverse FFT and hard validation gate
|
|
12
|
-
4. Spatial displacement and derivative maps
|
|
13
|
-
5. Jacobian foam history
|
|
14
|
-
6. Surface shading, detail, and spray
|
|
15
|
-
7. Quality modes, defects, and diagnostics
|
|
16
|
-
|
|
17
|
-
## 1. Architecture contract
|
|
18
|
-
|
|
19
|
-
Keep these stages distinct and inspectable:
|
|
20
|
-
|
|
21
|
-
```text
|
|
22
|
-
sea-state parameters
|
|
23
|
-
-> deterministic Gaussian field
|
|
24
|
-
-> initial directional spectrum h0(k)
|
|
25
|
-
-> conjugate packing h0(k), conj(h0(-k))
|
|
26
|
-
-> time-evolved packed frequency fields
|
|
27
|
-
-> horizontal IFFT stages
|
|
28
|
-
-> vertical IFFT stages
|
|
29
|
-
-> centered-spectrum permutation
|
|
30
|
-
-> displacement + derivative + foam-history maps
|
|
31
|
-
-> displaced surface + optical shading
|
|
32
|
-
```
|
|
33
|
-
|
|
34
|
-
One cascade owns one patch length and one disjoint wavenumber interval. Shared
|
|
35
|
-
sea-state uniforms and Gaussian seeds keep the cascades statistically related;
|
|
36
|
-
separate buffers prevent writes from aliasing.
|
|
37
|
-
|
|
38
|
-
The 256², three-cascade configuration uses:
|
|
39
|
-
|
|
40
|
-
```ts
|
|
41
|
-
const oceanPreset = {
|
|
42
|
-
resolution: 256,
|
|
43
|
-
patchLengthsMeters: [250, 17, 5],
|
|
44
|
-
boundaryFactor: 6,
|
|
45
|
-
depthMeters: 500,
|
|
46
|
-
gravity: 9.81,
|
|
47
|
-
choppiness: 1.3,
|
|
48
|
-
}
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
Treat these as a validated starting scale, not universal constants.
|
|
52
|
-
|
|
53
|
-
## 2. Cascade partition
|
|
54
|
-
|
|
55
|
-
For cascade `i`, define:
|
|
56
|
-
|
|
57
|
-
```text
|
|
58
|
-
deltaK(i) = 2π / patchLength(i)
|
|
59
|
-
handoff(i) = 2π / patchLength(i) * boundaryFactor
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
Use:
|
|
63
|
-
|
|
64
|
-
```text
|
|
65
|
-
cascade 0: [epsilon, handoff(1)]
|
|
66
|
-
cascade 1: [handoff(1), handoff(2)]
|
|
67
|
-
cascade 2: [handoff(2), largeUpperBound]
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
The in-band mask must be applied after all singular inputs have been made safe.
|
|
71
|
-
Do not rely on multiplication by zero to hide `1/0`, `sqrt(NaN)`, or infinite
|
|
72
|
-
frequency derivatives. Clamp the evaluated wavenumber first:
|
|
73
|
-
|
|
74
|
-
```glsl
|
|
75
|
-
float kSafe = max(kLength, cutoffLow);
|
|
76
|
-
float inBand =
|
|
77
|
-
step(cutoffLow, kLength) *
|
|
78
|
-
step(kLength, cutoffHigh);
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
Debug every cascade as a centered spectrum heatmap. Adjacent bands may touch
|
|
82
|
-
at a boundary; they must not overlap broadly or leave a visible spectral hole.
|
|
83
|
-
|
|
84
|
-
## 3. Initial directional spectrum
|
|
85
|
-
|
|
86
|
-
Generate two independent standard-normal values per grid cell once. Seed the
|
|
87
|
-
generator explicitly so image comparisons and regression tests are stable.
|
|
88
|
-
|
|
89
|
-
For each centered grid coordinate:
|
|
90
|
-
|
|
91
|
-
```text
|
|
92
|
-
k = (gridIndex - N/2) * deltaK
|
|
93
|
-
omega(k) = sqrt(g * |k| * tanh(min(|k| * depth, 20)))
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
The sea state sums two spectra:
|
|
97
|
-
|
|
98
|
-
```text
|
|
99
|
-
energy =
|
|
100
|
-
localWindSea(omega, direction)
|
|
101
|
-
+ swell(omega, direction)
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
Each term combines:
|
|
105
|
-
|
|
106
|
-
```text
|
|
107
|
-
JONSWAP frequency energy
|
|
108
|
-
* TMA finite-depth correction
|
|
109
|
-
* directional spreading
|
|
110
|
-
* exp(-shortWaveFade² * |k|²)
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
Compute JONSWAP peak terms from wind speed and fetch:
|
|
114
|
-
|
|
115
|
-
```text
|
|
116
|
-
alpha = 0.076 * (g * fetch / windSpeed²)^(-0.22)
|
|
117
|
-
peakOmega = 22 * (windSpeed * fetch / g²)^(-0.33)
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
Use the standard JONSWAP sigma split around the peak (`0.07` below, `0.09`
|
|
121
|
-
above), peak enhancement `gamma`, and an explicit scale per local/swell lobe.
|
|
122
|
-
|
|
123
|
-
Directional spreading must rotate around the configured wind angle and tighten
|
|
124
|
-
as the frequency approaches the energetic range. Blend a broad cosine-squared
|
|
125
|
-
base with a Donelan–Banner-style powered cosine lobe.
|
|
126
|
-
|
|
127
|
-
Initial complex amplitude:
|
|
128
|
-
|
|
129
|
-
```text
|
|
130
|
-
amplitude =
|
|
131
|
-
sqrt(
|
|
132
|
-
energy
|
|
133
|
-
* 2
|
|
134
|
-
* abs(dOmega/dk)
|
|
135
|
-
/ kSafe
|
|
136
|
-
* deltaK²
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
h0(k) = gaussianComplex(k) * amplitude * inBand
|
|
140
|
-
```
|
|
141
|
-
|
|
142
|
-
Expose at least:
|
|
143
|
-
|
|
144
|
-
```text
|
|
145
|
-
local-only spectrum
|
|
146
|
-
swell-only spectrum
|
|
147
|
-
combined spectrum
|
|
148
|
-
in-band mask
|
|
149
|
-
frequency derivative
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
## 4. Hermitian pairing and packed fields
|
|
153
|
-
|
|
154
|
-
Real spatial fields require conjugate symmetry. Store:
|
|
155
|
-
|
|
156
|
-
```text
|
|
157
|
-
packedH0(k) = [h0(k), conjugate(h0(-k))]
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
At time `t`:
|
|
161
|
-
|
|
162
|
-
```text
|
|
163
|
-
h(k,t) =
|
|
164
|
-
h0(k) * exp(i * omega * t)
|
|
165
|
-
+ conjugate(h0(-k)) * exp(-i * omega * t)
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
Compute horizontal displacement from `i * k / |k| * h`, vertical displacement
|
|
169
|
-
from `h`, and spatial derivatives by multiplying by the relevant wave-number
|
|
170
|
-
components.
|
|
171
|
-
|
|
172
|
-
Pack two real spatial fields into one complex IFFT input. A useful four-buffer
|
|
173
|
-
layout is:
|
|
174
|
-
|
|
175
|
-
```text
|
|
176
|
-
field 0: horizontal displacement X + i horizontal displacement Z
|
|
177
|
-
field 1: height + i cross derivative
|
|
178
|
-
field 2: height slope X + i height slope Z
|
|
179
|
-
field 3: horizontal derivative XX + i horizontal derivative ZZ
|
|
180
|
-
```
|
|
181
|
-
|
|
182
|
-
Packing halves the number of transforms. Document the unpacking algebra next
|
|
183
|
-
to the field contract; a swapped real/imaginary sign can look plausible while
|
|
184
|
-
rotating or mirroring the sea.
|
|
185
|
-
|
|
186
|
-
## 5. GPU inverse FFT schedule
|
|
187
|
-
|
|
188
|
-
Precompute a butterfly table on the CPU for every FFT stage and output column:
|
|
189
|
-
|
|
190
|
-
```ts
|
|
191
|
-
type ButterflyEntry = {
|
|
192
|
-
twiddleReal: number
|
|
193
|
-
twiddleImaginary: number
|
|
194
|
-
inputA: number
|
|
195
|
-
inputB: number
|
|
196
|
-
}
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
For each complex field:
|
|
200
|
-
|
|
201
|
-
1. execute `log2(N)` horizontal butterfly stages;
|
|
202
|
-
2. execute `log2(N)` vertical butterfly stages;
|
|
203
|
-
3. multiply by `(-1)^(x+y)` to reconcile centered frequency coordinates.
|
|
204
|
-
|
|
205
|
-
Ping-pong between the field buffer and a dedicated scratch buffer. Never let
|
|
206
|
-
two logical fields share scratch storage during the same stage.
|
|
207
|
-
|
|
208
|
-
The critical WebGPU backend rule is:
|
|
209
|
-
|
|
210
|
-
```text
|
|
211
|
-
one FFT stage -> one compute submission boundary
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
Do not assume writes from one dispatch are visible to the next dispatch inside
|
|
215
|
-
an implementation-defined combined pass. Batch independent fields at the same
|
|
216
|
-
stage into one submission, then submit the next stage:
|
|
217
|
-
|
|
218
|
-
```ts
|
|
219
|
-
for (let stage = 0; stage < logN; stage++) {
|
|
220
|
-
renderer.compute(allHorizontalFieldsAt(stage))
|
|
221
|
-
}
|
|
222
|
-
for (let stage = 0; stage < logN; stage++) {
|
|
223
|
-
renderer.compute(allVerticalFieldsAt(stage))
|
|
224
|
-
}
|
|
225
|
-
renderer.compute(allCenteringPermutations)
|
|
226
|
-
```
|
|
227
|
-
|
|
228
|
-
Inspect the installed renderer before relying on this exact API shape.
|
|
229
|
-
|
|
230
|
-
## 6. FFT hard gate
|
|
231
|
-
|
|
232
|
-
Validate the transform before connecting the spectrum:
|
|
233
|
-
|
|
234
|
-
```text
|
|
235
|
-
test A:
|
|
236
|
-
centered DC impulse
|
|
237
|
-
expected spatial result = constant complex (1, 0)
|
|
238
|
-
|
|
239
|
-
test B:
|
|
240
|
-
centered one-bin X-frequency impulse
|
|
241
|
-
expected spatial result =
|
|
242
|
-
cos(2πx/N) + i sin(2πx/N)
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
Measure maximum absolute error over every texel. A practical gate for half- or
|
|
246
|
-
single-precision storage is `1e-3`, adjusted only with evidence.
|
|
247
|
-
|
|
248
|
-
If either test fails, stop. Do not tune spectrum amplitude, choppiness, or
|
|
249
|
-
shading around a broken transform.
|
|
250
|
-
|
|
251
|
-
Diagnostic causes:
|
|
252
|
-
|
|
253
|
-
```text
|
|
254
|
-
constant test alternates signs -> missing or duplicated centering permutation
|
|
255
|
-
sine direction reversed -> inverse twiddle sign is wrong
|
|
256
|
-
frequency appears on Y -> horizontal/vertical indexing is swapped
|
|
257
|
-
every other stage corrupts -> ping-pong source/destination parity is wrong
|
|
258
|
-
random blocks -> missing inter-stage visibility boundary
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
## 7. Spatial map assembly
|
|
262
|
-
|
|
263
|
-
Assemble filterable repeating textures after the IFFT:
|
|
264
|
-
|
|
265
|
-
```text
|
|
266
|
-
displacement.rgba =
|
|
267
|
-
[lambda * Dx, height, lambda * Dz, foamHistory]
|
|
268
|
-
|
|
269
|
-
derivatives.rgba =
|
|
270
|
-
[dHeight/dx, dHeight/dz, lambda * dDx/dx, lambda * dDz/dz]
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
Half-float storage textures are a strong bandwidth/quality compromise when the
|
|
274
|
-
target backend supports storage writes and filtered sampling for that format.
|
|
275
|
-
Verify capabilities rather than assuming them.
|
|
276
|
-
|
|
277
|
-
## 8. Jacobian whitecaps with history
|
|
278
|
-
|
|
279
|
-
Choppy horizontal displacement can fold. Build the 2×2 horizontal mapping
|
|
280
|
-
Jacobian:
|
|
281
|
-
|
|
282
|
-
```text
|
|
283
|
-
jxx = 1 + lambda * dDx/dx
|
|
284
|
-
jzz = 1 + lambda * dDz/dz
|
|
285
|
-
jxz = lambda * dDz/dx
|
|
286
|
-
J = jxx * jzz - jxz²
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
Low or negative `J` identifies real fold/compression regions. Store a persistent
|
|
290
|
-
per-texel history initialized to `1`.
|
|
291
|
-
|
|
292
|
-
One effective update shape is:
|
|
293
|
-
|
|
294
|
-
```text
|
|
295
|
-
historyNext =
|
|
296
|
-
min(
|
|
297
|
-
currentJacobian,
|
|
298
|
-
historyPrevious
|
|
299
|
-
+ dt * recoveryRate / max(currentJacobian, 0.5)
|
|
300
|
-
)
|
|
301
|
-
```
|
|
302
|
-
|
|
303
|
-
This snaps toward a breaking event and recovers gradually. Keep simulation
|
|
304
|
-
history separate from the display threshold:
|
|
305
|
-
|
|
306
|
-
```text
|
|
307
|
-
foamCoverage =
|
|
308
|
-
smoothstep(lowCoverage, highCoverage,
|
|
309
|
-
sum(saturate((foamThreshold - history) * foamScale)))
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
Do not include a finest cascade that produces constant speckle merely because
|
|
313
|
-
it is available. Validate each cascade’s foam contribution separately.
|
|
314
|
-
|
|
315
|
-
## 9. Fold-aware surface normal
|
|
316
|
-
|
|
317
|
-
Sum derivative maps across cascades. Horizontal compression changes the height
|
|
318
|
-
slope denominator:
|
|
319
|
-
|
|
320
|
-
```text
|
|
321
|
-
slopeX = sum(dHeight/dx) / (1 + sum(lambda * dDx/dx))
|
|
322
|
-
slopeZ = sum(dHeight/dz) / (1 + sum(lambda * dDz/dz))
|
|
323
|
-
normal = normalize([-slopeX, 1, -slopeZ])
|
|
324
|
-
```
|
|
325
|
-
|
|
326
|
-
This keeps normals coupled to choppy displacement. A normal derived from height
|
|
327
|
-
alone misses overturning/compression behavior.
|
|
328
|
-
|
|
329
|
-
Add sub-grid normal detail only after this resolved normal exists. Sample a
|
|
330
|
-
seamless detail field at two independently scrolling scales and keep its
|
|
331
|
-
strength low enough that it cannot rewrite the swell direction.
|
|
332
|
-
|
|
333
|
-
## 10. Optical composition
|
|
334
|
-
|
|
335
|
-
Use one sky-radiance function for both the dome and reflected ray:
|
|
336
|
-
|
|
337
|
-
```text
|
|
338
|
-
sky(direction) =
|
|
339
|
-
horizon-to-zenith gradient
|
|
340
|
-
+ narrow sun disc
|
|
341
|
-
+ broad sun halo
|
|
342
|
-
```
|
|
343
|
-
|
|
344
|
-
Water-air Fresnel:
|
|
345
|
-
|
|
346
|
-
```text
|
|
347
|
-
F = 0.02 + 0.98 * (1 - saturate(N·V))^5
|
|
348
|
-
```
|
|
349
|
-
|
|
350
|
-
Build the body term from deep color plus crest scatter. Use a
|
|
351
|
-
view/sun/normal half-vector response weighted by crest height, then:
|
|
352
|
-
|
|
353
|
-
```text
|
|
354
|
-
water = mix(body, sky(reflect(-V, N)), F)
|
|
355
|
-
```
|
|
356
|
-
|
|
357
|
-
Foam changes the final response rather than adding a white texture. Shade it
|
|
358
|
-
with sun/sky incidence and modulate brightness with a separate bubbly detail
|
|
359
|
-
field. Do not punch noisy holes in the physically derived foam coverage.
|
|
360
|
-
|
|
361
|
-
The visible sky and reflected sky must share:
|
|
362
|
-
|
|
363
|
-
```text
|
|
364
|
-
sun direction
|
|
365
|
-
sun color
|
|
366
|
-
horizon color
|
|
367
|
-
zenith color
|
|
368
|
-
```
|
|
369
|
-
|
|
370
|
-
Otherwise the reflection will appear pasted onto the surface.
|
|
371
|
-
|
|
372
|
-
## 11. Runtime order
|
|
373
|
-
|
|
374
|
-
Use this order each frame:
|
|
375
|
-
|
|
376
|
-
```text
|
|
377
|
-
update time and dt uniforms
|
|
378
|
-
compute all time-dependent spectra
|
|
379
|
-
submit horizontal FFT stages
|
|
380
|
-
submit vertical FFT stages
|
|
381
|
-
submit centering permutations
|
|
382
|
-
assemble maps and update foam history
|
|
383
|
-
update optional spray
|
|
384
|
-
render ocean and sky
|
|
385
|
-
resolve GPU timing asynchronously
|
|
386
|
-
```
|
|
387
|
-
|
|
388
|
-
Sea-state changes that alter `h0` should recompute the initial spectrum on
|
|
389
|
-
interaction release, not continuously while dragging a control.
|
|
390
|
-
|
|
391
|
-
## 12. Geometry, camera, and fog
|
|
392
|
-
|
|
393
|
-
The presentation uses:
|
|
394
|
-
|
|
395
|
-
```text
|
|
396
|
-
camera FOV: 55°
|
|
397
|
-
camera: (0, 16, 68)
|
|
398
|
-
target: (0, 0, -20)
|
|
399
|
-
surface: 400 m square, 900 × 900 subdivisions
|
|
400
|
-
fog: horizon-colored exponential fog
|
|
401
|
-
```
|
|
402
|
-
|
|
403
|
-
The dense plane is justified because displacement is evaluated per vertex.
|
|
404
|
-
Scale tessellation against the smallest resolved cascade and camera distance.
|
|
405
|
-
Fog must hide the finite mesh edge before the plane ends.
|
|
406
|
-
|
|
407
|
-
Lower-cost modes should preserve the mechanism:
|
|
408
|
-
|
|
409
|
-
```text
|
|
410
|
-
high: 256², 3 cascades, dense mesh, persistent foam
|
|
411
|
-
medium: 256², 2 cascades, lower mesh tessellation, persistent foam
|
|
412
|
-
low: 128², 2 cascades, no spray, reduced detail texture
|
|
413
|
-
```
|
|
414
|
-
|
|
415
|
-
Do not call a four-wave analytic surface a low-quality FFT tier; that is a
|
|
416
|
-
different representation and should be routed to `$genex-threejs-water-optics`.
|
|
417
|
-
|
|
418
|
-
## 13. Required diagnostics
|
|
419
|
-
|
|
420
|
-
Expose:
|
|
421
|
-
|
|
422
|
-
```text
|
|
423
|
-
FFT test errors
|
|
424
|
-
Gaussian seed field
|
|
425
|
-
per-cascade in-band spectrum
|
|
426
|
-
time-evolved frequency magnitude
|
|
427
|
-
spatial height
|
|
428
|
-
horizontal displacement
|
|
429
|
-
height slopes
|
|
430
|
-
horizontal derivatives
|
|
431
|
-
Jacobian determinant
|
|
432
|
-
foam history
|
|
433
|
-
foam display coverage
|
|
434
|
-
resolved normal
|
|
435
|
-
sub-grid normal contribution
|
|
436
|
-
final without foam
|
|
437
|
-
final without detail
|
|
438
|
-
GPU milliseconds by compute and render phase
|
|
439
|
-
```
|
|
440
|
-
|
|
441
|
-
Capture a fixed camera at multiple times. A single attractive frame cannot
|
|
442
|
-
prove temporal stability, transform correctness, or foam persistence.
|
|
443
|
-
|
|
444
|
-
## 14. Failure diagnosis
|
|
445
|
-
|
|
446
|
-
```text
|
|
447
|
-
periodic square tiles:
|
|
448
|
-
cascade lengths or camera coverage expose repetition; add disjoint scales
|
|
449
|
-
|
|
450
|
-
all waves travel in one artificial line:
|
|
451
|
-
directional spread is too narrow or wind/swell angles are identical
|
|
452
|
-
|
|
453
|
-
energy explodes near the center:
|
|
454
|
-
DC/small-k singularities are evaluated before masking
|
|
455
|
-
|
|
456
|
-
surface moves but normals lag:
|
|
457
|
-
derivative maps are stale or sampled with different coordinates
|
|
458
|
-
|
|
459
|
-
white noise foam:
|
|
460
|
-
thresholding finest-cascade compression without temporal filtering
|
|
461
|
-
|
|
462
|
-
foam disappears instantly:
|
|
463
|
-
history is not persistent or recovery is interpreted as decay-to-zero
|
|
464
|
-
|
|
465
|
-
foam never clears:
|
|
466
|
-
recovery sign or Jacobian denominator clamp is wrong
|
|
467
|
-
|
|
468
|
-
glitter detached from sun:
|
|
469
|
-
visible sky and reflection use different sun direction or color
|
|
470
|
-
|
|
471
|
-
GPU corruption after increasing N:
|
|
472
|
-
FFT stage count, butterfly table, index type, or scratch allocation is wrong
|
|
473
|
-
```
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: genex-threejs-temporal-surfaces
|
|
3
|
-
description: Build temporal screen-space and surface-history effects for Genex Three.js games. Use for touch history, frost clearing, burn-in masks, wet trails, accumulation buffers, ping-pong render targets, reduced-resolution blur, refraction masks, and interaction effects that persist over time.
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Genex Three.js Temporal Surfaces
|
|
7
|
-
|
|
8
|
-
Use render-target state when the effect depends on history. Do not fake accumulation with a time-only procedural mask.
|
|
9
|
-
|
|
10
|
-
## Pipeline
|
|
11
|
-
|
|
12
|
-
```text
|
|
13
|
-
screen-space touch source
|
|
14
|
-
→ ping-pong state update
|
|
15
|
-
→ reduced-resolution scene blur
|
|
16
|
-
→ static structure textures
|
|
17
|
-
→ frost composite
|
|
18
|
-
→ normal/refraction output
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Read [references/temporal-surfaces.md](references/temporal-surfaces.md)
|
|
22
|
-
for an exact frost pass graph, pointer-history channels, blur and refraction
|
|
23
|
-
coupling, and implementation defects that must be corrected.
|
|
24
|
-
|
|
25
|
-
## Rules
|
|
26
|
-
|
|
27
|
-
- Separate persistent state from static noise and scene color.
|
|
28
|
-
- Preserve separate visible-mask and tilt-response channels.
|
|
29
|
-
- Use half-float for this history path unless a measured lower format is equivalent.
|
|
30
|
-
- Convert per-frame history decay to frame-rate-independent decay.
|
|
31
|
-
- Run the two-pass scene blur at reduced resolution.
|
|
32
|
-
- Pre-render static procedural textures once.
|
|
33
|
-
- Define and test resize/reset behavior for both history targets and static targets.
|
|
34
|
-
- Do not route world footprints, object-UV paint, or simulation-plane wetness here; this skill is screen-space.
|
|
35
|
-
|
|
36
|
-
## Routing boundary
|
|
37
|
-
|
|
38
|
-
Use `$genex-threejs-procedural-vfx` for world- or object-space residue, particles, and
|
|
39
|
-
dissolves. Use `$genex-threejs-precipitation-surfaces` for rain wetness, puddles,
|
|
40
|
-
snow accumulation, and weather-surface coupling in world space. This skill owns
|
|
41
|
-
screen-space persistent history and its composite.
|