@wildshard/shard-format 0.5.0 → 0.5.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.1",
|
|
4
4
|
"description": "The raw shardfile format: the spec, the validator and a validate CLI. The public, versioned contract every other repo builds on.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -242,6 +242,8 @@
|
|
|
242
242
|
"./postGraphLook": "./src/format/postGraphLook.ts",
|
|
243
243
|
"./postStack": "./src/format/postStack.ts",
|
|
244
244
|
"./look-light": "./src/format/look-light.ts",
|
|
245
|
+
"./look-render": "./src/format/look-render.ts",
|
|
246
|
+
"./pool-surface": "./src/format/pool-surface.ts",
|
|
245
247
|
"./practiceCourseRows": "./src/format/practiceCourseRows.ts",
|
|
246
248
|
"./preflight": "./src/format/preflight.ts",
|
|
247
249
|
"./presentation": "./src/format/presentation.ts",
|
package/src/format/look-light.ts
CHANGED
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
* `look.grade.tone` (B2) picks the display curve: `agx` (absent: the engine's AgX, as before) or `neutral` (Khronos PBR
|
|
19
19
|
* Neutral, which keeps saturated albedo saturated).
|
|
20
20
|
*
|
|
21
|
+
* `look.light.shadow` and `motes`, a lamp's `decay`, `halo` and `flicker`, `grade.vignette`, `grade.bloom.radius` and
|
|
22
|
+
* `tone: 'aces'` (meta TEMPLATES-CLEANROOM M4) are in `look-render.ts`.
|
|
23
|
+
*
|
|
21
24
|
* Plain data and checks, no three.js. Absent keys stay absent (no filled default), so a product built before these keys
|
|
22
25
|
* parses to the same bytes and keeps its source hash.
|
|
23
26
|
*/
|
|
@@ -36,6 +39,20 @@ import {
|
|
|
36
39
|
tuple,
|
|
37
40
|
} from 'valibot'
|
|
38
41
|
|
|
42
|
+
import {
|
|
43
|
+
LookMotesSchema,
|
|
44
|
+
LookShadowSchema,
|
|
45
|
+
lampDecay,
|
|
46
|
+
lampFlicker,
|
|
47
|
+
lampHalo,
|
|
48
|
+
} from './look-render.ts'
|
|
49
|
+
|
|
50
|
+
import type {
|
|
51
|
+
LookLampFlicker,
|
|
52
|
+
LookLampHalo,
|
|
53
|
+
LookMotes,
|
|
54
|
+
LookShadow,
|
|
55
|
+
} from './look-render.ts'
|
|
39
56
|
import type { GenericSchema } from 'valibot'
|
|
40
57
|
|
|
41
58
|
type Rgb = [number, number, number]
|
|
@@ -96,6 +113,9 @@ interface LookLamp {
|
|
|
96
113
|
colour: Rgb
|
|
97
114
|
intensity: number
|
|
98
115
|
distance: number
|
|
116
|
+
decay?: number
|
|
117
|
+
halo?: LookLampHalo
|
|
118
|
+
flicker?: LookLampFlicker
|
|
99
119
|
}
|
|
100
120
|
/** A warm fill from the ground: a shadowless directional light from the anti-sun heading, lifted by `lift`. */
|
|
101
121
|
interface LookBounce {
|
|
@@ -117,13 +137,16 @@ interface LookLight {
|
|
|
117
137
|
lamps?: LookLamp[]
|
|
118
138
|
bounce?: LookBounce
|
|
119
139
|
environment?: LookEnvironment
|
|
140
|
+
shadow?: LookShadow
|
|
141
|
+
motes?: LookMotes
|
|
120
142
|
}
|
|
121
143
|
/** `look.grade.tone`: the display curve; absent is the engine's AgX. */
|
|
122
|
-
type LookTone = 'agx' | 'neutral'
|
|
144
|
+
type LookTone = 'agx' | 'neutral' | 'aces'
|
|
123
145
|
/** `look.grade.bloom`: the engine bloom's intensity and luminance threshold. */
|
|
124
146
|
interface LookBloom {
|
|
125
147
|
intensity: number
|
|
126
148
|
threshold: number
|
|
149
|
+
radius?: number
|
|
127
150
|
}
|
|
128
151
|
type LookLightInput = LookLight
|
|
129
152
|
type LookBloomInput = LookBloom
|
|
@@ -164,6 +187,9 @@ const LookLampSchema: GenericSchema<LookLamp, LookLamp> = strictObject({
|
|
|
164
187
|
colour,
|
|
165
188
|
intensity: range(NONE, LAMP_INTENSITY_MAX),
|
|
166
189
|
distance: range(LAMP_DISTANCE_MIN, LAMP_DISTANCE_MAX),
|
|
190
|
+
decay: lampDecay,
|
|
191
|
+
halo: lampHalo,
|
|
192
|
+
flicker: lampFlicker,
|
|
167
193
|
})
|
|
168
194
|
const LookLampsSchema: GenericSchema<LookLamp[], LookLamp[]> = pipe(
|
|
169
195
|
array(LookLampSchema),
|
|
@@ -189,16 +215,20 @@ const LookLightSchema: GenericSchema<LookLight, LookLight> = strictObject({
|
|
|
189
215
|
lamps: exactOptional(LookLampsSchema),
|
|
190
216
|
bounce: exactOptional(LookBounceSchema),
|
|
191
217
|
environment: exactOptional(LookEnvironmentSchema),
|
|
218
|
+
shadow: exactOptional(LookShadowSchema),
|
|
219
|
+
motes: exactOptional(LookMotesSchema),
|
|
192
220
|
})
|
|
193
221
|
/** `look.grade.tone`: absent is AgX, as before. */
|
|
194
222
|
const LookToneSchema: GenericSchema<LookTone, LookTone> = picklist([
|
|
195
223
|
'agx',
|
|
196
224
|
'neutral',
|
|
225
|
+
'aces',
|
|
197
226
|
])
|
|
198
227
|
/** `look.grade.bloom`: absent is no bloom, as before. */
|
|
199
228
|
const LookBloomSchema: GenericSchema<LookBloom, LookBloom> = strictObject({
|
|
200
229
|
intensity: range(NONE, BLOOM_INTENSITY_MAX),
|
|
201
230
|
threshold: range(NONE, FULL),
|
|
231
|
+
radius: exactOptional(range(NONE, FULL)),
|
|
202
232
|
})
|
|
203
233
|
|
|
204
234
|
export {
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The render-match settings of a look (meta TEMPLATES-CLEANROOM M4): what a cleanroom three.js scene sets that a shard
|
|
3
|
+
* could not say before. Each is off when absent, and no default is filled, so an older shard file keeps its bytes.
|
|
4
|
+
*
|
|
5
|
+
* - `look.light.shadow`: the sun's shadow look: `intensity` (0 none, 1 black), the filter `radius` (texels) and the
|
|
6
|
+
* `normalBias` (metres) that keeps faces from shadowing themselves.
|
|
7
|
+
* - a lamp's `decay` (absent 2: physical), `halo` (a soft additive glow `size` metres across at `opacity`, one instanced
|
|
8
|
+
* draw for every halo) and `flicker` (`amount` of its intensity at about `rate` hertz: a fire's unsteady light).
|
|
9
|
+
* - `look.light.motes`: fireflies, sparks or dust: `count` glowing points drifting in the box `min`..`max`, in linear
|
|
10
|
+
* `colour` × `gain` (over 1 blooms), `size` metres across, one additive draw; phones draw half.
|
|
11
|
+
* - `look.grade.vignette`: the frame's dark edge, from `offset` (0 centre, 1 corner) at `darkness` (0 none); absent is
|
|
12
|
+
* the engine's own vignette.
|
|
13
|
+
*
|
|
14
|
+
* Plain data and checks, no three.js.
|
|
15
|
+
*/
|
|
16
|
+
import {
|
|
17
|
+
check,
|
|
18
|
+
exactOptional,
|
|
19
|
+
finite,
|
|
20
|
+
integer,
|
|
21
|
+
maxValue,
|
|
22
|
+
minValue,
|
|
23
|
+
number,
|
|
24
|
+
pipe,
|
|
25
|
+
strictObject,
|
|
26
|
+
tuple,
|
|
27
|
+
} from 'valibot'
|
|
28
|
+
|
|
29
|
+
import type { ExactOptionalSchema, GenericSchema } from 'valibot'
|
|
30
|
+
|
|
31
|
+
type Rgb = [number, number, number]
|
|
32
|
+
type Point = [number, number, number]
|
|
33
|
+
|
|
34
|
+
const NONE = 0
|
|
35
|
+
const FULL = 1
|
|
36
|
+
const SHADOW_RADIUS_MAX = 16
|
|
37
|
+
const SHADOW_NORMAL_BIAS_MAX = 0.5
|
|
38
|
+
const LAMP_DECAY_MAX = 2
|
|
39
|
+
const HALO_SIZE_MIN = 0.05
|
|
40
|
+
const HALO_SIZE_MAX = 8
|
|
41
|
+
const FLICKER_RATE_MAX = 30
|
|
42
|
+
/** At most this many motes in one look (one points draw). */
|
|
43
|
+
const LOOK_LIGHT_MOTES_MAX = 2048
|
|
44
|
+
const MOTE_GAIN_MAX = 8
|
|
45
|
+
const MOTE_SIZE_MIN = 0.005
|
|
46
|
+
const MOTE_SIZE_MAX = 1
|
|
47
|
+
const AXIS_X = 0
|
|
48
|
+
const AXIS_Y = 1
|
|
49
|
+
const AXIS_Z = 2
|
|
50
|
+
|
|
51
|
+
/** The sun's shadow look. */
|
|
52
|
+
interface LookShadow {
|
|
53
|
+
intensity: number
|
|
54
|
+
radius: number
|
|
55
|
+
normalBias: number
|
|
56
|
+
}
|
|
57
|
+
/** A lamp's glow: an additive halo `size` metres across at `opacity`. */
|
|
58
|
+
interface LookLampHalo {
|
|
59
|
+
size: number
|
|
60
|
+
opacity: number
|
|
61
|
+
}
|
|
62
|
+
/** A lamp's flicker: `amount` (0 to 1) of its intensity, at about `rate` hertz. */
|
|
63
|
+
interface LookLampFlicker {
|
|
64
|
+
rate: number
|
|
65
|
+
amount: number
|
|
66
|
+
}
|
|
67
|
+
/** Glowing motes drifting in the box `min`..`max`. */
|
|
68
|
+
interface LookMotes {
|
|
69
|
+
count: number
|
|
70
|
+
min: Point
|
|
71
|
+
max: Point
|
|
72
|
+
colour: Rgb
|
|
73
|
+
gain: number
|
|
74
|
+
size: number
|
|
75
|
+
}
|
|
76
|
+
/** `look.grade.vignette`: the frame's dark edge. */
|
|
77
|
+
interface LookVignette {
|
|
78
|
+
offset: number
|
|
79
|
+
darkness: number
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const real = pipe(number(), finite())
|
|
83
|
+
const range = (low: number, high: number): GenericSchema<number, number> =>
|
|
84
|
+
pipe(real, minValue(low), maxValue(high))
|
|
85
|
+
const unit = range(NONE, FULL)
|
|
86
|
+
const colour: GenericSchema<Rgb, Rgb> = tuple([unit, unit, unit])
|
|
87
|
+
const point: GenericSchema<Point, Point> = tuple([real, real, real])
|
|
88
|
+
const moteCount = pipe(
|
|
89
|
+
real,
|
|
90
|
+
integer(),
|
|
91
|
+
minValue(FULL),
|
|
92
|
+
maxValue(LOOK_LIGHT_MOTES_MAX),
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
const LookShadowSchema: GenericSchema<LookShadow, LookShadow> = strictObject({
|
|
96
|
+
intensity: unit,
|
|
97
|
+
radius: range(NONE, SHADOW_RADIUS_MAX),
|
|
98
|
+
normalBias: range(NONE, SHADOW_NORMAL_BIAS_MAX),
|
|
99
|
+
})
|
|
100
|
+
const LookLampHaloSchema: GenericSchema<LookLampHalo, LookLampHalo> =
|
|
101
|
+
strictObject({ size: range(HALO_SIZE_MIN, HALO_SIZE_MAX), opacity: unit })
|
|
102
|
+
const LookLampFlickerSchema: GenericSchema<LookLampFlicker, LookLampFlicker> =
|
|
103
|
+
strictObject({ rate: range(NONE, FLICKER_RATE_MAX), amount: unit })
|
|
104
|
+
const lampDecay: ExactOptionalSchema<
|
|
105
|
+
GenericSchema<number, number>,
|
|
106
|
+
undefined
|
|
107
|
+
> = exactOptional(range(NONE, LAMP_DECAY_MAX))
|
|
108
|
+
const lampHalo: ExactOptionalSchema<
|
|
109
|
+
GenericSchema<LookLampHalo, LookLampHalo>,
|
|
110
|
+
undefined
|
|
111
|
+
> = exactOptional(LookLampHaloSchema)
|
|
112
|
+
const lampFlicker: ExactOptionalSchema<
|
|
113
|
+
GenericSchema<LookLampFlicker, LookLampFlicker>,
|
|
114
|
+
undefined
|
|
115
|
+
> = exactOptional(LookLampFlickerSchema)
|
|
116
|
+
|
|
117
|
+
/** A box's corners, read only. */
|
|
118
|
+
interface MotesBox {
|
|
119
|
+
readonly min: readonly [number, number, number]
|
|
120
|
+
readonly max: readonly [number, number, number]
|
|
121
|
+
}
|
|
122
|
+
function ordered(row: MotesBox): boolean {
|
|
123
|
+
return (
|
|
124
|
+
row.min[AXIS_X] <= row.max[AXIS_X] &&
|
|
125
|
+
row.min[AXIS_Y] <= row.max[AXIS_Y] &&
|
|
126
|
+
row.min[AXIS_Z] <= row.max[AXIS_Z]
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
const motesRow = strictObject({
|
|
130
|
+
count: moteCount,
|
|
131
|
+
min: point,
|
|
132
|
+
max: point,
|
|
133
|
+
colour,
|
|
134
|
+
gain: range(NONE, MOTE_GAIN_MAX),
|
|
135
|
+
size: range(MOTE_SIZE_MIN, MOTE_SIZE_MAX),
|
|
136
|
+
})
|
|
137
|
+
const LookMotesSchema: GenericSchema<LookMotes, LookMotes> = pipe(
|
|
138
|
+
motesRow,
|
|
139
|
+
check<LookMotes, string>(ordered, 'Motes box min must not exceed max'),
|
|
140
|
+
)
|
|
141
|
+
const LookVignetteSchema: GenericSchema<LookVignette, LookVignette> =
|
|
142
|
+
strictObject({ offset: unit, darkness: unit })
|
|
143
|
+
|
|
144
|
+
export {
|
|
145
|
+
LOOK_LIGHT_MOTES_MAX,
|
|
146
|
+
LookLampFlickerSchema,
|
|
147
|
+
LookLampHaloSchema,
|
|
148
|
+
LookMotesSchema,
|
|
149
|
+
LookShadowSchema,
|
|
150
|
+
LookVignetteSchema,
|
|
151
|
+
lampDecay,
|
|
152
|
+
lampFlicker,
|
|
153
|
+
lampHalo,
|
|
154
|
+
}
|
|
155
|
+
export type {
|
|
156
|
+
LookLampFlicker,
|
|
157
|
+
LookLampHalo,
|
|
158
|
+
LookMotes,
|
|
159
|
+
LookShadow,
|
|
160
|
+
LookVignette,
|
|
161
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a pool's surface draws (meta TEMPLATES-CLEANROOM M4.1), the optional `surface` of a `water.json` pool:
|
|
3
|
+
*
|
|
4
|
+
* - `reflect`: `planar` mirrors the scene (desktop; phones fall back to `sky`), `sky` reflects the look's sky only.
|
|
5
|
+
* - `tint` (linear): the colour looked straight down into.
|
|
6
|
+
* - `fresnel`: the reflection's share face-on, and the power it rises by toward grazing.
|
|
7
|
+
* - `ripple`: the surface's small waves, `scale` per metre, `amplitude` (screen-space offset), `speed`.
|
|
8
|
+
* - `resolution`: the mirror's texels on a side (absent: the engine's choice for the tier).
|
|
9
|
+
*
|
|
10
|
+
* Absent: the engine's default water, as before. Plain data and checks, no three.js.
|
|
11
|
+
*/
|
|
12
|
+
import {
|
|
13
|
+
exactOptional,
|
|
14
|
+
finite,
|
|
15
|
+
integer,
|
|
16
|
+
maxValue,
|
|
17
|
+
minValue,
|
|
18
|
+
number,
|
|
19
|
+
picklist,
|
|
20
|
+
pipe,
|
|
21
|
+
strictObject,
|
|
22
|
+
tuple,
|
|
23
|
+
} from 'valibot'
|
|
24
|
+
|
|
25
|
+
import type { GenericSchema } from 'valibot'
|
|
26
|
+
|
|
27
|
+
type Rgb = [number, number, number]
|
|
28
|
+
|
|
29
|
+
const NONE = 0
|
|
30
|
+
const FULL = 1
|
|
31
|
+
const FRESNEL_POWER_MIN = 0.5
|
|
32
|
+
const FRESNEL_POWER_MAX = 8
|
|
33
|
+
const RIPPLE_SCALE_MAX = 20
|
|
34
|
+
const RIPPLE_AMPLITUDE_MAX = 0.05
|
|
35
|
+
const RIPPLE_SPEED_MAX = 8
|
|
36
|
+
const RESOLUTION_MIN = 128
|
|
37
|
+
const RESOLUTION_MAX = 2048
|
|
38
|
+
|
|
39
|
+
/** A pool's small waves. */
|
|
40
|
+
interface PoolRipple {
|
|
41
|
+
scale: number
|
|
42
|
+
amplitude: number
|
|
43
|
+
speed: number
|
|
44
|
+
}
|
|
45
|
+
/** A pool's drawn surface. */
|
|
46
|
+
interface PoolSurface {
|
|
47
|
+
reflect: 'planar' | 'sky'
|
|
48
|
+
tint: Rgb
|
|
49
|
+
fresnel: [number, number]
|
|
50
|
+
ripple: PoolRipple
|
|
51
|
+
resolution?: number
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const real = pipe(number(), finite())
|
|
55
|
+
const range = (low: number, high: number): GenericSchema<number, number> =>
|
|
56
|
+
pipe(real, minValue(low), maxValue(high))
|
|
57
|
+
const unit = range(NONE, FULL)
|
|
58
|
+
const tint: GenericSchema<Rgb, Rgb> = tuple([unit, unit, unit])
|
|
59
|
+
const fresnelPower = range(FRESNEL_POWER_MIN, FRESNEL_POWER_MAX)
|
|
60
|
+
const fresnel: GenericSchema<[number, number], [number, number]> = tuple([
|
|
61
|
+
unit,
|
|
62
|
+
fresnelPower,
|
|
63
|
+
])
|
|
64
|
+
const PoolRippleSchema: GenericSchema<PoolRipple, PoolRipple> = strictObject({
|
|
65
|
+
scale: range(NONE, RIPPLE_SCALE_MAX),
|
|
66
|
+
amplitude: range(NONE, RIPPLE_AMPLITUDE_MAX),
|
|
67
|
+
speed: range(NONE, RIPPLE_SPEED_MAX),
|
|
68
|
+
})
|
|
69
|
+
const texels = pipe(
|
|
70
|
+
real,
|
|
71
|
+
integer(),
|
|
72
|
+
minValue(RESOLUTION_MIN),
|
|
73
|
+
maxValue(RESOLUTION_MAX),
|
|
74
|
+
)
|
|
75
|
+
const PoolSurfaceSchema: GenericSchema<PoolSurface, PoolSurface> = strictObject(
|
|
76
|
+
{
|
|
77
|
+
reflect: picklist(['planar', 'sky']),
|
|
78
|
+
tint,
|
|
79
|
+
fresnel,
|
|
80
|
+
ripple: PoolRippleSchema,
|
|
81
|
+
resolution: exactOptional(texels),
|
|
82
|
+
},
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
export { PoolRippleSchema, PoolSurfaceSchema }
|
|
86
|
+
export type { PoolRipple, PoolSurface }
|
|
@@ -6,15 +6,17 @@ import { ForagerContinuation } from './ambientLife.ts';
|
|
|
6
6
|
const finite = v.pipe(v.number(), v.finite());
|
|
7
7
|
const key = v.pipe(v.string(), v.minLength(1), v.maxLength(128));
|
|
8
8
|
const point = v.strictObject({ x: finite, z: finite });
|
|
9
|
-
/** G1004/G872
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
trees:v.pipe(v.array(v.tuple([finite,finite,v.pipe(finite,v.minValue(0))])),v.
|
|
14
|
-
tops:v.pipe(v.array(finite),v.
|
|
9
|
+
/** The habitat's canopy (one top height per tree) and at most six ledges. G1004/G872 pinned the canopy at exactly 155
|
|
10
|
+
* rows, Nalati's frozen capture; its page now plants 146 (SERVER-PARITY SS10b), so the count follows the shard's own
|
|
11
|
+
* forest: any number up to 4096, one top per tree. */
|
|
12
|
+
const HabitatRows=v.strictObject({
|
|
13
|
+
trees:v.pipe(v.array(v.tuple([finite,finite,v.pipe(finite,v.minValue(0))])),v.maxLength(4096)),
|
|
14
|
+
tops:v.pipe(v.array(finite),v.maxLength(4096)),
|
|
15
15
|
ledges:v.pipe(v.array(v.strictObject({x:finite,y:finite,z:finite,r:v.pipe(finite,v.minValue(0))})),v.maxLength(6)),
|
|
16
16
|
marmots:ForagerContinuation,
|
|
17
17
|
});
|
|
18
|
+
const oneTopPerTree=(rows:{readonly trees:readonly unknown[];readonly tops:readonly unknown[]}):boolean=>rows.tops.length===rows.trees.length;
|
|
19
|
+
export const PopulationHabitatSchema:v.GenericSchema<PopulationHabitatRows,PopulationHabitatRows>=v.pipe(HabitatRows,v.check<PopulationHabitatRows,string>(oneTopPerTree,'Habitat needs one canopy top per tree'));
|
|
18
20
|
export interface PopulationHabitatRows {
|
|
19
21
|
trees:[number,number,number][];tops:number[];ledges:{x:number;y:number;z:number;r:number}[];
|
|
20
22
|
marmots:v.InferOutput<typeof ForagerContinuation>;
|
|
@@ -54,7 +54,9 @@ import { skinLookRules } from './skinAssets.ts';
|
|
|
54
54
|
import { MaterialsSchema, FamilyLooksSchema, MaterialCurvesSchema, TextureSamplersSchema, materialExists, materialTextureRefs, materialGraphRules, materialCurveRules, textureSamplerRules } from './materials.ts';
|
|
55
55
|
import { PostStackSchema, postStackRules } from './postStack.ts';
|
|
56
56
|
import { LookBloomSchema, LookLightSchema, LookToneSchema } from './look-light.ts';
|
|
57
|
+
import { LookVignetteSchema } from './look-render.ts';
|
|
57
58
|
import type { LookBloom, LookBloomInput, LookLight, LookLightInput, LookTone } from './look-light.ts';
|
|
59
|
+
import type { LookVignette } from './look-render.ts';
|
|
58
60
|
|
|
59
61
|
const channel = v.pipe(finite, v.minValue(0), v.maxValue(1));
|
|
60
62
|
const colour = v.tuple([channel, channel, channel]);
|
|
@@ -62,7 +64,7 @@ const unsigned = v.pipe(finite, v.minValue(0));
|
|
|
62
64
|
const key: v.GenericSchema<DayKeyRowsInput, DayKeyRows> = v.strictObject({ time: channel, sky: v.strictObject({ zenith: colour, horizon: colour }), fog: v.strictObject({ colour, density: unsigned, near: v.optional(unsigned), far: v.optional(unsigned) }), sun: v.strictObject({ colour, intensity: unsigned }), ambient: v.strictObject({ sky: colour, ground: colour, intensity: unsigned }) });
|
|
63
65
|
const day: v.GenericSchema<DayRowsInput, DayRows> = v.strictObject({ minutes: v.pipe(finite, v.minValue(1), v.maxValue(1440)), start: channel, maxElevation: v.pipe(finite, v.minValue(0), v.maxValue(90)), azimuth: v.pipe(finite, v.minValue(-180), v.maxValue(180)) });
|
|
64
66
|
const lookBloom = v.exactOptional(LookBloomSchema);
|
|
65
|
-
const lookGrade = v.strictObject({ exposure: finite, saturation: v.pipe(finite, v.minValue(0)), contrast: v.pipe(finite, v.minValue(0)), lut: v.nullable(ref), bloom: lookBloom, tone: v.exactOptional(LookToneSchema) });
|
|
67
|
+
const lookGrade = v.strictObject({ exposure: finite, saturation: v.pipe(finite, v.minValue(0)), contrast: v.pipe(finite, v.minValue(0)), lut: v.nullable(ref), bloom: lookBloom, tone: v.exactOptional(LookToneSchema), vignette: v.exactOptional(LookVignetteSchema) });
|
|
66
68
|
/** A colour LUT file's exact wire size: 33³ RGBA8 (the engine's render/lut format). */
|
|
67
69
|
export const LOOK_LUT_BYTES: number = 33 ** 3 * 4;
|
|
68
70
|
const rawSchema: v.GenericSchema<ShardfileRowsInput, ShardfileRows> & { readonly entries: { readonly [Key in keyof ShardfileRows]-?: v.GenericSchema<ShardfileRowsInput[Key], ShardfileRows[Key]> } } = v.strictObject({
|
|
@@ -184,7 +186,7 @@ export interface Shardfile {
|
|
|
184
186
|
samplers?: v.InferOutput<typeof TextureSamplersSchema>;
|
|
185
187
|
post?: v.InferOutput<typeof PostStackSchema>;
|
|
186
188
|
light?: LookLight;
|
|
187
|
-
grade: { exposure: number; saturation: number; contrast: number; lut: string | null; bloom?: LookBloom; tone?: LookTone };
|
|
189
|
+
grade: { exposure: number; saturation: number; contrast: number; lut: string | null; bloom?: LookBloom; tone?: LookTone; vignette?: LookVignette };
|
|
188
190
|
clock: 'engine';
|
|
189
191
|
day?: v.InferOutput<typeof day> | undefined;
|
|
190
192
|
dayOverride: number | null;
|
|
@@ -398,6 +400,7 @@ interface ShardfileRowsInputFields {
|
|
|
398
400
|
lut: (v.InferInput<typeof ref>) | null;
|
|
399
401
|
bloom?: LookBloomInput;
|
|
400
402
|
tone?: LookTone;
|
|
403
|
+
vignette?: LookVignette;
|
|
401
404
|
};
|
|
402
405
|
clock: 'engine';
|
|
403
406
|
day?: DayRowsInput | undefined;
|
|
@@ -473,6 +476,7 @@ interface ShardfileRowsFields {
|
|
|
473
476
|
lut: (v.InferOutput<typeof ref>) | null;
|
|
474
477
|
bloom?: LookBloom;
|
|
475
478
|
tone?: LookTone;
|
|
479
|
+
vignette?: LookVignette;
|
|
476
480
|
};
|
|
477
481
|
clock: 'engine';
|
|
478
482
|
day?: DayRows | undefined;
|
package/src/format/water.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
import { PoolSurfaceSchema } from './pool-surface.ts';
|
|
3
|
+
import type { PoolSurface } from './pool-surface.ts';
|
|
2
4
|
|
|
3
5
|
const coord = v.pipe(v.number(), v.finite(), v.minValue(-250), v.maxValue(250));
|
|
4
6
|
export const WaterBodyIdSchema: v.GenericSchema<WaterBodyIdInput, WaterBodyId> = v.pipe(v.string(), v.regex(/^[a-z][a-z0-9.-]*$/u), v.maxLength(128));
|
|
@@ -30,8 +32,9 @@ const dryEntries = v.optional(v.pipe(v.array(v.picklist(['north', 'east', 'south
|
|
|
30
32
|
export const StreamWaterSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{ readonly id: v.GenericSchema<StreamWaterRowsInput['id'], StreamWaterRows['id']>; readonly kind: v.GenericSchema<StreamWaterRowsInput['kind'], StreamWaterRows['kind']>; readonly width: v.GenericSchema<StreamWaterRowsInput['width'], StreamWaterRows['width']>; readonly points: v.GenericSchema<StreamWaterRowsInput['points'], StreamWaterRows['points']>; readonly levels: v.OptionalSchema<v.GenericSchema<Exclude<StreamWaterRowsInput['levels'], undefined>, Exclude<StreamWaterRows['levels'], undefined>>, undefined>; readonly dryEntries: v.OptionalSchema<v.GenericSchema<Exclude<StreamWaterRowsInput['dryEntries'], undefined>, Exclude<StreamWaterRows['dryEntries'], undefined>>, undefined>; }, undefined>, v.CheckAction<{ [K in keyof StreamWaterRows]: StreamWaterRows[K] }, 'stream fits cell, has nonzero segments and declares its live levels'>]> = v.pipe(v.strictObject({ id, kind: v.literal('stream'), width: v.pipe(coord, v.minValue(0.01), v.maxValue(100)), points: v.pipe(v.array(streamPoint), v.minLength(2), v.maxLength(128)), levels, dryEntries }), v.check((s) => s.points.every((p, i) => {
|
|
31
33
|
const prev = s.points[i - 1]; return (p.under === undefined || s.levels?.[p.under] !== undefined) && Math.abs(p.x) + s.width / 2 <= 250 && Math.abs(p.z) + s.width / 2 <= 250 && (prev === undefined || p.x !== prev.x || p.z !== prev.z);
|
|
32
34
|
}), 'stream fits cell, has nonzero segments and declares its live levels'));
|
|
35
|
+
const poolSurface = v.exactOptional(PoolSurfaceSchema);
|
|
33
36
|
export const WaterBodySchema: v.GenericSchema<WaterBodyRowsInput, WaterBodyRows> = v.variant('kind', [
|
|
34
|
-
v.strictObject({ id, kind: v.literal('pool'), level: coord, shape: v.variant('kind', [circle, polygon]), dryEntries }),
|
|
37
|
+
v.strictObject({ id, kind: v.literal('pool'), level: coord, shape: v.variant('kind', [circle, polygon]), dryEntries, surface: poolSurface }),
|
|
35
38
|
v.strictObject({ id: v.literal('sea'), kind: v.literal('sea'), level: coord, waves: v.boolean(), dryEntries }),
|
|
36
39
|
StreamWaterSchema,
|
|
37
40
|
]);
|
|
@@ -124,6 +127,7 @@ export type WaterBodyRowsInput = ({
|
|
|
124
127
|
])[];
|
|
125
128
|
});
|
|
126
129
|
dryEntries?: ('north' | 'east' | 'south' | 'west')[] | undefined;
|
|
130
|
+
surface?: PoolSurface;
|
|
127
131
|
}) | ({
|
|
128
132
|
id: 'sea';
|
|
129
133
|
kind: 'sea';
|
|
@@ -148,6 +152,7 @@ export type WaterBodyRows = ({
|
|
|
148
152
|
])[];
|
|
149
153
|
});
|
|
150
154
|
dryEntries?: ('north' | 'east' | 'south' | 'west')[] | undefined;
|
|
155
|
+
surface?: PoolSurface;
|
|
151
156
|
}) | ({
|
|
152
157
|
id: 'sea';
|
|
153
158
|
kind: 'sea';
|