lecodes-sdk 2.2.14 → 2.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.
- package/dist/types/gl/Scene.d.ts +0 -11
- package/dist/types/gl/postProcessing.d.ts +31 -2
- package/dist/types/runtime/device.d.ts +7 -19
- package/dist/types/version.d.ts +1 -1
- package/dist/types.json +1 -1
- package/package.json +1 -1
- package/src/animate/tween/Timeline.ts +175 -175
- package/src/bridges/gl.d.ts +5 -13
- package/src/gl/CameraPlace.ts +52 -52
- package/src/gl/Light.ts +257 -257
- package/src/gl/Mesh.ts +120 -120
- package/src/gl/Scene.ts +0 -13
- package/src/gl/animation/DynamicBone.ts +486 -486
- package/src/gl/postProcessing.ts +52 -9
- package/src/gl/scenarios.ts +291 -291
- package/src/runtime/device.ts +8 -37
- package/src/version.ts +1 -1
package/src/gl/postProcessing.ts
CHANGED
|
@@ -12,12 +12,13 @@
|
|
|
12
12
|
// Two bands inside, because the engine treats them differently:
|
|
13
13
|
//
|
|
14
14
|
// - The GRADING band — tone mapping, exposure, white balance, contrast / saturation / vibrance,
|
|
15
|
-
// shadows / midtones / highlights, slope / offset / power, curves, the .cube LUT
|
|
16
|
-
// engine into the ONE 3D lookup table the frame always samples. Free per frame;
|
|
17
|
-
// a 32³ table on the CPU. So writes here are COALESCED: a field write marks the
|
|
18
|
-
// whole band goes to the engine once, in a microtask (the end of the current
|
|
19
|
-
// values are quantised to 1/1000
|
|
20
|
-
// animate every frame; a blend between two looks over a
|
|
15
|
+
// shadows / midtones / highlights, slope / offset / power, curves, the .cube LUT, the HDR look —
|
|
16
|
+
// is baked by the engine into the ONE 3D lookup table the frame always samples. Free per frame;
|
|
17
|
+
// a CHANGE re-bakes a 32³ table on the CPU. So writes here are COALESCED: a field write marks the
|
|
18
|
+
// band dirty and the whole band goes to the engine once, in a microtask (the end of the current
|
|
19
|
+
// handler), and the values are quantised to 1/1000 (the HDR look to 0.05) so a tween that barely
|
|
20
|
+
// moves does not re-bake. Not a thing to animate every frame; a blend between two looks over a
|
|
21
|
+
// second is fine (a few dozen bakes).
|
|
21
22
|
// - The LIVE band — bloom, vignette, ambient occlusion, screen-space reflections, depth of field —
|
|
22
23
|
// is a set of view options: written to the engine at once, free to animate (a focus pull every
|
|
23
24
|
// frame is what depthOfField is for).
|
|
@@ -134,6 +135,26 @@ export type ColorCurves = {
|
|
|
134
135
|
highlightScale?: Rgb
|
|
135
136
|
}
|
|
136
137
|
|
|
138
|
+
/** The look on an HDR display — a screen with headroom above SDR white (Apple's XDR panels, an
|
|
139
|
+
* external display in HDR mode), where the operator is stretched past SDR white toward the peak.
|
|
140
|
+
* Ignored on SDR: stored, read back, nothing changes on screen (`device.hdr.available` says which
|
|
141
|
+
* display this is). Part of the grading band — a change is a bake — and quantised to 0.05 steps. */
|
|
142
|
+
export type HdrLook = {
|
|
143
|
+
/** How much of the picture reaches for the display's headroom, 0..1 (default 0.35). 0 touches only
|
|
144
|
+
* what SDR clipped — the SDR grade kept exactly, but a mostly-mid-tone frame then looks flat next
|
|
145
|
+
* to its one bright spot; 1 lifts nearly everything above black toward the peak. A sunlit
|
|
146
|
+
* exterior takes 1, a dim interior wants less. */
|
|
147
|
+
strength?: number
|
|
148
|
+
/** Where white lands, as a multiple of SDR white, 1..8 (default 1) — the "HDR brightness" of a
|
|
149
|
+
* console game's calibration screen, where 1.5–2 is the norm. It scales the WHOLE picture: at 1
|
|
150
|
+
* a white wall is as bright as the UI's white (faithful, and dim next to what "HDR on" is
|
|
151
|
+
* expected to look like), at 2 twice that, and highlights still climb above it (the engine keeps
|
|
152
|
+
* `headroom / paperWhite` for them, clamped at the peak). `strength` decides how much of the
|
|
153
|
+
* picture reaches for the peak; this decides where the picture starts — a game that wants to read
|
|
154
|
+
* as "HDR on" rather than "SDR with a brighter sun" wants this over `strength`. */
|
|
155
|
+
paperWhite?: number
|
|
156
|
+
}
|
|
157
|
+
|
|
137
158
|
export type PostProcessingOptions = {
|
|
138
159
|
/** The operator that folds the scene's HDR light into the display's range (default 'aces').
|
|
139
160
|
* `'aces'` (filament's ACES legacy) desaturates bright colours towards white — HDR fire reads
|
|
@@ -167,6 +188,11 @@ export type PostProcessingOptions = {
|
|
|
167
188
|
* the operator, in display-referred sRGB — a `.cube` file: `asset('./look.cube')`, or a bare
|
|
168
189
|
* staged filename. `null` removes it. */
|
|
169
190
|
lut?: string | null
|
|
191
|
+
/** The look on an HDR display: `strength` 0..1 (how much of the picture reaches for the peak:
|
|
192
|
+
* 0 only what SDR clipped … 1 nearly everything; default 0.35), `paperWhite` 1..8 (where white
|
|
193
|
+
* lands × SDR white — the console "HDR brightness", 1.5–2 the norm; default 1). Ignored on SDR.
|
|
194
|
+
* An overlay takes its parent's, like the rest of the grading. */
|
|
195
|
+
hdr?: HdrLook
|
|
170
196
|
/** `true` = defaults (intensity 0.2), an object = its knobs, `false` = off. */
|
|
171
197
|
bloom?: boolean | BloomOptions
|
|
172
198
|
/** `true` = defaults (a soft black edge), an object = its knobs, `false` = off. */
|
|
@@ -180,12 +206,13 @@ export type PostProcessingOptions = {
|
|
|
180
206
|
}
|
|
181
207
|
|
|
182
208
|
/** The float layout of `_creator.setColorGrading` — creator.h's ColorGradingParam. Indices never
|
|
183
|
-
* move; a new field goes at the end and COUNT grows
|
|
209
|
+
* move; a new field goes at the end and COUNT grows (the engine takes an older bundle's shorter
|
|
210
|
+
* array, down to the 39 before HDR_*, with the tail at its defaults). */
|
|
184
211
|
export const CG = {
|
|
185
212
|
TONE_MAPPING: 0, EXPOSURE: 1, TEMPERATURE: 2, TINT: 3, CONTRAST: 4, VIBRANCE: 5, SATURATION: 6,
|
|
186
213
|
SHADOWS: 7, MIDTONES: 10, HIGHLIGHTS: 13, RANGES: 16, SLOPE: 20, OFFSET: 23, POWER: 26,
|
|
187
|
-
SHADOW_GAMMA: 29, MID_POINT: 32, HIGHLIGHT_SCALE: 35, LUT: 38,
|
|
188
|
-
COUNT:
|
|
214
|
+
SHADOW_GAMMA: 29, MID_POINT: 32, HIGHLIGHT_SCALE: 35, LUT: 38, HDR_STRENGTH: 39, HDR_PAPER_WHITE: 40,
|
|
215
|
+
COUNT: 41,
|
|
189
216
|
} as const
|
|
190
217
|
|
|
191
218
|
const TONE_MAPPING_MODE: Record<ToneMappingOperator, number> = { aces: 0, neutral: 1, linear: 2, filmic: 3 }
|
|
@@ -196,6 +223,10 @@ const ONE: Rgb = [ 1, 1, 1 ]
|
|
|
196
223
|
const ZERO: Rgb = [ 0, 0, 0 ]
|
|
197
224
|
const rgb = (v: Rgb | undefined, d: Rgb): Rgb => v ? [ v[0], v[1], v[2] ] : d
|
|
198
225
|
const pair = (v: readonly [number, number] | undefined, d: readonly [number, number]): readonly [number, number] => v ? [ v[0], v[1] ] : d
|
|
226
|
+
/** The HDR look on the wire: clamped to its range and quantised to 0.05 — a slider must not re-bake a
|
|
227
|
+
* 32³ LUT per pixel of travel (the quantum is the SDK's; the engine only clamps). */
|
|
228
|
+
const hdrStep = (v: number, min: number, max: number, d: number): number =>
|
|
229
|
+
Number.isFinite(v) ? Math.round(Math.min(max, Math.max(min, v)) * 20) / 20 : d
|
|
199
230
|
|
|
200
231
|
/** The grading band, normalised: every field present. */
|
|
201
232
|
type Grading = {
|
|
@@ -218,12 +249,15 @@ type Grading = {
|
|
|
218
249
|
midPoint: Rgb
|
|
219
250
|
highlightScale: Rgb
|
|
220
251
|
lut: string | null
|
|
252
|
+
hdrStrength: number
|
|
253
|
+
hdrPaperWhite: number
|
|
221
254
|
}
|
|
222
255
|
|
|
223
256
|
const defaultGrading = (): Grading => ({
|
|
224
257
|
toneMapping: "aces", exposure: 0, temperature: 0, tint: 0, contrast: 1, saturation: 1, vibrance: 1,
|
|
225
258
|
shadows: ONE, midtones: ONE, highlights: ONE, rangeShadows: [ 0, 0.333 ], rangeHighlights: [ 0.55, 1 ],
|
|
226
259
|
slope: ONE, offset: ZERO, power: ONE, shadowGamma: ONE, midPoint: ONE, highlightScale: ONE, lut: null,
|
|
260
|
+
hdrStrength: 0.35, hdrPaperWhite: 1,
|
|
227
261
|
})
|
|
228
262
|
|
|
229
263
|
const BLOOM_DEFAULTS: Required<BloomOptions> = { intensity: 0.2, threshold: true, highlight: 1000, levels: 6, quality: "medium", lensFlare: false, dirt: null, dirtStrength: 0.2 }
|
|
@@ -279,6 +313,7 @@ export class PostProcessing {
|
|
|
279
313
|
if (options.power !== undefined) this.power = options.power
|
|
280
314
|
if (options.curves !== undefined) this.curves = options.curves
|
|
281
315
|
if (options.lut !== undefined) this.lut = options.lut
|
|
316
|
+
if (options.hdr !== undefined) this.hdr = options.hdr
|
|
282
317
|
this.flush()
|
|
283
318
|
if (options.bloom !== undefined) this.bloom = options.bloom
|
|
284
319
|
if (options.vignette !== undefined) this.vignette = options.vignette
|
|
@@ -348,6 +383,12 @@ export class PostProcessing {
|
|
|
348
383
|
}
|
|
349
384
|
get lut(): string | null { return this._g.lut }
|
|
350
385
|
set lut(v: string | null) { this._g.lut = v; this._lutDirty = v !== this._sentLut; this._touch() }
|
|
386
|
+
get hdr(): Required<HdrLook> { return { strength: this._g.hdrStrength, paperWhite: this._g.hdrPaperWhite } }
|
|
387
|
+
set hdr(v: HdrLook) {
|
|
388
|
+
if (v.strength !== undefined) this._g.hdrStrength = v.strength
|
|
389
|
+
if (v.paperWhite !== undefined) this._g.hdrPaperWhite = v.paperWhite
|
|
390
|
+
this._touch()
|
|
391
|
+
}
|
|
351
392
|
|
|
352
393
|
// ---- the live band: view options, written at once ----
|
|
353
394
|
|
|
@@ -445,6 +486,8 @@ export class PostProcessing {
|
|
|
445
486
|
put3(CG.MID_POINT, g.midPoint)
|
|
446
487
|
put3(CG.HIGHLIGHT_SCALE, g.highlightScale)
|
|
447
488
|
p[CG.LUT] = g.lut !== null ? 1 : 0
|
|
489
|
+
p[CG.HDR_STRENGTH] = hdrStep(g.hdrStrength, 0, 1, 0.35)
|
|
490
|
+
p[CG.HDR_PAPER_WHITE] = hdrStep(g.hdrPaperWhite, 1, 8, 1)
|
|
448
491
|
return p
|
|
449
492
|
}
|
|
450
493
|
}
|