@kerf-js/keel 0.0.0-stage → 0.1.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/LICENSE +16 -0
- package/README.md +306 -2
- package/package.json +59 -3
- package/src/blend-inset.ts +79 -0
- package/src/blend.ts +120 -0
- package/src/client.d.ts +9 -0
- package/src/generate/bust.ts +24 -0
- package/src/generate/bust.worker.ts +4 -0
- package/src/generate/pack.ts +69 -0
- package/src/generate/plate.ts +51 -0
- package/src/generate/plate.worker.ts +4 -0
- package/src/generate/serve.ts +56 -0
- package/src/generate/surface.ts +16 -0
- package/src/generate/surface.worker.ts +4 -0
- package/src/generate.ts +133 -0
- package/src/governor.ts +87 -0
- package/src/index.d.ts +15 -0
- package/src/index.mjs +63 -0
- package/src/lit.d.ts +384 -0
- package/src/paint-live.ts +60 -0
- package/src/paint-recipe.d.mts +29 -0
- package/src/paint-recipe.mjs +29 -0
- package/src/paint-worker.mjs +20 -0
- package/src/paint.d.mts +37 -0
- package/src/paint.mjs +180 -0
- package/src/runtime.ts +35 -0
- package/src/scene.ts +289 -0
- package/src/stage.ts +192 -0
- package/vendor/LICENSE +21 -0
- package/vendor/LICENSE-modules +21 -0
- package/vendor/NOTICE +24 -0
- package/vendor/README.md +13 -0
- package/vendor/lit.d.mts +1 -0
- package/vendor/lit.mjs +2 -0
- package/vendor/lock.json +177 -0
- package/vendor/modules/band/events.d.ts +20 -0
- package/vendor/modules/band/index.d.ts +29 -0
- package/vendor/modules/band/player.d.ts +43 -0
- package/vendor/modules/band/roll.d.ts +14 -0
- package/vendor/modules/band/score.d.ts +45 -0
- package/vendor/modules/band/styles.data.d.ts +37 -0
- package/vendor/modules/band/voices.d.ts +33 -0
- package/vendor/modules/band.d.mts +1 -0
- package/vendor/modules/band.mjs +2 -0
- package/vendor/modules/butterflies/butterflies.glsl.d.ts +2 -0
- package/vendor/modules/butterflies/flight.d.ts +68 -0
- package/vendor/modules/butterflies/index.d.ts +79 -0
- package/vendor/modules/butterflies/wing.d.ts +38 -0
- package/vendor/modules/butterflies.d.mts +1 -0
- package/vendor/modules/butterflies.inputs.json +73 -0
- package/vendor/modules/butterflies.mjs +39 -0
- package/vendor/modules/camera-rail/index.d.ts +113 -0
- package/vendor/modules/camera-rail.d.mts +1 -0
- package/vendor/modules/camera-rail.mjs +2 -0
- package/vendor/modules/device-profile/index.d.ts +47 -0
- package/vendor/modules/device-profile.d.mts +1 -0
- package/vendor/modules/device-profile.mjs +2 -0
- package/vendor/modules/lit-finish/dress.d.ts +34 -0
- package/vendor/modules/lit-finish/finish.glsl.d.ts +15 -0
- package/vendor/modules/lit-finish/index.d.ts +33 -0
- package/vendor/modules/lit-finish/lit.d.ts +52 -0
- package/vendor/modules/lit-finish/pass.d.ts +35 -0
- package/vendor/modules/lit-finish/settings.d.ts +88 -0
- package/vendor/modules/lit-finish.d.mts +1 -0
- package/vendor/modules/lit-finish.inputs.json +200 -0
- package/vendor/modules/lit-finish.mjs +267 -0
- package/vendor/modules/look/index.d.ts +159 -0
- package/vendor/modules/look.d.mts +1 -0
- package/vendor/modules/look.inputs.json +23 -0
- package/vendor/modules/look.mjs +2 -0
- package/vendor/modules/motes/index.d.ts +83 -0
- package/vendor/modules/motes/motes.glsl.d.ts +9 -0
- package/vendor/modules/motes/place.d.ts +59 -0
- package/vendor/modules/motes.d.mts +1 -0
- package/vendor/modules/motes.inputs.json +116 -0
- package/vendor/modules/motes.mjs +68 -0
- package/vendor/modules/plate-painter/dab.d.ts +44 -0
- package/vendor/modules/plate-painter/exact.d.ts +19 -0
- package/vendor/modules/plate-painter/foliage.d.ts +4 -0
- package/vendor/modules/plate-painter/gpu.d.ts +65 -0
- package/vendor/modules/plate-painter/index.d.ts +14 -0
- package/vendor/modules/plate-painter/paint.glsl.d.ts +14 -0
- package/vendor/modules/plate-painter/plan.d.ts +42 -0
- package/vendor/modules/plate-painter/recipe.d.ts +136 -0
- package/vendor/modules/plate-painter/scene.d.ts +4 -0
- package/vendor/modules/plate-painter.d.mts +1 -0
- package/vendor/modules/plate-painter.inputs.json +50 -0
- package/vendor/modules/plate-painter.mjs +384 -0
- package/vendor/modules/portrait/body.d.ts +25 -0
- package/vendor/modules/portrait/bust.d.ts +67 -0
- package/vendor/modules/portrait/cap.d.ts +12 -0
- package/vendor/modules/portrait/compile.d.ts +8 -0
- package/vendor/modules/portrait/exact.d.ts +17 -0
- package/vendor/modules/portrait/hair.d.ts +26 -0
- package/vendor/modules/portrait/hand.d.ts +30 -0
- package/vendor/modules/portrait/head.d.ts +18 -0
- package/vendor/modules/portrait/index.d.ts +12 -0
- package/vendor/modules/portrait/mesh.d.ts +24 -0
- package/vendor/modules/portrait/parts.d.ts +33 -0
- package/vendor/modules/portrait/portrait.glsl.d.ts +4 -0
- package/vendor/modules/portrait/render.d.ts +125 -0
- package/vendor/modules/portrait/sdf.d.ts +75 -0
- package/vendor/modules/portrait/settings.d.ts +27 -0
- package/vendor/modules/portrait.d.mts +1 -0
- package/vendor/modules/portrait.inputs.json +111 -0
- package/vendor/modules/portrait.mjs +2 -0
- package/vendor/modules/quality/index.d.ts +130 -0
- package/vendor/modules/quality.d.mts +1 -0
- package/vendor/modules/quality.inputs.json +34 -0
- package/vendor/modules/quality.mjs +2 -0
- package/vendor/modules/scene-blend/blend.d.ts +54 -0
- package/vendor/modules/scene-blend/blend.glsl.d.ts +8 -0
- package/vendor/modules/scene-blend/index.d.ts +25 -0
- package/vendor/modules/scene-blend/lit.d.ts +61 -0
- package/vendor/modules/scene-blend/noise.d.ts +13 -0
- package/vendor/modules/scene-blend/settings.d.ts +63 -0
- package/vendor/modules/scene-blend.d.mts +1 -0
- package/vendor/modules/scene-blend.inputs.json +133 -0
- package/vendor/modules/scene-blend.mjs +2 -0
- package/vendor/modules/section-post/index.d.ts +23 -0
- package/vendor/modules/section-post/lit.d.ts +47 -0
- package/vendor/modules/section-post/noise.d.ts +14 -0
- package/vendor/modules/section-post/post.d.ts +31 -0
- package/vendor/modules/section-post/post.glsl.d.ts +8 -0
- package/vendor/modules/section-post/settings.d.ts +84 -0
- package/vendor/modules/section-post.d.mts +1 -0
- package/vendor/modules/section-post.inputs.json +107 -0
- package/vendor/modules/section-post.mjs +53 -0
- package/vendor/modules/surfaces/exact.d.ts +8 -0
- package/vendor/modules/surfaces/field.d.ts +7 -0
- package/vendor/modules/surfaces/gpu.d.ts +19 -0
- package/vendor/modules/surfaces/index.d.ts +17 -0
- package/vendor/modules/surfaces/paint.d.ts +28 -0
- package/vendor/modules/surfaces/plan.d.ts +39 -0
- package/vendor/modules/surfaces/print.d.ts +55 -0
- package/vendor/modules/surfaces/recipe.d.ts +143 -0
- package/vendor/modules/surfaces/surface.glsl.d.ts +4 -0
- package/vendor/modules/surfaces.d.mts +1 -0
- package/vendor/modules/surfaces.inputs.json +54 -0
- package/vendor/modules/surfaces.mjs +172 -0
- package/vendor/modules/tracks/index.d.ts +66 -0
- package/vendor/modules/tracks.d.mts +1 -0
- package/vendor/modules/tracks.mjs +2 -0
- package/vendor/modules/tree-growth/bend.d.ts +28 -0
- package/vendor/modules/tree-growth/frame.d.ts +60 -0
- package/vendor/modules/tree-growth/index.d.ts +23 -0
- package/vendor/modules/tree-growth/light.d.ts +13 -0
- package/vendor/modules/tree-growth/math.d.ts +19 -0
- package/vendor/modules/tree-growth/model.d.ts +100 -0
- package/vendor/modules/tree-growth/sectors.d.ts +10 -0
- package/vendor/modules/tree-growth/simulation.d.ts +58 -0
- package/vendor/modules/tree-growth/species.d.ts +117 -0
- package/vendor/modules/tree-growth/species.data.d.ts +2 -0
- package/vendor/modules/tree-growth/year.d.ts +38 -0
- package/vendor/modules/tree-growth.d.mts +1 -0
- package/vendor/modules/tree-growth.inputs.json +75 -0
- package/vendor/modules/tree-growth.mjs +2 -0
- package/vendor/modules/tree-render/features.d.ts +9 -0
- package/vendor/modules/tree-render/forest/bake.d.ts +41 -0
- package/vendor/modules/tree-render/forest/cards.d.ts +28 -0
- package/vendor/modules/tree-render/forest/forest.d.ts +156 -0
- package/vendor/modules/tree-render/index.d.ts +52 -0
- package/vendor/modules/tree-render/inputs.d.ts +260 -0
- package/vendor/modules/tree-render/instances.d.ts +66 -0
- package/vendor/modules/tree-render/math.d.ts +8 -0
- package/vendor/modules/tree-render/tree/bark.d.ts +20 -0
- package/vendor/modules/tree-render/tree/leaves.d.ts +29 -0
- package/vendor/modules/tree-render/tree/litter.d.ts +21 -0
- package/vendor/modules/tree-render/tree/ornaments.d.ts +36 -0
- package/vendor/modules/tree-render/tree/roots.d.ts +75 -0
- package/vendor/modules/tree-render/tree/shapes.d.ts +49 -0
- package/vendor/modules/tree-render/tree/tree.d.ts +239 -0
- package/vendor/modules/tree-render/tree/wood.d.ts +27 -0
- package/vendor/modules/tree-render/wind.d.ts +51 -0
- package/vendor/modules/tree-render.d.mts +1 -0
- package/vendor/modules/tree-render.inputs.json +45 -0
- package/vendor/modules/tree-render.mjs +2 -0
- package/vendor/modules/voxel-dither/dither.glsl.d.ts +9 -0
- package/vendor/modules/voxel-dither/index.d.ts +35 -0
- package/vendor/modules/voxel-dither/light.d.ts +33 -0
- package/vendor/modules/voxel-dither/lit.d.ts +86 -0
- package/vendor/modules/voxel-dither/pass.d.ts +46 -0
- package/vendor/modules/voxel-dither/screens.d.ts +21 -0
- package/vendor/modules/voxel-dither/settings.d.ts +307 -0
- package/vendor/modules/voxel-dither/signals.d.ts +35 -0
- package/vendor/modules/voxel-dither.d.mts +1 -0
- package/vendor/modules/voxel-dither.inputs.json +295 -0
- package/vendor/modules/voxel-dither.mjs +452 -0
- package/vendor/modules/world-light/index.d.ts +133 -0
- package/vendor/modules/world-light.d.mts +1 -0
- package/vendor/modules/world-light.inputs.json +68 -0
- package/vendor/modules/world-light.mjs +2 -0
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** A point of a wing's outline: x out along the span (0 at the body, 1 at the tip), y forward along the body. */
|
|
2
|
+
export interface WingPoint {
|
|
3
|
+
readonly x: number;
|
|
4
|
+
readonly y: number;
|
|
5
|
+
}
|
|
6
|
+
/** A Shape as keel/lit makes it: the parts this module calls. */
|
|
7
|
+
export interface ShapeLike {
|
|
8
|
+
moveTo(x: number, y: number): unknown;
|
|
9
|
+
bezierCurveTo(ax: number, ay: number, bx: number, by: number, x: number, y: number): unknown;
|
|
10
|
+
getPoints(divisions?: number): readonly WingPoint[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* The mesh. `position` is three numbers a vertex: the span out from the body (a wing's, never negative), 0, and the
|
|
14
|
+
* place along the body, forward positive; a body vertex gives its own x. `wing` is two: the side (1 right, -1 left,
|
|
15
|
+
* 0 the body) and the edge (0 at the root, 1 on the outline).
|
|
16
|
+
*/
|
|
17
|
+
export interface WingMesh {
|
|
18
|
+
readonly position: Float32Array;
|
|
19
|
+
readonly wing: Float32Array;
|
|
20
|
+
readonly index: number[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Draws one wing's outline on a keel/lit Shape: a forewing reaching forward to its tip, a notch, a rounder hindwing.
|
|
24
|
+
*
|
|
25
|
+
* @param shape A new keel/lit Shape.
|
|
26
|
+
* @param divisions Points along each curve.
|
|
27
|
+
* @returns The outline, without its closing repeat.
|
|
28
|
+
*/
|
|
29
|
+
export declare function wingOutline(shape: ShapeLike, divisions?: number): WingPoint[];
|
|
30
|
+
/** Twice the outline's signed area: above 0 when it runs counter-clockwise in its own x and y. */
|
|
31
|
+
export declare function windingOf(outline: readonly WingPoint[]): number;
|
|
32
|
+
/**
|
|
33
|
+
* A butterfly's mesh from one wing's outline: the right wing as drawn, the left its mirror, and the body.
|
|
34
|
+
*
|
|
35
|
+
* @param outline One wing, as `wingOutline` gives it.
|
|
36
|
+
* @returns The mesh's arrays, for a keel/lit Geometry.
|
|
37
|
+
*/
|
|
38
|
+
export declare function wingMesh(outline: readonly WingPoint[]): WingMesh;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './butterflies/index.js'
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
{
|
|
2
|
+
"protocol": "keel-module-inputs@1",
|
|
3
|
+
"fields": [
|
|
4
|
+
{
|
|
5
|
+
"key": "count",
|
|
6
|
+
"label": "Butterflies",
|
|
7
|
+
"required": false,
|
|
8
|
+
"type": "number",
|
|
9
|
+
"min": 0,
|
|
10
|
+
"max": 50,
|
|
11
|
+
"step": 1,
|
|
12
|
+
"control": "slider",
|
|
13
|
+
"default": 4
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"key": "scale",
|
|
17
|
+
"label": "Wingspan",
|
|
18
|
+
"required": false,
|
|
19
|
+
"type": "number",
|
|
20
|
+
"min": 0,
|
|
21
|
+
"max": 2,
|
|
22
|
+
"step": 0.005,
|
|
23
|
+
"unit": "world units",
|
|
24
|
+
"default": 0.06
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"key": "flapHz",
|
|
28
|
+
"label": "Wingbeats",
|
|
29
|
+
"required": false,
|
|
30
|
+
"type": "number",
|
|
31
|
+
"min": 0,
|
|
32
|
+
"max": 20,
|
|
33
|
+
"step": 0.5,
|
|
34
|
+
"unit": "Hz",
|
|
35
|
+
"default": 6
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"key": "speed",
|
|
39
|
+
"label": "Wander speed",
|
|
40
|
+
"required": false,
|
|
41
|
+
"placement": "advanced",
|
|
42
|
+
"type": "number",
|
|
43
|
+
"min": 0,
|
|
44
|
+
"max": 4,
|
|
45
|
+
"step": 0.05,
|
|
46
|
+
"unit": "rad/s",
|
|
47
|
+
"default": 0.3
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"key": "glow",
|
|
51
|
+
"label": "Edge glow",
|
|
52
|
+
"required": false,
|
|
53
|
+
"help": "Over about 1 the wing edges reach a bloom threshold of 1.",
|
|
54
|
+
"type": "number",
|
|
55
|
+
"min": 0,
|
|
56
|
+
"max": 4,
|
|
57
|
+
"step": 0.05,
|
|
58
|
+
"control": "slider",
|
|
59
|
+
"default": 1.5
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"key": "seed",
|
|
63
|
+
"label": "Seed",
|
|
64
|
+
"required": false,
|
|
65
|
+
"placement": "advanced",
|
|
66
|
+
"type": "number",
|
|
67
|
+
"min": 0,
|
|
68
|
+
"max": 2147483647,
|
|
69
|
+
"step": 1,
|
|
70
|
+
"default": 1
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// butterflies@0.1.0 from keel-modules 53c36d0 (MIT). Generated: don't edit.
|
|
2
|
+
var v=`
|
|
3
|
+
attribute vec2 aWing;
|
|
4
|
+
attribute float aFlap;
|
|
5
|
+
uniform float uTime, uFlapHz, uStill;
|
|
6
|
+
varying vec2 vWing;
|
|
7
|
+
varying float vShade;
|
|
8
|
+
void main() {
|
|
9
|
+
float beat = sin(6.2831853 * uFlapHz * uTime + aFlap);
|
|
10
|
+
// (Wings from 30 degrees under level to 70 over; still, open and a little raised.)
|
|
11
|
+
float a = mix(0.35 + 0.87 * beat, 0.15, uStill);
|
|
12
|
+
float b = a * 1.35;
|
|
13
|
+
float span = position.x;
|
|
14
|
+
float inner = min(span, 0.45);
|
|
15
|
+
float outer = max(span - 0.45, 0.0);
|
|
16
|
+
vec2 xy = inner * vec2(cos(a), sin(a)) + outer * vec2(cos(b), sin(b));
|
|
17
|
+
float side = aWing.x;
|
|
18
|
+
vec3 p = side == 0.0 ? position : vec3(xy.x * side, xy.y, position.z);
|
|
19
|
+
// (The body rises as the wings come down.)
|
|
20
|
+
p.y -= 0.06 * beat * (1.0 - uStill);
|
|
21
|
+
vec3 n = side == 0.0 ? vec3(0.0, 1.0, 0.0) : vec3(-sin(a) * side, cos(a), 0.0);
|
|
22
|
+
vec3 world = normalize(mat3(modelMatrix) * mat3(instanceMatrix) * n);
|
|
23
|
+
vShade = 0.6 + 0.4 * abs(world.y);
|
|
24
|
+
vWing = aWing;
|
|
25
|
+
gl_Position = projectionMatrix * viewMatrix * modelMatrix * instanceMatrix * vec4(p, 1.0);
|
|
26
|
+
}
|
|
27
|
+
`,w=`
|
|
28
|
+
uniform vec3 uUpper, uUnder, uBody;
|
|
29
|
+
uniform float uGlow, uLight;
|
|
30
|
+
varying vec2 vWing;
|
|
31
|
+
varying float vShade;
|
|
32
|
+
void main() {
|
|
33
|
+
vec3 wing = gl_FrontFacing ? uUpper : uUnder;
|
|
34
|
+
vec3 base = mix(uBody, wing, abs(vWing.x));
|
|
35
|
+
float rim = smoothstep(0.55, 1.0, vWing.y);
|
|
36
|
+
vec3 c = base * uLight * vShade + rim * uGlow * mix(base, vec3(1.0), 0.65);
|
|
37
|
+
gl_FragColor = vec4(c, 1.0);
|
|
38
|
+
}
|
|
39
|
+
`;var g={count:4,seed:1,centre:[0,0,0],radius:[1.2,.6,.6],scale:.06,speed:.3,flapHz:6,colors:{upper:"#2d5de0",under:"#7ea2ff",body:"#1b2f6e"},glow:1.5,light:1,keepOut:[]},T=6.283185307179586,U=50,z=[.6,.28,.12],C=[1,2.1,3.9];function b(e,n,t){let r=Math.imul(e|0,2654435761)^Math.imul(n+1,2246822519)^Math.imul(t+1,3266489917);return r=Math.imul(r^r>>>16,2146121005),r=Math.imul(r^r>>>15,2221713035),r^=r>>>16,(r>>>0)/4294967296}var O=(e,n,t)=>Math.min(t,Math.max(n,e));function x(e={}){let n={...g,...e};return{...n,count:O(Math.floor(n.count),0,U),seed:n.seed|0,radius:[Math.max(0,n.radius[0]),Math.max(0,n.radius[1]),Math.max(0,n.radius[2])],scale:Math.max(0,n.scale),speed:Math.max(0,n.speed),flapHz:Math.max(0,n.flapHz),colors:{...g.colors,...n.colors},glow:Math.max(0,n.glow),light:Math.max(0,n.light)}}function k(e={}){let n=x(e),t=[];for(let r=0;r<n.count;r+=1){let o=[],u=[],i=[];for(let s=0;s<3;s+=1)for(let a=0;a<3;a+=1){let l=s*3+a;o.push(n.speed*(C[a]??1)*(.7+.6*b(n.seed,r,l))),u.push((n.radius[s]??0)*(z[a]??0)),i.push(b(n.seed,r,10+l)*T)}t.push({rate:o,reach:u,phase:i,flap:b(n.seed,r,20)*T})}return t}function P(e,n){for(let t of n){let r=[e[0]-t.centre[0],e[1]-t.centre[1],e[2]-t.centre[2]],o=Math.hypot(r[0],r[1],r[2]);if(o>=t.radius)continue;let u=o>1e-9?[r[0]/o,r[1]/o,r[2]/o]:[0,1,0];for(let i=0;i<3;i+=1)e[i]=(t.centre[i]??0)+(u[i]??0)*t.radius}}function R(e){let n=e[0]??0,t=(e[1]??0)*.5,r=e[2]??0,o=Math.hypot(n,t,r);return o>1e-9?[n/o,t/o,r/o]:[0,0,1]}function L(e,n,t={}){let r=t.centre??g.centre,o=[r[0],r[1],r[2]],u=[0,0,0];for(let i=0;i<9;i+=1){let s=Math.floor(i/3),a=e.rate[i]??0,l=e.reach[i]??0,c=a*n+(e.phase[i]??0);o[s]=(o[s]??0)+l*Math.sin(c),u[s]=(u[s]??0)+l*a*Math.cos(c)}return P(o,t.keepOut??[]),{at:o,front:R(u)}}var f={x:.03,y:0},B=.72,W=.2,V=.3,I=-.42,h=.035;function M(e,n=8){e.moveTo(.03,.12),e.bezierCurveTo(.25,.45,.72,.64,.96,.52),e.bezierCurveTo(1.02,.32,.78,.1,.56,.03),e.bezierCurveTo(.82,-.15,.76,-.5,.5,-.56),e.bezierCurveTo(.3,-.62,.1,-.36,.03,-.12);let t=e.getPoints(n).map(u=>({x:u.x,y:u.y})),r=t[0],o=t[t.length-1];return r&&o&&t.length>1&&r.x===o.x&&r.y===o.y&&t.pop(),t}function A(e){let n=0;for(let t=0;t<e.length;t+=1){let r=e[t]??f,o=e[(t+1)%e.length]??f;n+=r.x*o.y-o.x*r.y}return n}function p(e,n,t){return e.position.push(n[0],n[1],n[2]),e.wing.push(t[0],t[1]),e.position.length/3-1}function S(e,n,t){let r=A(n)>0==t>0,o=(a,l,c)=>{e.index.push(...r?[a,c,l]:[a,l,c])},u=p(e,[f.x,0,f.y],[t,0]),i=[],s=[];for(let a of n){let l=f.x+(a.x-f.x)*B,c=f.y+(a.y-f.y)*B;i.push(p(e,[l,0,c],[t,W])),s.push(p(e,[a.x,0,a.y],[t,1]))}for(let a=0;a<n.length;a+=1){let l=(a+1)%n.length,[c,y,m,d]=[i[a]??u,i[l]??u,s[a]??u,s[l]??u];o(u,c,y),o(c,m,d),o(c,d,y)}}function G(e){let n=p(e,[0,0,V],[0,0]),t=p(e,[0,0,I],[0,0]);for(let r of[[h,0],[-h,0],[0,h],[0,-h]]){let o=p(e,[r[0],r[1],0],[0,0]);e.index.push(n,o,t)}}function F(e){let n={position:[],wing:[],index:[]};return S(n,e,1),S(n,e,-1),G(n),{position:new Float32Array(n.position),wing:new Float32Array(n.wing),index:n.index}}function N(e,n){let t=F(M(new e.Shape)),r=new e.Geometry;return r.setAttribute("position",new e.Attribute(t.position,3)),r.setAttribute("aWing",new e.Attribute(t.wing,2)),r.setAttribute("aFlap",new e.InstanceAttribute(new Float32Array(n.map(o=>o.flap)),1)),r.setIndex(t.index),r}function _(e,n){return{uTime:{value:0},uStill:{value:0},uFlapHz:{value:n.flapHz},uGlow:{value:n.glow},uLight:{value:n.light},uUpper:{value:new e.Vector3(1,1,1)},uUnder:{value:new e.Vector3(1,1,1)},uBody:{value:new e.Vector3(1,1,1)}}}function H(e,n,t,r){let[o,u,i]=t.front,s=Math.hypot(o,i),[a,l]=s>1e-6?[i/s,-o/s]:[1,0],[c,y,m]=[u*l,i*a-o*l,-u*a],d=r/2;e.set([a*d,0,l*d,0,c*d,y*d,m*d,0,o*d,u*d,i*d,0],n*16),e.set([t.at[0],t.at[1],t.at[2],1],n*16+12)}var j={upper:"uUpper",under:"uUnder",body:"uBody"};function Q(e,n={}){let t=x(n),r=k(t),o=N(e,r),u=_(e,t),i=new e.CustomMaterial({uniforms:u,vertexShader:v,fragmentShader:w,side:"both"}),s=new e.Instances(o,i,Math.max(1,r.length));s.count=r.length,s.frustumCulled=!1;let a={...t.colors},l={mesh:s,update(c){let y=c.still===!0,m=y?0:c.time;u.uTime.value=m,u.uStill.value=y?1:0,r.forEach((d,E)=>{H(s.instanceMatrix.array,E,L(d,m,t),t.scale)}),s.instanceMatrix.needsUpdate=!0},setColors(c){Object.assign(a,c);for(let y of["upper","under","body"]){let m=new e.Color(a[y]);u[j[y]].value.set(m.r,m.g,m.b)}},dispose(){o.dispose(),i.dispose()}};return l.setColors(a),l.update({time:0}),l}export{w as BUTTERFLY_FRAGMENT,v as BUTTERFLY_VERTEX,g as DEFAULT_BUTTERFLIES,x as butterflySettings,Q as createButterflies,b as flightHash,L as flyAt,k as planFlights,A as windingOf,F as wingMesh,M as wingOutline};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* camera-rail: a camera on keyed tracks, scrubbed by position. MIT.
|
|
3
|
+
*
|
|
4
|
+
* `at(position, frame)` samples the camera's eye, target, fov and roll from
|
|
5
|
+
* its tracks through the `tracks` module's sampler (passed in), turns the
|
|
6
|
+
* view by the pointer's pan and tilt, and returns the view. A baked flight
|
|
7
|
+
* rides a Catmull-Rom path by a keyed `along`. `applyView` puts a view on a
|
|
8
|
+
* keel/lit camera, which is injected: the maths never touches a renderer.
|
|
9
|
+
*/
|
|
10
|
+
/** An [x, y, z] in world units. */
|
|
11
|
+
export type Vec3 = readonly [number, number, number];
|
|
12
|
+
/** What a sampled property holds: the `tracks` module's Value. */
|
|
13
|
+
export type Value = number | readonly number[] | string;
|
|
14
|
+
/** The `tracks` module's `sampleTracks`, or anything of its shape: values by target, then property. */
|
|
15
|
+
export type Sampler<T> = (tracks: T, position: number, time?: number) => Readonly<Record<string, Readonly<Record<string, Value>>>>;
|
|
16
|
+
/** A Catmull-Rom path the eye, and the target when given, ride by the keyed `along` (0..1). */
|
|
17
|
+
export interface RailPath {
|
|
18
|
+
readonly eye: readonly Vec3[];
|
|
19
|
+
readonly target?: readonly Vec3[];
|
|
20
|
+
}
|
|
21
|
+
/** How a rail is set up. */
|
|
22
|
+
export interface RailOptions<T> {
|
|
23
|
+
/** The tracks, in the `tracks` module's format. */
|
|
24
|
+
readonly tracks: T;
|
|
25
|
+
/** The target name the camera's tracks use. Defaults to "camera". */
|
|
26
|
+
readonly name?: string;
|
|
27
|
+
/** The pointer's pan scale: the pointer at a side edge turns the view by 0.1 rad times this. Defaults to 0. */
|
|
28
|
+
readonly pan?: number;
|
|
29
|
+
/** The pointer's tilt scale, the same for the top and bottom edges. Defaults to 0. */
|
|
30
|
+
readonly tilt?: number;
|
|
31
|
+
/** The fov in degrees when no track keys one. Defaults to 30. */
|
|
32
|
+
readonly fov?: number;
|
|
33
|
+
/** A path for a baked flight, ridden by the keyed `along`. */
|
|
34
|
+
readonly path?: RailPath;
|
|
35
|
+
}
|
|
36
|
+
/** What the page knows this frame. */
|
|
37
|
+
export interface Frame {
|
|
38
|
+
/** The pointer, each axis in -1..1 with y up; null or left out when it is away. */
|
|
39
|
+
readonly pointer?: {
|
|
40
|
+
readonly x: number;
|
|
41
|
+
readonly y: number;
|
|
42
|
+
} | null;
|
|
43
|
+
/** Scroll velocity, 0 at rest. See {@link pointerStrength}. */
|
|
44
|
+
readonly velocity?: number;
|
|
45
|
+
/** The clock, for tracks driven by time. */
|
|
46
|
+
readonly time?: number;
|
|
47
|
+
}
|
|
48
|
+
/** The camera this frame: eye and target in world units, fov in degrees, roll in radians round the view axis. */
|
|
49
|
+
export interface View {
|
|
50
|
+
readonly eye: Vec3;
|
|
51
|
+
readonly target: Vec3;
|
|
52
|
+
readonly fov: number;
|
|
53
|
+
readonly roll: number;
|
|
54
|
+
}
|
|
55
|
+
/** A rail: {@link createCameraRail}. */
|
|
56
|
+
export interface CameraRail {
|
|
57
|
+
/** The view at `position`. Call once a frame: the pointer's smoothing steps on each call. */
|
|
58
|
+
at(position: number, frame?: Frame): View;
|
|
59
|
+
}
|
|
60
|
+
/** The parts of a keel/lit camera {@link applyView} touches. Pass the stage's PerspectiveCamera. */
|
|
61
|
+
export interface RailCamera {
|
|
62
|
+
readonly position: {
|
|
63
|
+
set(x: number, y: number, z: number): unknown;
|
|
64
|
+
};
|
|
65
|
+
lookAt(x: number, y: number, z: number): unknown;
|
|
66
|
+
rotateZ(angle: number): unknown;
|
|
67
|
+
fov: number;
|
|
68
|
+
updateProjectionMatrix(): unknown;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The pointer's hold on the view: 1 at rest, `0.05 + max(0, 0.2 - |v| * 10)` while scrolling, so it
|
|
72
|
+
* floors at 0.05 from |v| = 0.02 up.
|
|
73
|
+
*
|
|
74
|
+
* @param velocity The scroll velocity, 0 at rest.
|
|
75
|
+
* @returns The strength, 0.05..1.
|
|
76
|
+
*/
|
|
77
|
+
export declare function pointerStrength(velocity: number): number;
|
|
78
|
+
/**
|
|
79
|
+
* A point along a Catmull-Rom spline through `points`, the ends held.
|
|
80
|
+
*
|
|
81
|
+
* @param points The points the spline passes through, in order.
|
|
82
|
+
* @param u How far along, 0 at the first point and 1 at the last; clamped.
|
|
83
|
+
* @returns The point there.
|
|
84
|
+
*/
|
|
85
|
+
export declare function catmullRom(points: readonly Vec3[], u: number): Vec3;
|
|
86
|
+
/**
|
|
87
|
+
* Turns the view from `eye` to `target`: `pan` radians round the up axis, positive to the right,
|
|
88
|
+
* then `tilt` round the view's right axis, positive upward. The distance to the target is kept.
|
|
89
|
+
*
|
|
90
|
+
* @param eye Where the camera stands.
|
|
91
|
+
* @param target What it looks at before the turn.
|
|
92
|
+
* @param pan The turn round the up axis, radians.
|
|
93
|
+
* @param tilt The turn up or down, radians.
|
|
94
|
+
* @returns What it looks at after the turn.
|
|
95
|
+
*/
|
|
96
|
+
export declare function turnView(eye: Vec3, target: Vec3, pan: number, tilt: number): Vec3;
|
|
97
|
+
/**
|
|
98
|
+
* Puts a view on a keel/lit camera: stands it at the eye, aims it at the target, rolls it, and sets
|
|
99
|
+
* the fov when it changed.
|
|
100
|
+
*
|
|
101
|
+
* @param camera The camera, injected.
|
|
102
|
+
* @param view The view to apply.
|
|
103
|
+
*/
|
|
104
|
+
export declare function applyView(camera: RailCamera, view: View): void;
|
|
105
|
+
/**
|
|
106
|
+
* Builds a rail on keyed tracks. The camera's tracks key `eye`, `target` (vectors), `fov` (degrees),
|
|
107
|
+
* `roll` (radians) and `along` (0..1 on the path); each is optional.
|
|
108
|
+
*
|
|
109
|
+
* @param sample The `tracks` module's `sampleTracks`.
|
|
110
|
+
* @param options The tracks, the pointer scales, the default fov and the path.
|
|
111
|
+
* @returns The rail.
|
|
112
|
+
*/
|
|
113
|
+
export declare function createCameraRail<T>(sample: Sampler<T>, options: RailOptions<T>): CameraRail;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './camera-rail/index.js'
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// camera-rail@0.1.0 from keel-modules 53c36d0 (MIT). Generated: don't edit.
|
|
2
|
+
function t(t){return 0===t?1:.05+Math.max(0,.2-10*Math.abs(t))}function e(t,e){let a=t.length-1,r=Math.min(Math.max(e,0),1)*a,n=Math.min(Math.floor(r),a-1),o=r-n,l=e=>t[Math.min(Math.max(e,0),a)]??[0,0,0],[i,h,s,M]=[l(n-1),l(n),l(n+1),l(n+2)],f=t=>.5*(2*h[t]+(s[t]-i[t])*o+(2*i[t]-5*h[t]+4*s[t]-M[t])*o*o+(3*h[t]-i[t]-3*s[t]+M[t])*o*o*o);return[f(0),f(1),f(2)]}function a(t,e,a,r){let n=e[0]-t[0],o=e[1]-t[1],l=e[2]-t[2],i=n*Math.cos(a)-l*Math.sin(a),h=n*Math.sin(a)+l*Math.cos(a),s=Math.sqrt(i*i+h*h);if(0===s)return[t[0]+i,t[1]+o,t[2]+h];let M=Math.sqrt(s*s+o*o),f=Math.atan2(o,s)+r,p=Math.cos(f)*M/s;return[t[0]+i*p,t[1]+Math.sin(f)*M,t[2]+h*p]}function r(t,e){t.position.set(e.eye[0],e.eye[1],e.eye[2]),t.lookAt(e.target[0],e.target[1],e.target[2]),0!==e.roll&&t.rotateZ(e.roll),t.fov!==e.fov&&(t.fov=e.fov,t.updateProjectionMatrix())}var n=(t,e)=>"number"==typeof t?t:e,o=t=>"object"==typeof t&&3===t.length?[t[0]??0,t[1]??0,t[2]??0]:void 0;function l(r,l){let{tracks:i,name:h="camera",pan:s=0,tilt:M=0,fov:f=30,path:p}=l,u={strength:1,pan:0,tilt:0};return{at(l,c={}){let g=r(i,l,c.time)[h]??{},[m,y]=(t=>{let a=n(t.along,0);return[o(t.eye)??(p?e(p.eye,a):[0,0,5]),o(t.target)??(p?.target?e(p.target,a):[0,0,0])]})(g);return(e=>{let a=e.pointer??{x:0,y:0};u.strength+=.1*(t(e.velocity??0)-u.strength);let r=.5*u.strength;u.pan+=(.1*a.x*s-u.pan)*r,u.tilt+=(.1*a.y*M-u.tilt)*r})(c),{eye:m,target:0===u.pan&&0===u.tilt?y:a(m,y,u.pan,u.tilt),fov:n(g.fov,f),roll:n(g.roll,0)}}}}export{r as applyView,e as catmullRom,l as createCameraRail,t as pointerStrength,a as turnView};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* device-profile: what kind of device this is, and how much to draw on it.
|
|
3
|
+
*
|
|
4
|
+
* The signals are read once (`readSignals`) and judged by a pure function
|
|
5
|
+
* (`profileOf`), so any device can be replayed from a record of its signals.
|
|
6
|
+
*/
|
|
7
|
+
export type DeviceClass = "phone" | "tablet" | "desktop";
|
|
8
|
+
export type DeviceTier = "low" | "mid" | "high";
|
|
9
|
+
/** What a browser and its GPU say of themselves; any may be missing. */
|
|
10
|
+
export interface DeviceSignals {
|
|
11
|
+
readonly userAgent: string;
|
|
12
|
+
/** `navigator.userAgentData.mobile`, where a browser has it. */
|
|
13
|
+
readonly mobile?: boolean;
|
|
14
|
+
readonly touchPoints: number;
|
|
15
|
+
/** The screen's short side, in CSS pixels. */
|
|
16
|
+
readonly shortSide: number;
|
|
17
|
+
readonly pixelRatio: number;
|
|
18
|
+
/** Device memory, in GiB, and logical cores. */
|
|
19
|
+
readonly memory?: number;
|
|
20
|
+
readonly cores?: number;
|
|
21
|
+
/** `MAX_FRAGMENT_UNIFORM_VECTORS`, 0 with no WebGL2. */
|
|
22
|
+
readonly uniforms: number;
|
|
23
|
+
/** The unmasked GPU name, where a browser gives it. */
|
|
24
|
+
readonly gpu?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface DeviceProfile {
|
|
27
|
+
readonly class: DeviceClass;
|
|
28
|
+
readonly tier: DeviceTier;
|
|
29
|
+
readonly uniforms: number;
|
|
30
|
+
/** The most parts a body should have here: what is worth the pixels, before what the GPU can hold. */
|
|
31
|
+
readonly parts: number;
|
|
32
|
+
/** The pixel ratio to draw at. */
|
|
33
|
+
readonly pixelRatio: number;
|
|
34
|
+
}
|
|
35
|
+
export interface ProfileOptions {
|
|
36
|
+
readonly force?: DeviceClass;
|
|
37
|
+
}
|
|
38
|
+
/** A phone, a tablet or a desktop. (An iPad's Safari calls itself a Mac: only its touch points give it away.) */
|
|
39
|
+
export declare function classOf(s: DeviceSignals): DeviceClass;
|
|
40
|
+
/**
|
|
41
|
+
* How much it can draw: a software GPU or little memory is low whatever it is, a handheld mid at most, the rest high.
|
|
42
|
+
*/
|
|
43
|
+
export declare function tierOf(s: DeviceSignals, cls: DeviceClass): DeviceTier;
|
|
44
|
+
/** A device's profile, from its signals. */
|
|
45
|
+
export declare function profileOf(s: DeviceSignals, options?: ProfileOptions): DeviceProfile;
|
|
46
|
+
/** This browser's signals. */
|
|
47
|
+
export declare function readSignals(): DeviceSignals;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './device-profile/index.js'
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// device-profile@0.1.0 from keel-modules 53c36d0 (MIT). Generated: don't edit.
|
|
2
|
+
var e={low:48,mid:48,high:64},t={low:1,mid:1.5,high:2};function i(e){return/iPhone|iPod|Android.*Mobile/u.test(e.userAgent)?"phone":/iPad|Android|Tablet/u.test(e.userAgent)||e.userAgent.includes("Macintosh")&&e.touchPoints>1?"tablet":!0===e.mobile?(e=>e.shortSide<600)(e)?"phone":"tablet":"desktop"}function o(e,t){return/SwiftShader|llvmpipe|Software/iu.test(e.gpu??"")||(e.memory??8)<=2||(e.cores??8)<=2?"low":"desktop"===t?"high":"mid"}function n(n,r={}){let a=r.force??i(n),s=o(n,a);return{class:a,tier:s,uniforms:n.uniforms,parts:e[s],pixelRatio:Math.min(n.pixelRatio,t[s])}}function r(){let e=document.createElement("canvas").getContext("webgl2");if(!e)return{uniforms:0};let t=e.getExtension("WEBGL_debug_renderer_info"),i=Number(e.getParameter(e.MAX_FRAGMENT_UNIFORM_VECTORS)),o=t?String(e.getParameter(t.UNMASKED_RENDERER_WEBGL)):void 0;return e.getExtension("WEBGL_lose_context")?.loseContext(),void 0===o?{uniforms:i}:{uniforms:i,gpu:o}}function a(){let e=navigator,t=e.userAgentData?.mobile,i=e.deviceMemory;return{userAgent:navigator.userAgent,touchPoints:navigator.maxTouchPoints,shortSide:Math.min(screen.width,screen.height),pixelRatio:window.devicePixelRatio,cores:navigator.hardwareConcurrency,...void 0===t?{}:{mobile:t},...void 0===i?{}:{memory:i},...r()}}export{i as classOf,n as profileOf,a as readSignals,o as tierOf};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Uniform } from "./lit.js";
|
|
2
|
+
interface ShaderLike {
|
|
3
|
+
readonly uniforms: Record<string, Uniform>;
|
|
4
|
+
vertexShader: string;
|
|
5
|
+
fragmentShader: string;
|
|
6
|
+
}
|
|
7
|
+
export interface DressMaterialLike {
|
|
8
|
+
onCompile?: ((shader: ShaderLike, renderer: unknown) => void) | undefined;
|
|
9
|
+
customProgramCacheKey?: (() => string) | undefined;
|
|
10
|
+
readonly side?: unknown;
|
|
11
|
+
readonly alphaTest?: number;
|
|
12
|
+
needsUpdate: boolean;
|
|
13
|
+
readonly userData: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface DressNodeLike {
|
|
16
|
+
readonly isMesh?: boolean;
|
|
17
|
+
readonly material?: DressMaterialLike | readonly DressMaterialLike[];
|
|
18
|
+
traverse(visit: (node: DressNodeLike) => void): void;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Dresses one material once: its own onCompile runs first, then the finish's; its program key keeps its own.
|
|
22
|
+
*
|
|
23
|
+
* @param material A keel/lit material.
|
|
24
|
+
* @param uniforms The finish's shared uniforms (uFinishTranslucency, uFinishVariation, uFinishMute).
|
|
25
|
+
*/
|
|
26
|
+
export declare function dressMaterial(material: DressMaterialLike, uniforms: Record<string, Uniform>): void;
|
|
27
|
+
/**
|
|
28
|
+
* Dresses every mesh's materials under a root; a material already dressed is left alone.
|
|
29
|
+
*
|
|
30
|
+
* @param root A stage or part of one.
|
|
31
|
+
* @param uniforms The finish's shared uniforms.
|
|
32
|
+
*/
|
|
33
|
+
export declare function dressTree(root: DressNodeLike, uniforms: Record<string, Uniform>): void;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const VERTEX_GLSL = "\nvoid main() { gl_Position = vec4(position.xy, 0.0, 1.0); }\n";
|
|
2
|
+
export declare const AO_GLSL = "\nprecision highp float;\n\nuniform sampler2D tDepth;\nuniform float uNear;\nuniform float uFar;\nuniform float uOrtho;\nuniform vec2 uProj;\n// Distance in front of the eye for a window depth.\nfloat viewDepth(float d) {\n if (uOrtho > 0.5) return uNear + d * (uFar - uNear);\n return uNear * uFar / (uFar - (uFar - uNear) * d);\n}\nvec3 viewAt(vec2 uv) {\n float z = viewDepth(texture2D(tDepth, uv).x);\n vec2 ndc = uv * 2.0 - 1.0;\n return uOrtho > 0.5 ? vec3(ndc / uProj, -z) : vec3(ndc * z / uProj, -z);\n}\nfloat ign(vec2 p) { return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); }\n\nuniform vec2 uTexel;\nuniform vec2 uAoSize;\nuniform float uRadius;\nuniform vec3 uKernel[16];\n// The surface's normal from its neighbours' depths, from the nearer side of each pair so edges stay clean.\nvec3 normalAt(vec2 uv, vec3 p) {\n vec3 r = viewAt(uv + vec2(uTexel.x, 0.0)) - p;\n vec3 l = p - viewAt(uv - vec2(uTexel.x, 0.0));\n vec3 u = viewAt(uv + vec2(0.0, uTexel.y)) - p;\n vec3 d = p - viewAt(uv - vec2(0.0, uTexel.y));\n return normalize(cross(abs(r.z) < abs(l.z) ? r : l, abs(u.z) < abs(d.z) ? u : d));\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / uAoSize;\n if (texture2D(tDepth, uv).x >= 0.99999) { gl_FragColor = vec4(1.0); return; }\n vec3 p = viewAt(uv);\n vec3 n = normalAt(uv, p);\n float a = ign(gl_FragCoord.xy) * 6.2831853;\n vec3 spin = vec3(cos(a), sin(a), 0.0);\n vec3 t = normalize(spin - n * dot(spin, n));\n mat3 tbn = mat3(t, cross(n, t), n);\n float occluded = 0.0;\n for (int i = 0; i < 16; i++) {\n vec3 s = p + tbn * uKernel[i] * uRadius;\n vec2 ndc = uOrtho > 0.5 ? s.xy * uProj : s.xy * uProj / -s.z;\n vec2 at = ndc * 0.5 + 0.5;\n if (at.x < 0.0 || at.y < 0.0 || at.x > 1.0 || at.y > 1.0) continue;\n float surface = -viewDepth(texture2D(tDepth, at).x);\n float near = smoothstep(0.0, 1.0, uRadius / max(abs(p.z - surface), 1e-4));\n occluded += step(s.z + 0.03 * uRadius, surface) * near;\n }\n // (Squared: the open share of the hemisphere, as the eye reads contact shade.)\n float open = 1.0 - occluded / 16.0;\n gl_FragColor = vec4(vec3(open * open), 1.0);\n}\n";
|
|
3
|
+
/** Pass 3: the lit picture's own light, in linear HDR: AO, the aerial haze, exposure. */
|
|
4
|
+
export declare const LIGHT_GLSL = "\nprecision highp float;\n\nuniform sampler2D tDepth;\nuniform float uNear;\nuniform float uFar;\nuniform float uOrtho;\nuniform vec2 uProj;\n// Distance in front of the eye for a window depth.\nfloat viewDepth(float d) {\n if (uOrtho > 0.5) return uNear + d * (uFar - uNear);\n return uNear * uFar / (uFar - (uFar - uNear) * d);\n}\nvec3 viewAt(vec2 uv) {\n float z = viewDepth(texture2D(tDepth, uv).x);\n vec2 ndc = uv * 2.0 - 1.0;\n return uOrtho > 0.5 ? vec3(ndc / uProj, -z) : vec3(ndc * z / uProj, -z);\n}\nfloat ign(vec2 p) { return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); }\n\nuniform sampler2D tColor;\nuniform sampler2D tAo;\nuniform vec2 uSize;\nuniform vec2 uAoSize;\nuniform float uAo;\nuniform float uExposure;\nuniform vec3 uHaze;\nuniform float uHazeDensity;\nuniform float uHazeStart;\nuniform float uHazeGlow;\nuniform vec3 uSunDir;\nuniform vec3 uSunColour;\nuniform float uView;\n// The half-size AO, blurred over 4x4 of its texels among those at the same depth, so its noise is gone and\n// nothing bleeds across a silhouette.\nfloat aoAt(vec2 uv, float z) {\n float sum = 0.0;\n float weight = 0.0;\n for (int y = 0; y < 4; y++) {\n for (int x = 0; x < 4; x++) {\n vec2 at = uv + (vec2(float(x), float(y)) - 1.5) / uAoSize;\n float w = exp(-abs(viewDepth(texture2D(tDepth, at).x) - z) / (0.05 * z + 0.02));\n sum += texture2D(tAo, at).r * w;\n weight += w;\n }\n }\n return weight > 0.0 ? sum / weight : 1.0;\n}\nvoid main() {\n vec2 uv = gl_FragCoord.xy / uSize;\n vec3 c = texture2D(tColor, uv).rgb;\n bool sky = texture2D(tDepth, uv).x >= 0.99999;\n vec3 p = viewAt(uv);\n float occlusion = sky ? 1.0 : aoAt(uv, -p.z);\n if (uView > 0.5) { gl_FragColor = vec4(vec3(occlusion), 1.0); return; }\n c *= mix(1.0, occlusion, uAo);\n // Aerial haze: the air between the eye and the point, lit brighter toward the sun (Henyey-Greenstein, g 0.6,\n // 4pi-normalized: 10 toward the sun).\n float dist = sky ? 1e5 : length(p);\n float through = exp(-max(dist - uHazeStart, 0.0) * uHazeDensity);\n float mu = dot(normalize(p), uSunDir);\n float lobe = 0.64 / pow(1.36 - 1.2 * mu, 1.5);\n vec3 air = uHaze * (1.0 + uSunColour * uHazeGlow * lobe * 0.15);\n c = mix(air, c, uHazeDensity > 0.0 ? through : 1.0);\n gl_FragColor = vec4(c * uExposure, 1.0);\n}\n";
|
|
5
|
+
/**
|
|
6
|
+
* Pass 4: TAA. This frame (jittered) against the last, found where it was through the depth and last frame's
|
|
7
|
+
* camera, held inside this frame's 3x3 neighbourhood so nothing that moved trails.
|
|
8
|
+
*/
|
|
9
|
+
export declare const TAA_GLSL = "\nprecision highp float;\n\nuniform sampler2D tDepth;\nuniform float uNear;\nuniform float uFar;\nuniform float uOrtho;\nuniform vec2 uProj;\n// Distance in front of the eye for a window depth.\nfloat viewDepth(float d) {\n if (uOrtho > 0.5) return uNear + d * (uFar - uNear);\n return uNear * uFar / (uFar - (uFar - uNear) * d);\n}\nvec3 viewAt(vec2 uv) {\n float z = viewDepth(texture2D(tDepth, uv).x);\n vec2 ndc = uv * 2.0 - 1.0;\n return uOrtho > 0.5 ? vec3(ndc / uProj, -z) : vec3(ndc * z / uProj, -z);\n}\nfloat ign(vec2 p) { return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); }\n\nuniform sampler2D tCurrent;\nuniform sampler2D tHistory;\nuniform vec2 uSize;\nuniform mat4 uInvView;\nuniform mat4 uPrevViewProj;\nuniform float uBlend;\nuniform float uReset;\n// Weighted by 1/(1+luma), so one bright pixel does not ring over its neighbours.\nvec3 tame(vec3 c) { return c / (1.0 + dot(c, vec3(0.2126, 0.7152, 0.0722))); }\nvec3 untame(vec3 c) { return c / max(1.0 - dot(c, vec3(0.2126, 0.7152, 0.0722)), 1e-4); }\nvoid main() {\n vec2 uv = gl_FragCoord.xy / uSize;\n vec3 current = tame(texture2D(tCurrent, uv).rgb);\n vec3 low = current;\n vec3 high = current;\n for (int y = -1; y <= 1; y++) {\n for (int x = -1; x <= 1; x++) {\n vec3 n = tame(texture2D(tCurrent, uv + vec2(float(x), float(y)) / uSize).rgb);\n low = min(low, n);\n high = max(high, n);\n }\n }\n vec4 before = uPrevViewProj * (uInvView * vec4(viewAt(uv), 1.0));\n vec2 then = before.xy / before.w * 0.5 + 0.5;\n bool lost = uReset > 0.5 || then.x < 0.0 || then.y < 0.0 || then.x > 1.0 || then.y > 1.0;\n vec3 history = clamp(tame(texture2D(tHistory, then).rgb), low, high);\n gl_FragColor = vec4(untame(lost ? current : mix(history, current, uBlend)), 1.0);\n}\n";
|
|
10
|
+
/** Pass 5: what is brighter than the threshold, at quarter size (a 2x2 box of the resolved picture). */
|
|
11
|
+
export declare const BRIGHT_GLSL = "\nprecision highp float;\nuniform sampler2D tResolved;\nuniform vec2 uBloomSize;\nuniform vec2 uSize;\nuniform float uThreshold;\nvoid main() {\n vec2 uv = gl_FragCoord.xy / uBloomSize;\n vec2 t = 1.0 / uSize;\n vec3 c = 0.25 * (texture2D(tResolved, uv + vec2(-t.x, -t.y)).rgb + texture2D(tResolved, uv + vec2(t.x, -t.y)).rgb\n + texture2D(tResolved, uv + vec2(-t.x, t.y)).rgb + texture2D(tResolved, uv + vec2(t.x, t.y)).rgb);\n float l = dot(c, vec3(0.2126, 0.7152, 0.0722));\n gl_FragColor = vec4(c * max(l - uThreshold, 0.0) / max(l, 1e-4), 1.0);\n}\n";
|
|
12
|
+
/** Pass 6 and 7: a wide Gaussian along uDir (texels), nine taps on linear filtering. */
|
|
13
|
+
export declare const BLUR_GLSL = "\nprecision highp float;\nuniform sampler2D tBlur;\nuniform vec2 uBloomSize;\nuniform vec2 uDir;\nvoid main() {\n vec2 uv = gl_FragCoord.xy / uBloomSize;\n vec2 d = uDir / uBloomSize;\n vec3 c = texture2D(tBlur, uv).rgb * 0.2270270270;\n c += (texture2D(tBlur, uv + d * 1.3846153846).rgb + texture2D(tBlur, uv - d * 1.3846153846).rgb) * 0.3162162162;\n c += (texture2D(tBlur, uv + d * 3.2307692308).rgb + texture2D(tBlur, uv - d * 3.2307692308).rgb) * 0.0702702703;\n gl_FragColor = vec4(c, 1.0);\n}\n";
|
|
14
|
+
/** Pass 8, onto the canvas: bloom, the tone map, the grade, sRGB and a half-step of noise against banding. */
|
|
15
|
+
export declare const GRADE_GLSL = "\nprecision highp float;\n\n// AgX (Troy Sobotka's, in Benjamin Wrensch's fit), back to linear display light.\nvec3 agx(vec3 c) {\n const mat3 into = mat3(0.842479062253094, 0.0423282422610123, 0.0423756549057051, 0.0784335999999992, 0.878468636469772, 0.0784336, 0.0792237451477643, 0.0791661274605434, 0.879142973793104);\n const mat3 back = mat3(1.19687900512017, -0.0528968517574562, -0.0529716355144438, -0.0980208811401368, 1.15190312990417, -0.0980434501171241, -0.0990297440797205, -0.0989611768448433, 1.15107367264116);\n vec3 x = clamp(log2(max(into * c, vec3(1e-10))), -12.47393, 4.026069);\n x = (x + 12.47393) / 16.499999;\n vec3 x2 = x * x;\n vec3 x4 = x2 * x2;\n x = 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + 0.4298 * x2 + 0.1191 * x - 0.00232;\n return pow(max(back * x, vec3(0.0)), vec3(2.2));\n}\n// Khronos PBR Neutral.\nvec3 neutral(vec3 c) {\n float x = min(c.r, min(c.g, c.b));\n c -= x < 0.08 ? x - 6.25 * x * x : 0.04;\n float peak = max(c.r, max(c.g, c.b));\n if (peak < 0.76) return c;\n float top = 1.0 - 0.0576 / (peak - 0.52);\n c *= top / peak;\n return mix(c, vec3(top), 1.0 - 1.0 / (0.15 * (peak - top) + 1.0));\n}\n// ACES, Narkowicz's fit.\nvec3 aces(vec3 c) {\n c *= 0.6;\n return clamp(c * (2.51 * c + 0.03) / (c * (2.43 * c + 0.59) + 0.14), 0.0, 1.0);\n}\nvec3 srgb(vec3 c) {\n return mix(c * 12.92, 1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055, step(0.0031308, c));\n}\n\nuniform sampler2D tResolved;\nuniform sampler2D tBloom;\nuniform vec2 uSize;\nuniform float uBloom;\nuniform float uTone;\nuniform float uSaturation;\nuniform float uContrast;\nuniform float uWarmth;\nuniform float uVignette;\nuniform float uView;\nfloat ign(vec2 p) { return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); }\nvoid main() {\n vec2 uv = gl_FragCoord.xy / uSize;\n vec3 c = texture2D(tResolved, uv).rgb;\n if (uView > 0.5) { gl_FragColor = vec4(srgb(clamp(c, 0.0, 1.0)), 1.0); return; }\n c += texture2D(tBloom, uv).rgb * uBloom;\n vec3 m = uTone < 0.5 ? agx(c) : (uTone < 1.5 ? neutral(c) : aces(c));\n float l = dot(m, vec3(0.2126, 0.7152, 0.0722));\n m = max(mix(vec3(l), m, uSaturation), 0.0);\n m = mix(m, m * vec3(0.92, 0.98, 1.1), uWarmth * (1.0 - clamp(l * 2.0, 0.0, 1.0)));\n m = mix(m, m * vec3(1.08, 1.0, 0.88), uWarmth * clamp(l * 1.5 - 0.3, 0.0, 1.0));\n vec3 s = srgb(clamp(m, 0.0, 1.0));\n s = clamp((s - 0.5) * uContrast + 0.5, 0.0, 1.0);\n vec2 q = uv - 0.5;\n s *= 1.0 - uVignette * dot(q, q) * 1.6;\n gl_FragColor = vec4(s + (ign(gl_FragCoord.xy) - 0.5) / 255.0, 1.0);\n}\n";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The finish a lit, full-colour keel/lit stage needs to read as real: ambient
|
|
3
|
+
* occlusion from depth, aerial haze lit toward the sun, sunlight through
|
|
4
|
+
* leaves, colour muted and varied across the world, TAA, bloom, a filmic tone
|
|
5
|
+
* map and a light grade. The realism look's counterpart to voxel-dither. MIT.
|
|
6
|
+
*
|
|
7
|
+
* renderer.toneMapping = "none"; // the finish tone maps
|
|
8
|
+
* const finish = createLitFinish(lit, renderer, { tonemap: "agx", ao: 0.8 });
|
|
9
|
+
* finish.setSize(cssWidth, cssHeight, renderer.getPixelRatio());
|
|
10
|
+
* finish.setSun([sun.x, sun.y, sun.z], "#fff2dc");
|
|
11
|
+
* finish.setHaze({ colour: "#a9bfd6", density: 0.015, start: 6 });
|
|
12
|
+
* renderer.setAnimationLoop(() => finish.render(scene, camera));
|
|
13
|
+
*
|
|
14
|
+
* The scene is drawn once, jittered, into a multisampled linear target with
|
|
15
|
+
* depth. AO is taken from that depth at half size (16 samples, a different
|
|
16
|
+
* spin per pixel) and blurred among pixels at the same depth, so it never
|
|
17
|
+
* bleeds across a silhouette. Haze replaces a stage's fog: give the stage none.
|
|
18
|
+
* TAA reprojects the last frame through the depth and the last camera. Light
|
|
19
|
+
* through leaves and colour variation live in the stage's own materials: the
|
|
20
|
+
* finish chains them onto each material's onCompile every 30 frames, so parts
|
|
21
|
+
* a stage builds later are dressed too. A dithered fade moves its pattern by
|
|
22
|
+
* `ditherOffset()` to resolve under TAA.
|
|
23
|
+
*
|
|
24
|
+
* keel/lit is injected: the module never imports it and never touches globals.
|
|
25
|
+
*/
|
|
26
|
+
export { TONEMAPS, DEFAULT_FINISH_SETTINGS, AO_SAMPLES, finishSettings, aoKernel, directionInView, linearColour, multiply4, jitterAt, ditherShiftAt, } from "./settings.js";
|
|
27
|
+
export type { Tonemap, FinishSettings } from "./settings.js";
|
|
28
|
+
export { VERTEX_GLSL, AO_GLSL, LIGHT_GLSL, TAA_GLSL, BRIGHT_GLSL, BLUR_GLSL, GRADE_GLSL } from "./finish.glsl.js";
|
|
29
|
+
export { dressMaterial, dressTree } from "./dress.js";
|
|
30
|
+
export type { DressMaterialLike, DressNodeLike } from "./dress.js";
|
|
31
|
+
export type { LitLike } from "./lit.js";
|
|
32
|
+
export { createLitFinish } from "./pass.js";
|
|
33
|
+
export type { Haze, LitFinish } from "./pass.js";
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface TextureLike {
|
|
2
|
+
dispose(): void;
|
|
3
|
+
}
|
|
4
|
+
export interface RenderTargetLike {
|
|
5
|
+
readonly texture: TextureLike;
|
|
6
|
+
readonly depthTexture: TextureLike | null;
|
|
7
|
+
setSize(width: number, height: number): void;
|
|
8
|
+
dispose(): void;
|
|
9
|
+
}
|
|
10
|
+
export interface Uniform {
|
|
11
|
+
value: unknown;
|
|
12
|
+
}
|
|
13
|
+
export interface ShaderMaterialLike {
|
|
14
|
+
readonly uniforms: Record<string, Uniform>;
|
|
15
|
+
dispose(): void;
|
|
16
|
+
}
|
|
17
|
+
interface MatrixLike {
|
|
18
|
+
readonly elements: ArrayLike<number>;
|
|
19
|
+
}
|
|
20
|
+
export interface CameraLike {
|
|
21
|
+
readonly near: number;
|
|
22
|
+
readonly far: number;
|
|
23
|
+
readonly isOrthographicCamera?: boolean;
|
|
24
|
+
readonly matrixWorld: MatrixLike;
|
|
25
|
+
readonly matrixWorldInverse: MatrixLike;
|
|
26
|
+
readonly projectionMatrix: MatrixLike;
|
|
27
|
+
}
|
|
28
|
+
export interface RendererLike {
|
|
29
|
+
getRenderTarget(): RenderTargetLike | null;
|
|
30
|
+
setRenderTarget(target: RenderTargetLike | null): void;
|
|
31
|
+
render(scene: unknown, camera: unknown): void;
|
|
32
|
+
}
|
|
33
|
+
export interface DisposableLike {
|
|
34
|
+
dispose(): void;
|
|
35
|
+
}
|
|
36
|
+
interface MeshLike {
|
|
37
|
+
frustumCulled: boolean;
|
|
38
|
+
}
|
|
39
|
+
export interface SceneLike {
|
|
40
|
+
add(object: unknown): void;
|
|
41
|
+
}
|
|
42
|
+
/** The parts of keel/lit this module calls. Pass the keel/lit namespace itself. */
|
|
43
|
+
export interface LitLike {
|
|
44
|
+
readonly RenderTarget: new (width: number, height: number, options: Readonly<Record<string, unknown>>) => RenderTargetLike;
|
|
45
|
+
readonly DepthTexture: new (width: number, height: number) => TextureLike;
|
|
46
|
+
readonly CustomMaterial: new (parameters: Readonly<Record<string, unknown>>) => ShaderMaterialLike;
|
|
47
|
+
plane(width: number, height: number): DisposableLike;
|
|
48
|
+
readonly Mesh: new (geometry: unknown, material: unknown) => MeshLike;
|
|
49
|
+
readonly Stage: new () => SceneLike;
|
|
50
|
+
readonly OrthoCamera: new (left: number, right: number, top: number, bottom: number, near: number, far: number) => unknown;
|
|
51
|
+
}
|
|
52
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { CameraLike, LitLike, RendererLike } from "./lit.js";
|
|
2
|
+
import type { FinishSettings } from "./settings.js";
|
|
3
|
+
/** The air a finish draws in: its colour ("#rrggbb" or linear RGB), how much per metre and where it starts. */
|
|
4
|
+
export interface Haze {
|
|
5
|
+
readonly colour?: unknown;
|
|
6
|
+
readonly density?: number;
|
|
7
|
+
readonly start?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface LitFinish {
|
|
10
|
+
readonly settings: FinishSettings;
|
|
11
|
+
setSettings(input?: unknown): FinishSettings;
|
|
12
|
+
/** The canvas's CSS size and pixel ratio (the renderer's). */
|
|
13
|
+
setSize(cssWidth: number, cssHeight: number, devicePixelRatio: number): void;
|
|
14
|
+
/** The sun's direction toward it, in world space, and its colour (linear; only its hue counts). */
|
|
15
|
+
setSun(direction: readonly number[], colour?: unknown): void;
|
|
16
|
+
/** The air's colour, and optionally its density and start, which override the settings'. */
|
|
17
|
+
setHaze(haze: Haze): void;
|
|
18
|
+
/** Dresses a stage's materials now (render does it every 30 frames for the scene it draws). */
|
|
19
|
+
dress(root: unknown): void;
|
|
20
|
+
/** Whole pixels a dithered fade should move by this frame, so TAA resolves it (0, 0 without TAA). */
|
|
21
|
+
ditherOffset(): [number, number];
|
|
22
|
+
render(scene: unknown, camera: CameraLike): void;
|
|
23
|
+
/** What the canvas shows: the finished picture (default), or the AO alone, for tuning. */
|
|
24
|
+
setView(view: "final" | "ao"): void;
|
|
25
|
+
dispose(): void;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Binds a lit finish to a renderer: AO, aerial haze, light through leaves, colour variation, TAA, bloom, a tone map
|
|
29
|
+
* and a grade over a keel/lit stage. The renderer's own tone mapping should be "none"; the finish does its own.
|
|
30
|
+
*
|
|
31
|
+
* @param lit The keel/lit namespace (WebGL2).
|
|
32
|
+
* @param renderer The renderer that owns the canvas.
|
|
33
|
+
* @param input Settings, normalized through `finishSettings`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function createLitFinish(lit: LitLike, renderer: RendererLike, input?: unknown): LitFinish;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
export declare const TONEMAPS: readonly ["agx", "neutral", "aces"];
|
|
2
|
+
export type Tonemap = (typeof TONEMAPS)[number];
|
|
3
|
+
/** How a lit picture is finished. */
|
|
4
|
+
export interface FinishSettings {
|
|
5
|
+
/** Multiplies the light before the tone map. */
|
|
6
|
+
readonly exposure: number;
|
|
7
|
+
readonly tonemap: Tonemap;
|
|
8
|
+
/** Ambient occlusion strength, 0 (off) to 1. */
|
|
9
|
+
readonly ao: number;
|
|
10
|
+
/** How far round a point AO looks for what shades it, metres. */
|
|
11
|
+
readonly aoRadius: number;
|
|
12
|
+
/** Aerial haze: how much air there is per metre (0 none), and where it starts, metres from the eye. */
|
|
13
|
+
readonly hazeDensity: number;
|
|
14
|
+
readonly hazeStart: number;
|
|
15
|
+
/** How bright the air glows toward the sun, 0 to 2. */
|
|
16
|
+
readonly hazeGlow: number;
|
|
17
|
+
/** After the tone map: saturation 0 to 2, contrast 0.5 to 2. */
|
|
18
|
+
readonly saturation: number;
|
|
19
|
+
readonly contrast: number;
|
|
20
|
+
/** Lights lean warm and shadows cool, 0 to 1. */
|
|
21
|
+
readonly warmth: number;
|
|
22
|
+
/** Darkens the corners, 0 to 1. */
|
|
23
|
+
readonly vignette: number;
|
|
24
|
+
/** How much sunlight comes through leaves and blades, 0 to 2 (in their own shadow, none). */
|
|
25
|
+
readonly translucency: number;
|
|
26
|
+
/** Patches of drier and damper colour across every surface, 0 to 1. */
|
|
27
|
+
readonly variation: number;
|
|
28
|
+
/** Takes the saturation out of the stage's own colours before they are lit, 0 to 1 (a pixel palette is loud). */
|
|
29
|
+
readonly mute: number;
|
|
30
|
+
/** Glow round the brightest light, 0 to 1, from light brighter than `bloomThreshold` (after exposure). */
|
|
31
|
+
readonly bloom: number;
|
|
32
|
+
readonly bloomThreshold: number;
|
|
33
|
+
/** Temporal antialiasing: each frame jittered and blended with the last, reprojected; `taaBlend` is the new share. */
|
|
34
|
+
readonly taa: boolean;
|
|
35
|
+
readonly taaBlend: number;
|
|
36
|
+
}
|
|
37
|
+
export declare const DEFAULT_FINISH_SETTINGS: FinishSettings;
|
|
38
|
+
/**
|
|
39
|
+
* Normalizes untrusted settings into a complete finish. Anything missing or malformed falls back to the defaults;
|
|
40
|
+
* anything out of range is held to it.
|
|
41
|
+
*
|
|
42
|
+
* @param input Plain settings object, or undefined.
|
|
43
|
+
*/
|
|
44
|
+
export declare function finishSettings(input?: unknown): FinishSettings;
|
|
45
|
+
export declare const AO_SAMPLES = 16;
|
|
46
|
+
/**
|
|
47
|
+
* The AO kernel: points in the unit hemisphere round +z, cosine-weighted on a golden-angle spiral and gathered
|
|
48
|
+
* toward the centre, so near occluders count most. The same every run.
|
|
49
|
+
*
|
|
50
|
+
* @param count How many points.
|
|
51
|
+
* @returns x, y, z for each, flat.
|
|
52
|
+
*/
|
|
53
|
+
export declare function aoKernel(count?: number): number[];
|
|
54
|
+
/**
|
|
55
|
+
* A world direction in the camera's space: the rotation of its view matrix (column-major, as keel/lit keeps it).
|
|
56
|
+
*
|
|
57
|
+
* @param direction World direction (need not be unit length).
|
|
58
|
+
* @param view The camera's matrixWorldInverse elements.
|
|
59
|
+
* @returns The unit direction in view space, or straight ahead for a zero direction.
|
|
60
|
+
*/
|
|
61
|
+
export declare function directionInView(direction: readonly number[], view: ArrayLike<number>): [number, number, number];
|
|
62
|
+
/**
|
|
63
|
+
* A colour as linear RGB: "#rrggbb" (sRGB) or [r, g, b] already linear.
|
|
64
|
+
*
|
|
65
|
+
* @param value The colour.
|
|
66
|
+
* @param fallback Used when the colour is malformed.
|
|
67
|
+
*/
|
|
68
|
+
export declare function linearColour(value: unknown, fallback: readonly [number, number, number]): [number, number, number];
|
|
69
|
+
/**
|
|
70
|
+
* Two column-major 4x4 matrices multiplied, a then b applied last (a * b, as keel/lit's Matrix4.multiplyMatrices).
|
|
71
|
+
*
|
|
72
|
+
* @param a The left matrix.
|
|
73
|
+
* @param b The right matrix.
|
|
74
|
+
*/
|
|
75
|
+
export declare function multiply4(a: ArrayLike<number>, b: ArrayLike<number>): number[];
|
|
76
|
+
/**
|
|
77
|
+
* This frame's subpixel jitter for TAA: Halton (2, 3) over eight frames, in pixels, -0.5 to 0.5.
|
|
78
|
+
*
|
|
79
|
+
* @param frame The frame number.
|
|
80
|
+
*/
|
|
81
|
+
export declare function jitterAt(frame: number): [number, number];
|
|
82
|
+
/**
|
|
83
|
+
* Whole pixels to move a 4x4 dither by this frame, so over sixteen frames every pixel meets every threshold and a
|
|
84
|
+
* dithered fade averages, under TAA, to its real cover.
|
|
85
|
+
*
|
|
86
|
+
* @param frame The frame number.
|
|
87
|
+
*/
|
|
88
|
+
export declare function ditherShiftAt(frame: number): [number, number];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './lit-finish/index.js'
|