@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,200 @@
|
|
|
1
|
+
{
|
|
2
|
+
"protocol": "keel-module-inputs@1",
|
|
3
|
+
"fields": [
|
|
4
|
+
{
|
|
5
|
+
"key": "tonemap",
|
|
6
|
+
"label": "Tone map",
|
|
7
|
+
"required": false,
|
|
8
|
+
"type": "select",
|
|
9
|
+
"options": [
|
|
10
|
+
{
|
|
11
|
+
"value": "agx",
|
|
12
|
+
"label": "AgX"
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"value": "neutral",
|
|
16
|
+
"label": "PBR Neutral"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"value": "aces",
|
|
20
|
+
"label": "ACES"
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"default": "agx"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"key": "exposure",
|
|
27
|
+
"label": "Exposure",
|
|
28
|
+
"required": false,
|
|
29
|
+
"type": "number",
|
|
30
|
+
"min": 0,
|
|
31
|
+
"max": 16,
|
|
32
|
+
"step": 0.05,
|
|
33
|
+
"control": "slider",
|
|
34
|
+
"default": 1
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
"key": "ao",
|
|
38
|
+
"label": "Ambient occlusion",
|
|
39
|
+
"required": false,
|
|
40
|
+
"type": "number",
|
|
41
|
+
"min": 0,
|
|
42
|
+
"max": 1,
|
|
43
|
+
"step": 0.05,
|
|
44
|
+
"control": "slider",
|
|
45
|
+
"default": 0.8
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"key": "aoRadius",
|
|
49
|
+
"label": "AO radius",
|
|
50
|
+
"required": false,
|
|
51
|
+
"placement": "advanced",
|
|
52
|
+
"type": "number",
|
|
53
|
+
"min": 0.05,
|
|
54
|
+
"max": 8,
|
|
55
|
+
"step": 0.05,
|
|
56
|
+
"unit": "m",
|
|
57
|
+
"default": 1.2
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"key": "hazeDensity",
|
|
61
|
+
"label": "Haze",
|
|
62
|
+
"required": false,
|
|
63
|
+
"help": "Air per metre; 0 draws none.",
|
|
64
|
+
"type": "number",
|
|
65
|
+
"min": 0,
|
|
66
|
+
"max": 0.5,
|
|
67
|
+
"step": 0.001,
|
|
68
|
+
"control": "slider",
|
|
69
|
+
"default": 0.012
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"key": "hazeGlow",
|
|
73
|
+
"label": "Haze glow",
|
|
74
|
+
"required": false,
|
|
75
|
+
"placement": "advanced",
|
|
76
|
+
"type": "number",
|
|
77
|
+
"min": 0,
|
|
78
|
+
"max": 2,
|
|
79
|
+
"step": 0.05,
|
|
80
|
+
"default": 0.9
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"key": "saturation",
|
|
84
|
+
"label": "Saturation",
|
|
85
|
+
"required": false,
|
|
86
|
+
"placement": "advanced",
|
|
87
|
+
"type": "number",
|
|
88
|
+
"min": 0,
|
|
89
|
+
"max": 2,
|
|
90
|
+
"step": 0.01,
|
|
91
|
+
"default": 1.05
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"key": "contrast",
|
|
95
|
+
"label": "Contrast",
|
|
96
|
+
"required": false,
|
|
97
|
+
"placement": "advanced",
|
|
98
|
+
"type": "number",
|
|
99
|
+
"min": 0.5,
|
|
100
|
+
"max": 2,
|
|
101
|
+
"step": 0.01,
|
|
102
|
+
"default": 1.18
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"key": "warmth",
|
|
106
|
+
"label": "Warm lights, cool shadows",
|
|
107
|
+
"required": false,
|
|
108
|
+
"placement": "advanced",
|
|
109
|
+
"type": "number",
|
|
110
|
+
"min": 0,
|
|
111
|
+
"max": 1,
|
|
112
|
+
"step": 0.01,
|
|
113
|
+
"default": 0.25
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
"key": "vignette",
|
|
117
|
+
"label": "Vignette",
|
|
118
|
+
"required": false,
|
|
119
|
+
"placement": "advanced",
|
|
120
|
+
"type": "number",
|
|
121
|
+
"min": 0,
|
|
122
|
+
"max": 1,
|
|
123
|
+
"step": 0.01,
|
|
124
|
+
"default": 0.3
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"key": "translucency",
|
|
128
|
+
"label": "Light through leaves",
|
|
129
|
+
"required": false,
|
|
130
|
+
"type": "number",
|
|
131
|
+
"min": 0,
|
|
132
|
+
"max": 2,
|
|
133
|
+
"step": 0.05,
|
|
134
|
+
"control": "slider",
|
|
135
|
+
"default": 0.8
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"key": "variation",
|
|
139
|
+
"label": "Colour variation",
|
|
140
|
+
"required": false,
|
|
141
|
+
"type": "number",
|
|
142
|
+
"min": 0,
|
|
143
|
+
"max": 1,
|
|
144
|
+
"step": 0.05,
|
|
145
|
+
"control": "slider",
|
|
146
|
+
"default": 0.5
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"key": "mute",
|
|
150
|
+
"label": "Mute colours",
|
|
151
|
+
"required": false,
|
|
152
|
+
"placement": "advanced",
|
|
153
|
+
"type": "number",
|
|
154
|
+
"min": 0,
|
|
155
|
+
"max": 1,
|
|
156
|
+
"step": 0.05,
|
|
157
|
+
"default": 0.2
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"key": "bloom",
|
|
161
|
+
"label": "Bloom",
|
|
162
|
+
"required": false,
|
|
163
|
+
"type": "number",
|
|
164
|
+
"min": 0,
|
|
165
|
+
"max": 1,
|
|
166
|
+
"step": 0.01,
|
|
167
|
+
"control": "slider",
|
|
168
|
+
"default": 0.12
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"key": "bloomThreshold",
|
|
172
|
+
"label": "Bloom threshold",
|
|
173
|
+
"required": false,
|
|
174
|
+
"placement": "advanced",
|
|
175
|
+
"type": "number",
|
|
176
|
+
"min": 0,
|
|
177
|
+
"max": 8,
|
|
178
|
+
"step": 0.05,
|
|
179
|
+
"default": 1
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
"key": "taa",
|
|
183
|
+
"label": "Temporal antialiasing",
|
|
184
|
+
"required": false,
|
|
185
|
+
"type": "boolean",
|
|
186
|
+
"default": true
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"key": "taaBlend",
|
|
190
|
+
"label": "TAA new-frame share",
|
|
191
|
+
"required": false,
|
|
192
|
+
"placement": "advanced",
|
|
193
|
+
"type": "number",
|
|
194
|
+
"min": 0.02,
|
|
195
|
+
"max": 1,
|
|
196
|
+
"step": 0.01,
|
|
197
|
+
"default": 0.1
|
|
198
|
+
}
|
|
199
|
+
]
|
|
200
|
+
}
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
// lit-finish@0.1.0 from keel-modules 53c36d0 (MIT). Generated: don't edit.
|
|
2
|
+
var g=["agx","neutral","aces"],L={exposure:1,tonemap:"agx",ao:.8,aoRadius:1.2,hazeDensity:.012,hazeStart:4,hazeGlow:.9,saturation:1.05,contrast:1.18,warmth:.25,vignette:.3,translucency:.8,variation:.5,mute:.2,bloom:.12,bloomThreshold:1,taa:!0,taaBlend:.1};function c(r,t,e,n){return typeof r=="number"&&Number.isFinite(r)?Math.min(e,Math.max(t,r)):n}function j(r,t,e){return typeof r=="string"&&t.includes(r)?r:e}function x(r){if(r===null||typeof r!="object")return L;let t=r,e=L;return{exposure:c(t.exposure,0,16,e.exposure),tonemap:j(t.tonemap,g,e.tonemap),ao:c(t.ao,0,1,e.ao),aoRadius:c(t.aoRadius,.05,8,e.aoRadius),hazeDensity:c(t.hazeDensity,0,.5,e.hazeDensity),hazeStart:c(t.hazeStart,0,1e4,e.hazeStart),hazeGlow:c(t.hazeGlow,0,2,e.hazeGlow),saturation:c(t.saturation,0,2,e.saturation),contrast:c(t.contrast,.5,2,e.contrast),warmth:c(t.warmth,0,1,e.warmth),vignette:c(t.vignette,0,1,e.vignette),translucency:c(t.translucency,0,2,e.translucency),variation:c(t.variation,0,1,e.variation),mute:c(t.mute,0,1,e.mute),bloom:c(t.bloom,0,1,e.bloom),bloomThreshold:c(t.bloomThreshold,0,8,e.bloomThreshold),taa:typeof t.taa=="boolean"?t.taa:e.taa,taaBlend:c(t.taaBlend,.02,1,e.taaBlend)}}var P=16;function w(r=P){let t=[];for(let e=0;e<r;e+=1){let n=(e+.5)/r,o=Math.sqrt(n),i=e*2.399963229728653,a=(e+1)/r,u=.1+.9*a*a;t.push(Math.cos(i)*o*u,Math.sin(i)*o*u,Math.sqrt(1-n)*u)}return t}function z(r,t){let[e=0,n=0,o=0]=r,i=f=>t[f]??0,a=[i(0)*e+i(4)*n+i(8)*o,i(1)*e+i(5)*n+i(9)*o,i(2)*e+i(6)*n+i(10)*o],u=Math.hypot(a[0],a[1],a[2]);return u>0?[a[0]/u,a[1]/u,a[2]/u]:[0,0,-1]}var O=/^#[0-9a-f]{6}$/iu,S=r=>r<=.04045?r/12.92:((r+.055)/1.055)**2.4;function y(r,t){if(typeof r=="string"&&O.test(r)){let e=Number.parseInt(r.slice(1),16);return[S((e>>16&255)/255),S((e>>8&255)/255),S((e&255)/255)]}if(Array.isArray(r)&&r.length>=3&&r.slice(0,3).every(e=>typeof e=="number"&&Number.isFinite(e))){let[e,n,o]=r;return[Math.max(0,e??0),Math.max(0,n??0),Math.max(0,o??0)]}return[t[0],t[1],t[2]]}function D(r,t){let e=new Array(16).fill(0);for(let n=0;n<4;n+=1)for(let o=0;o<4;o+=1){let i=0;for(let a=0;a<4;a+=1)i+=(r[a*4+o]??0)*(t[n*4+a]??0);e[n*4+o]=i}return e}function N(r,t){let e=1,n=0;for(let o=r;o>0;o=Math.floor(o/t))e/=t,n+=e*(o%t);return n}function T(r){let t=Math.floor(r)%8+1;return[N(t,2)-.5,N(t,3)-.5]}function R(r){let t=Math.floor(r)%16;return[t%4,Math.floor(t/4)]}var k=`
|
|
3
|
+
void main() { gl_Position = vec4(position.xy, 0.0, 1.0); }
|
|
4
|
+
`,C=`
|
|
5
|
+
uniform sampler2D tDepth;
|
|
6
|
+
uniform float uNear;
|
|
7
|
+
uniform float uFar;
|
|
8
|
+
uniform float uOrtho;
|
|
9
|
+
uniform vec2 uProj;
|
|
10
|
+
// Distance in front of the eye for a window depth.
|
|
11
|
+
float viewDepth(float d) {
|
|
12
|
+
if (uOrtho > 0.5) return uNear + d * (uFar - uNear);
|
|
13
|
+
return uNear * uFar / (uFar - (uFar - uNear) * d);
|
|
14
|
+
}
|
|
15
|
+
vec3 viewAt(vec2 uv) {
|
|
16
|
+
float z = viewDepth(texture2D(tDepth, uv).x);
|
|
17
|
+
vec2 ndc = uv * 2.0 - 1.0;
|
|
18
|
+
return uOrtho > 0.5 ? vec3(ndc / uProj, -z) : vec3(ndc * z / uProj, -z);
|
|
19
|
+
}
|
|
20
|
+
float ign(vec2 p) { return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); }
|
|
21
|
+
`,A=`
|
|
22
|
+
precision highp float;
|
|
23
|
+
${C}
|
|
24
|
+
uniform vec2 uTexel;
|
|
25
|
+
uniform vec2 uAoSize;
|
|
26
|
+
uniform float uRadius;
|
|
27
|
+
uniform vec3 uKernel[16];
|
|
28
|
+
// The surface's normal from its neighbours' depths, from the nearer side of each pair so edges stay clean.
|
|
29
|
+
vec3 normalAt(vec2 uv, vec3 p) {
|
|
30
|
+
vec3 r = viewAt(uv + vec2(uTexel.x, 0.0)) - p;
|
|
31
|
+
vec3 l = p - viewAt(uv - vec2(uTexel.x, 0.0));
|
|
32
|
+
vec3 u = viewAt(uv + vec2(0.0, uTexel.y)) - p;
|
|
33
|
+
vec3 d = p - viewAt(uv - vec2(0.0, uTexel.y));
|
|
34
|
+
return normalize(cross(abs(r.z) < abs(l.z) ? r : l, abs(u.z) < abs(d.z) ? u : d));
|
|
35
|
+
}
|
|
36
|
+
void main() {
|
|
37
|
+
vec2 uv = gl_FragCoord.xy / uAoSize;
|
|
38
|
+
if (texture2D(tDepth, uv).x >= 0.99999) { gl_FragColor = vec4(1.0); return; }
|
|
39
|
+
vec3 p = viewAt(uv);
|
|
40
|
+
vec3 n = normalAt(uv, p);
|
|
41
|
+
float a = ign(gl_FragCoord.xy) * 6.2831853;
|
|
42
|
+
vec3 spin = vec3(cos(a), sin(a), 0.0);
|
|
43
|
+
vec3 t = normalize(spin - n * dot(spin, n));
|
|
44
|
+
mat3 tbn = mat3(t, cross(n, t), n);
|
|
45
|
+
float occluded = 0.0;
|
|
46
|
+
for (int i = 0; i < 16; i++) {
|
|
47
|
+
vec3 s = p + tbn * uKernel[i] * uRadius;
|
|
48
|
+
vec2 ndc = uOrtho > 0.5 ? s.xy * uProj : s.xy * uProj / -s.z;
|
|
49
|
+
vec2 at = ndc * 0.5 + 0.5;
|
|
50
|
+
if (at.x < 0.0 || at.y < 0.0 || at.x > 1.0 || at.y > 1.0) continue;
|
|
51
|
+
float surface = -viewDepth(texture2D(tDepth, at).x);
|
|
52
|
+
float near = smoothstep(0.0, 1.0, uRadius / max(abs(p.z - surface), 1e-4));
|
|
53
|
+
occluded += step(s.z + 0.03 * uRadius, surface) * near;
|
|
54
|
+
}
|
|
55
|
+
// (Squared: the open share of the hemisphere, as the eye reads contact shade.)
|
|
56
|
+
float open = 1.0 - occluded / 16.0;
|
|
57
|
+
gl_FragColor = vec4(vec3(open * open), 1.0);
|
|
58
|
+
}
|
|
59
|
+
`,U=`
|
|
60
|
+
// AgX (Troy Sobotka's, in Benjamin Wrensch's fit), back to linear display light.
|
|
61
|
+
vec3 agx(vec3 c) {
|
|
62
|
+
const mat3 into = mat3(0.842479062253094, 0.0423282422610123, 0.0423756549057051, 0.0784335999999992, 0.878468636469772, 0.0784336, 0.0792237451477643, 0.0791661274605434, 0.879142973793104);
|
|
63
|
+
const mat3 back = mat3(1.19687900512017, -0.0528968517574562, -0.0529716355144438, -0.0980208811401368, 1.15190312990417, -0.0980434501171241, -0.0990297440797205, -0.0989611768448433, 1.15107367264116);
|
|
64
|
+
vec3 x = clamp(log2(max(into * c, vec3(1e-10))), -12.47393, 4.026069);
|
|
65
|
+
x = (x + 12.47393) / 16.499999;
|
|
66
|
+
vec3 x2 = x * x;
|
|
67
|
+
vec3 x4 = x2 * x2;
|
|
68
|
+
x = 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + 0.4298 * x2 + 0.1191 * x - 0.00232;
|
|
69
|
+
return pow(max(back * x, vec3(0.0)), vec3(2.2));
|
|
70
|
+
}
|
|
71
|
+
// Khronos PBR Neutral.
|
|
72
|
+
vec3 neutral(vec3 c) {
|
|
73
|
+
float x = min(c.r, min(c.g, c.b));
|
|
74
|
+
c -= x < 0.08 ? x - 6.25 * x * x : 0.04;
|
|
75
|
+
float peak = max(c.r, max(c.g, c.b));
|
|
76
|
+
if (peak < 0.76) return c;
|
|
77
|
+
float top = 1.0 - 0.0576 / (peak - 0.52);
|
|
78
|
+
c *= top / peak;
|
|
79
|
+
return mix(c, vec3(top), 1.0 - 1.0 / (0.15 * (peak - top) + 1.0));
|
|
80
|
+
}
|
|
81
|
+
// ACES, Narkowicz's fit.
|
|
82
|
+
vec3 aces(vec3 c) {
|
|
83
|
+
c *= 0.6;
|
|
84
|
+
return clamp(c * (2.51 * c + 0.03) / (c * (2.43 * c + 0.59) + 0.14), 0.0, 1.0);
|
|
85
|
+
}
|
|
86
|
+
vec3 srgb(vec3 c) {
|
|
87
|
+
return mix(c * 12.92, 1.055 * pow(c, vec3(1.0 / 2.4)) - 0.055, step(0.0031308, c));
|
|
88
|
+
}
|
|
89
|
+
`,F=`
|
|
90
|
+
precision highp float;
|
|
91
|
+
${C}
|
|
92
|
+
uniform sampler2D tColor;
|
|
93
|
+
uniform sampler2D tAo;
|
|
94
|
+
uniform vec2 uSize;
|
|
95
|
+
uniform vec2 uAoSize;
|
|
96
|
+
uniform float uAo;
|
|
97
|
+
uniform float uExposure;
|
|
98
|
+
uniform vec3 uHaze;
|
|
99
|
+
uniform float uHazeDensity;
|
|
100
|
+
uniform float uHazeStart;
|
|
101
|
+
uniform float uHazeGlow;
|
|
102
|
+
uniform vec3 uSunDir;
|
|
103
|
+
uniform vec3 uSunColour;
|
|
104
|
+
uniform float uView;
|
|
105
|
+
// The half-size AO, blurred over 4x4 of its texels among those at the same depth, so its noise is gone and
|
|
106
|
+
// nothing bleeds across a silhouette.
|
|
107
|
+
float aoAt(vec2 uv, float z) {
|
|
108
|
+
float sum = 0.0;
|
|
109
|
+
float weight = 0.0;
|
|
110
|
+
for (int y = 0; y < 4; y++) {
|
|
111
|
+
for (int x = 0; x < 4; x++) {
|
|
112
|
+
vec2 at = uv + (vec2(float(x), float(y)) - 1.5) / uAoSize;
|
|
113
|
+
float w = exp(-abs(viewDepth(texture2D(tDepth, at).x) - z) / (0.05 * z + 0.02));
|
|
114
|
+
sum += texture2D(tAo, at).r * w;
|
|
115
|
+
weight += w;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return weight > 0.0 ? sum / weight : 1.0;
|
|
119
|
+
}
|
|
120
|
+
void main() {
|
|
121
|
+
vec2 uv = gl_FragCoord.xy / uSize;
|
|
122
|
+
vec3 c = texture2D(tColor, uv).rgb;
|
|
123
|
+
bool sky = texture2D(tDepth, uv).x >= 0.99999;
|
|
124
|
+
vec3 p = viewAt(uv);
|
|
125
|
+
float occlusion = sky ? 1.0 : aoAt(uv, -p.z);
|
|
126
|
+
if (uView > 0.5) { gl_FragColor = vec4(vec3(occlusion), 1.0); return; }
|
|
127
|
+
c *= mix(1.0, occlusion, uAo);
|
|
128
|
+
// Aerial haze: the air between the eye and the point, lit brighter toward the sun (Henyey-Greenstein, g 0.6,
|
|
129
|
+
// 4pi-normalized: 10 toward the sun).
|
|
130
|
+
float dist = sky ? 1e5 : length(p);
|
|
131
|
+
float through = exp(-max(dist - uHazeStart, 0.0) * uHazeDensity);
|
|
132
|
+
float mu = dot(normalize(p), uSunDir);
|
|
133
|
+
float lobe = 0.64 / pow(1.36 - 1.2 * mu, 1.5);
|
|
134
|
+
vec3 air = uHaze * (1.0 + uSunColour * uHazeGlow * lobe * 0.15);
|
|
135
|
+
c = mix(air, c, uHazeDensity > 0.0 ? through : 1.0);
|
|
136
|
+
gl_FragColor = vec4(c * uExposure, 1.0);
|
|
137
|
+
}
|
|
138
|
+
`,_=`
|
|
139
|
+
precision highp float;
|
|
140
|
+
${C}
|
|
141
|
+
uniform sampler2D tCurrent;
|
|
142
|
+
uniform sampler2D tHistory;
|
|
143
|
+
uniform vec2 uSize;
|
|
144
|
+
uniform mat4 uInvView;
|
|
145
|
+
uniform mat4 uPrevViewProj;
|
|
146
|
+
uniform float uBlend;
|
|
147
|
+
uniform float uReset;
|
|
148
|
+
// Weighted by 1/(1+luma), so one bright pixel does not ring over its neighbours.
|
|
149
|
+
vec3 tame(vec3 c) { return c / (1.0 + dot(c, vec3(0.2126, 0.7152, 0.0722))); }
|
|
150
|
+
vec3 untame(vec3 c) { return c / max(1.0 - dot(c, vec3(0.2126, 0.7152, 0.0722)), 1e-4); }
|
|
151
|
+
void main() {
|
|
152
|
+
vec2 uv = gl_FragCoord.xy / uSize;
|
|
153
|
+
vec3 current = tame(texture2D(tCurrent, uv).rgb);
|
|
154
|
+
vec3 low = current;
|
|
155
|
+
vec3 high = current;
|
|
156
|
+
for (int y = -1; y <= 1; y++) {
|
|
157
|
+
for (int x = -1; x <= 1; x++) {
|
|
158
|
+
vec3 n = tame(texture2D(tCurrent, uv + vec2(float(x), float(y)) / uSize).rgb);
|
|
159
|
+
low = min(low, n);
|
|
160
|
+
high = max(high, n);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
vec4 before = uPrevViewProj * (uInvView * vec4(viewAt(uv), 1.0));
|
|
164
|
+
vec2 then = before.xy / before.w * 0.5 + 0.5;
|
|
165
|
+
bool lost = uReset > 0.5 || then.x < 0.0 || then.y < 0.0 || then.x > 1.0 || then.y > 1.0;
|
|
166
|
+
vec3 history = clamp(tame(texture2D(tHistory, then).rgb), low, high);
|
|
167
|
+
gl_FragColor = vec4(untame(lost ? current : mix(history, current, uBlend)), 1.0);
|
|
168
|
+
}
|
|
169
|
+
`,M=`
|
|
170
|
+
precision highp float;
|
|
171
|
+
uniform sampler2D tResolved;
|
|
172
|
+
uniform vec2 uBloomSize;
|
|
173
|
+
uniform vec2 uSize;
|
|
174
|
+
uniform float uThreshold;
|
|
175
|
+
void main() {
|
|
176
|
+
vec2 uv = gl_FragCoord.xy / uBloomSize;
|
|
177
|
+
vec2 t = 1.0 / uSize;
|
|
178
|
+
vec3 c = 0.25 * (texture2D(tResolved, uv + vec2(-t.x, -t.y)).rgb + texture2D(tResolved, uv + vec2(t.x, -t.y)).rgb
|
|
179
|
+
+ texture2D(tResolved, uv + vec2(-t.x, t.y)).rgb + texture2D(tResolved, uv + vec2(t.x, t.y)).rgb);
|
|
180
|
+
float l = dot(c, vec3(0.2126, 0.7152, 0.0722));
|
|
181
|
+
gl_FragColor = vec4(c * max(l - uThreshold, 0.0) / max(l, 1e-4), 1.0);
|
|
182
|
+
}
|
|
183
|
+
`,H=`
|
|
184
|
+
precision highp float;
|
|
185
|
+
uniform sampler2D tBlur;
|
|
186
|
+
uniform vec2 uBloomSize;
|
|
187
|
+
uniform vec2 uDir;
|
|
188
|
+
void main() {
|
|
189
|
+
vec2 uv = gl_FragCoord.xy / uBloomSize;
|
|
190
|
+
vec2 d = uDir / uBloomSize;
|
|
191
|
+
vec3 c = texture2D(tBlur, uv).rgb * 0.2270270270;
|
|
192
|
+
c += (texture2D(tBlur, uv + d * 1.3846153846).rgb + texture2D(tBlur, uv - d * 1.3846153846).rgb) * 0.3162162162;
|
|
193
|
+
c += (texture2D(tBlur, uv + d * 3.2307692308).rgb + texture2D(tBlur, uv - d * 3.2307692308).rgb) * 0.0702702703;
|
|
194
|
+
gl_FragColor = vec4(c, 1.0);
|
|
195
|
+
}
|
|
196
|
+
`,B=`
|
|
197
|
+
precision highp float;
|
|
198
|
+
${U}
|
|
199
|
+
uniform sampler2D tResolved;
|
|
200
|
+
uniform sampler2D tBloom;
|
|
201
|
+
uniform vec2 uSize;
|
|
202
|
+
uniform float uBloom;
|
|
203
|
+
uniform float uTone;
|
|
204
|
+
uniform float uSaturation;
|
|
205
|
+
uniform float uContrast;
|
|
206
|
+
uniform float uWarmth;
|
|
207
|
+
uniform float uVignette;
|
|
208
|
+
uniform float uView;
|
|
209
|
+
float ign(vec2 p) { return fract(52.9829189 * fract(dot(p, vec2(0.06711056, 0.00583715)))); }
|
|
210
|
+
void main() {
|
|
211
|
+
vec2 uv = gl_FragCoord.xy / uSize;
|
|
212
|
+
vec3 c = texture2D(tResolved, uv).rgb;
|
|
213
|
+
if (uView > 0.5) { gl_FragColor = vec4(srgb(clamp(c, 0.0, 1.0)), 1.0); return; }
|
|
214
|
+
c += texture2D(tBloom, uv).rgb * uBloom;
|
|
215
|
+
vec3 m = uTone < 0.5 ? agx(c) : (uTone < 1.5 ? neutral(c) : aces(c));
|
|
216
|
+
float l = dot(m, vec3(0.2126, 0.7152, 0.0722));
|
|
217
|
+
m = max(mix(vec3(l), m, uSaturation), 0.0);
|
|
218
|
+
m = mix(m, m * vec3(0.92, 0.98, 1.1), uWarmth * (1.0 - clamp(l * 2.0, 0.0, 1.0)));
|
|
219
|
+
m = mix(m, m * vec3(1.08, 1.0, 0.88), uWarmth * clamp(l * 1.5 - 0.3, 0.0, 1.0));
|
|
220
|
+
vec3 s = srgb(clamp(m, 0.0, 1.0));
|
|
221
|
+
s = clamp((s - 0.5) * uContrast + 0.5, 0.0, 1.0);
|
|
222
|
+
vec2 q = uv - 0.5;
|
|
223
|
+
s *= 1.0 - uVignette * dot(q, q) * 1.6;
|
|
224
|
+
gl_FragColor = vec4(s + (ign(gl_FragCoord.xy) - 0.5) / 255.0, 1.0);
|
|
225
|
+
}
|
|
226
|
+
`;var I=`varying vec3 vFinishWorld;
|
|
227
|
+
`,W=`#include <project_vertex>
|
|
228
|
+
#ifdef USE_INSTANCING
|
|
229
|
+
vFinishWorld = (modelMatrix * instanceMatrix * vec4(transformed, 1.0)).xyz;
|
|
230
|
+
#else
|
|
231
|
+
vFinishWorld = (modelMatrix * vec4(transformed, 1.0)).xyz;
|
|
232
|
+
#endif`,q=`varying vec3 vFinishWorld;
|
|
233
|
+
uniform float uFinishTranslucency;
|
|
234
|
+
uniform float uFinishVariation;
|
|
235
|
+
uniform float uFinishMute;
|
|
236
|
+
float finishHash(vec3 p) { return fract(sin(dot(p, vec3(127.1, 311.7, 74.7))) * 43758.5453); }
|
|
237
|
+
float finishNoise(vec3 p) {
|
|
238
|
+
vec3 i = floor(p);
|
|
239
|
+
vec3 f = fract(p);
|
|
240
|
+
f = f * f * (3.0 - 2.0 * f);
|
|
241
|
+
float a = mix(mix(finishHash(i), finishHash(i + vec3(1, 0, 0)), f.x), mix(finishHash(i + vec3(0, 1, 0)), finishHash(i + vec3(1, 1, 0)), f.x), f.y);
|
|
242
|
+
float b = mix(mix(finishHash(i + vec3(0, 0, 1)), finishHash(i + vec3(1, 0, 1)), f.x), mix(finishHash(i + vec3(0, 1, 1)), finishHash(i + vec3(1, 1, 1)), f.x), f.y);
|
|
243
|
+
return mix(a, b, f.z);
|
|
244
|
+
}
|
|
245
|
+
`,K=`#include <color_fragment>
|
|
246
|
+
{
|
|
247
|
+
vec3 finishC = diffuseColor.rgb;
|
|
248
|
+
finishC = mix(finishC, vec3(dot(finishC, vec3(0.2126, 0.7152, 0.0722))), uFinishMute);
|
|
249
|
+
float finishBig = finishNoise(vFinishWorld * 0.12);
|
|
250
|
+
finishC *= mix(1.0, 0.72 + 0.56 * finishNoise(vFinishWorld * 1.3 + 7.3), uFinishVariation);
|
|
251
|
+
finishC = mix(finishC, finishC * vec3(1.14, 1.06, 0.74), uFinishVariation * smoothstep(0.5, 0.85, finishBig));
|
|
252
|
+
finishC = mix(finishC, finishC * vec3(0.84, 0.96, 1.06), uFinishVariation * smoothstep(0.5, 0.15, finishBig));
|
|
253
|
+
diffuseColor.rgb = finishC;
|
|
254
|
+
}`,X=`#if NUM_DIR_LIGHTS > 0
|
|
255
|
+
{
|
|
256
|
+
vec3 finishL = directionalLights[0].direction;
|
|
257
|
+
vec3 finishSun = directionalLights[0].color;
|
|
258
|
+
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
|
|
259
|
+
DirectionalLightShadow finishShadow = directionalLightShadows[0];
|
|
260
|
+
finishSun *= receiveShadow ? getShadow(directionalShadowMap[0], finishShadow.shadowMapSize, finishShadow.shadowIntensity, finishShadow.shadowBias, finishShadow.shadowRadius, vDirectionalShadowCoord[0]) : 1.0;
|
|
261
|
+
#endif
|
|
262
|
+
float finishBack = pow(max(dot(-normalize(vViewPosition), finishL), 0.0), 4.0);
|
|
263
|
+
float finishWrap = max(dot(-normal, finishL), 0.0);
|
|
264
|
+
outgoingLight += diffuseColor.rgb * vec3(1.05, 1.1, 0.6) * finishSun * uFinishTranslucency * (0.35 * finishWrap + finishBack) * 0.5;
|
|
265
|
+
}
|
|
266
|
+
#endif
|
|
267
|
+
#include <opaque_fragment>`;function $(r){return r.side==="both"||r.side===2||(r.alphaTest??0)>0}function J(r,t,e){let n=r.vertexShader,o=r.fragmentShader;if(!n.includes("#include <project_vertex>")||!o.includes("#include <color_fragment>"))return;Object.assign(r.uniforms,t),r.vertexShader=I+n.replace("#include <project_vertex>",W);let i=q+o.replace("#include <color_fragment>",K);e&&i.includes("#include <lights_fragment_begin>")&&(i=i.replace("#include <opaque_fragment>",X)),r.fragmentShader=i}function E(r,t){if(r.userData.litFinishDressed===!0)return;let e=r.onCompile,n=r.customProgramCacheKey,o=$(r);r.onCompile=(a,u)=>{e?.call(r,a,u),J(a,t,o)};let i=n?n.call(r):String(e??"");r.customProgramCacheKey=()=>`${i}|lit-finish${o?"-leaf":""}`,r.userData.litFinishDressed=!0,r.needsUpdate=!0}function b(r,t){r.traverse(e=>{if(e.isMesh!==!0||e.material===void 0)return;let n=Array.isArray(e.material)?e.material:[e.material];for(let o of n)E(o,t)})}var Q={ao:A,light:F,taa:_,bright:M,blur:H,grade:B};function Y(r,t,e,n){let o=new r.CustomMaterial({uniforms:e,vertexShader:k,fragmentShader:n,depthTest:!1,depthWrite:!1}),i=new r.Mesh(t,o);i.frustumCulled=!1;let a=new r.Stage;return a.add(i),{scene:a,material:o}}function Z(){let r=(o=1,i=1)=>({value:[o,i]}),t=(o,i,a)=>({value:[o,i,a]}),e=o=>({value:o}),n=()=>({value:[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]});return{tColor:e(0),tDepth:e(0),tAo:e(0),tCurrent:e(0),tHistory:e(0),tResolved:e(0),tBloom:e(0),tBlur:e(0),uNear:e(.1),uFar:e(100),uOrtho:e(0),uProj:r(),uSize:r(),uAoSize:r(),uBloomSize:r(),uTexel:r(),uRadius:e(.6),uKernel:{value:w()},uAo:e(.8),uExposure:e(1),uTone:e(0),uHaze:t(.6,.7,.85),uHazeDensity:e(0),uHazeStart:e(0),uHazeGlow:e(0),uSunDir:t(0,0,-1),uSunColour:t(1,.95,.85),uInvView:n(),uPrevViewProj:n(),uBlend:e(1),uReset:e(1),uThreshold:e(1),uBloom:e(0),uDir:r(1,0),uSaturation:e(1),uContrast:e(1),uWarmth:e(0),uVignette:e(0),uView:e(0)}}function s(r,t,e){let n=r[t];n!==void 0&&(n.value=e)}function G(r,t,e,n){let o=[["uAo",e.ao],["uRadius",e.aoRadius],["uExposure",e.exposure],["uTone",g.indexOf(e.tonemap)],["uHazeDensity",n.density??e.hazeDensity],["uHazeStart",n.start??e.hazeStart],["uHazeGlow",e.hazeGlow],["uSaturation",e.saturation],["uContrast",e.contrast],["uWarmth",e.warmth],["uVignette",e.vignette],["uBloom",e.bloom],["uThreshold",e.bloomThreshold],["uBlend",e.taa?e.taaBlend:1]];for(let[i,a]of o)s(r,i,a);s(t,"uFinishTranslucency",e.translucency),s(t,"uFinishVariation",e.variation),s(t,"uFinishMute",e.mute)}function ee(r){let t={minFilter:"linear",magFilter:"linear",generateMipmaps:!1},e={...t,type:"half",depthBuffer:!1},n=new r.DepthTexture(1,1),o=i=>new r.RenderTarget(1,1,i);return{world:o({...t,type:"half",samples:4,depthBuffer:!0,depthTexture:n}),ao:o({...t,depthBuffer:!1}),hdr:o(e),history:[o(e),o(e)],bloom:[o(e),o(e)]}}function re(r,t,e,n){let o=[Math.max(1,Math.ceil(e/2)),Math.max(1,Math.ceil(n/2))],i=[Math.max(1,Math.ceil(e/4)),Math.max(1,Math.ceil(n/4))];r.world.setSize(e,n),r.ao.setSize(o[0],o[1]);for(let a of[r.hdr,...r.history])a.setSize(e,n);for(let a of r.bloom)a.setSize(i[0],i[1]);s(t,"uSize",[e,n]),s(t,"uAoSize",[o[0],o[1]]),s(t,"uBloomSize",[i[0],i[1]]),s(t,"uTexel",[1/e,1/n]),s(t,"uReset",1)}function te(r,t,e,n){let o=e.projectionMatrix.elements,[i,a]=e.isOrthographicCamera===!0?[12,13]:[8,9],u=[o[i]??0,o[a]??0];n&&(o[i]=u[0]+n[0],o[a]=u[1]+n[1]),r.render(t,e),o[i]=u[0],o[a]=u[1]}function oe(r,t,e){let n=t.projectionMatrix.elements;return s(r,"uNear",t.near),s(r,"uFar",t.far),s(r,"uOrtho",t.isOrthographicCamera===!0?1:0),s(r,"uProj",[n[0]??1,n[5]??1]),s(r,"uSunDir",z(e,t.matrixWorldInverse.elements)),s(r,"uInvView",Array.from(t.matrixWorld.elements)),D(n,t.matrixWorldInverse.elements)}function h(r,t,e){r.renderer.setRenderTarget(e),r.renderer.render(r.passes[t].scene,r.quad)}function ne(r){let{targets:t,uniforms:e}=r;h(r,"bright",t.bloom[0]),s(e,"tBlur",t.bloom[0].texture),s(e,"uDir",[1,0]),h(r,"blur",t.bloom[1]),s(e,"tBlur",t.bloom[1].texture),s(e,"uDir",[0,1]),h(r,"blur",t.bloom[0])}function ie(r,t,e,n){let{targets:o,uniforms:i}=r;h(r,"ao",o.ao),h(r,"light",o.hdr);let a=o.hdr;if(e.taa){let u=o.history[t.flip];s(i,"tCurrent",o.hdr.texture),s(i,"tHistory",o.history[t.flip===0?1:0].texture),h(r,"taa",u),s(i,"uReset",0),a=u}else s(i,"uReset",1);s(i,"tResolved",a.texture),e.bloom>0&&ne(r),s(i,"tBloom",o.bloom[0].texture),h(r,"grade",n)}function ae(r){let t=r.targets;t.world.depthTexture?.dispose();for(let e of[t.world,t.ao,t.hdr,...t.history,...t.bloom])e.dispose();for(let e of Object.values(r.passes))e.material.dispose();r.geometry.dispose()}function se(r,t,e){let n=ee(r);s(e,"tColor",n.world.texture),s(e,"tDepth",n.world.depthTexture),s(e,"tAo",n.ao.texture);let o=r.plane(2,2),i=Object.fromEntries(Object.entries(Q).map(([a,u])=>[a,Y(r,o,e,u)]));return{renderer:t,passes:i,targets:n,uniforms:e,quad:new r.OrthoCamera(-1,1,1,-1,0,1),geometry:o}}function ue(r,t,e,n){let{renderer:o,uniforms:i}=r,a=o.getRenderTarget(),[u,f]=T(t.index);o.setRenderTarget(r.targets.world);let m=n.taa?[2*u/t.size[0],2*f/t.size[1]]:null;te(o,e.scene,e.camera,m);let l=oe(i,e.camera,e.sun);s(i,"uPrevViewProj",t.previous??l),ie(r,t,n,a),t.previous=l,t.flip=t.flip===0?1:0,t.index+=1}function le(r,t,e){let n=x(e),o={},i=[.4,.8,.3],a=Z(),u={uFinishTranslucency:{value:0},uFinishVariation:{value:0},uFinishMute:{value:0}},f=se(r,t,a),m={index:0,flip:0,previous:null,size:[1,1]};return G(a,u,n,o),{get settings(){return n},setSettings(l){return n=x(l),G(a,u,n,o),n},setSize(l,p,d){let v=V=>Math.max(1,Math.round(V*d));m.size=[v(l),v(p)],re(f.targets,a,m.size[0],m.size[1])},setSun(l,p){i=l;let d=y(p,[1,.95,.85]),v=Math.max(d[0],d[1],d[2],1e-6);s(a,"uSunColour",[d[0]/v,d[1]/v,d[2]/v])},setHaze(l){o=l,l.colour!==void 0&&s(a,"uHaze",y(l.colour,[.6,.7,.85])),G(a,u,n,o)},dress(l){b(l,u)},ditherOffset(){return n.taa?R(m.index):[0,0]},render(l,p){m.index%30===0&&b(l,u),ue(f,m,{scene:l,camera:p,sun:i},n)},setView(l){s(a,"uView",l==="ao"?1:0)},dispose(){ae(f)}}}export{A as AO_GLSL,P as AO_SAMPLES,H as BLUR_GLSL,M as BRIGHT_GLSL,L as DEFAULT_FINISH_SETTINGS,B as GRADE_GLSL,F as LIGHT_GLSL,_ as TAA_GLSL,g as TONEMAPS,k as VERTEX_GLSL,w as aoKernel,le as createLitFinish,z as directionInView,R as ditherShiftAt,E as dressMaterial,b as dressTree,x as finishSettings,T as jitterAt,y as linearColour,D as multiply4};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One look recipe for every keel/lit stage: the dithered pixel look or the lit,
|
|
3
|
+
* full-colour realism look, picked and capped per target. MIT.
|
|
4
|
+
*
|
|
5
|
+
* The recipe is keel-engine core's `keel-look@1`, and `resolveLook` is its twin:
|
|
6
|
+
* both are held to the same shared cases (test/look-cases.json, written by the
|
|
7
|
+
* engine), so a game drawing meshes through keel/bake and a grove drawing a
|
|
8
|
+
* keel/lit stage wear the same recipe the same way.
|
|
9
|
+
*
|
|
10
|
+
* const look = resolveLook(recipe, LOOK_TARGETS.lit);
|
|
11
|
+
* const stage = stageOfLook(look);
|
|
12
|
+
* if (stage.dither) createVoxelDither(lit, renderer, stage.dither); // the pixel look, or realism's grade
|
|
13
|
+
* renderer.toneMapping = stage.toneMapping ?? renderer.toneMapping;
|
|
14
|
+
* createTreeRender(lit, { ...stage.trees, model, frame });
|
|
15
|
+
* createForest(lit, { variants, places, maxLeaves: 1600 * stage.density });
|
|
16
|
+
* createPlantField({ detail: detail * stage.density, ... });
|
|
17
|
+
*
|
|
18
|
+
* The pixel look is voxel-dither's own settings (a style id and overrides, by
|
|
19
|
+
* its names), so `stage.dither` goes straight to it, with the target's `limit`
|
|
20
|
+
* beside them for voxel-dither to cap the style's levels and palette.
|
|
21
|
+
*
|
|
22
|
+
* Pure: no renderer, no globals.
|
|
23
|
+
*/
|
|
24
|
+
export declare const LOOK_RECIPE_FORMAT = "keel-look@1";
|
|
25
|
+
/** voxel-dither's screens, by its ids. */
|
|
26
|
+
export declare const LOOK_SCREENS: readonly ["auto", "bayer2", "bayer4", "bayer8", "halftone", "lines", "diagonal", "hatch", "ign", "stipple", "checker", "none"];
|
|
27
|
+
export type LookScreen = (typeof LOOK_SCREENS)[number];
|
|
28
|
+
/** The dithered look: a voxel-dither style and overrides, in its own names and ranges. */
|
|
29
|
+
export interface PixelLook {
|
|
30
|
+
readonly style?: string;
|
|
31
|
+
readonly screen?: LookScreen;
|
|
32
|
+
readonly pixel?: number;
|
|
33
|
+
readonly levels?: number;
|
|
34
|
+
/** A small target keeps the first entries, so list them most needed first. */
|
|
35
|
+
readonly palette?: readonly string[];
|
|
36
|
+
readonly amount?: number;
|
|
37
|
+
readonly shading?: "smooth" | "cel";
|
|
38
|
+
readonly bands?: number;
|
|
39
|
+
readonly outline?: number;
|
|
40
|
+
readonly crease?: number;
|
|
41
|
+
readonly contrast?: number;
|
|
42
|
+
readonly saturation?: number;
|
|
43
|
+
}
|
|
44
|
+
/** The lit, full-colour look. */
|
|
45
|
+
export interface RealismLook {
|
|
46
|
+
readonly exposure?: number;
|
|
47
|
+
readonly tonemap?: "neutral" | "agx" | "aces";
|
|
48
|
+
/** Ambient occlusion strength, 0 to 1. */
|
|
49
|
+
readonly ao?: number;
|
|
50
|
+
/** How much denser than the pixel look generators build, 1 to 4. */
|
|
51
|
+
readonly density?: number;
|
|
52
|
+
/** A pixel grade over the lit picture, or none. */
|
|
53
|
+
readonly grade?: PixelLook | null;
|
|
54
|
+
}
|
|
55
|
+
export interface LookRecipe {
|
|
56
|
+
readonly format: typeof LOOK_RECIPE_FORMAT;
|
|
57
|
+
readonly pixel?: PixelLook;
|
|
58
|
+
readonly realism?: RealismLook;
|
|
59
|
+
readonly prefer?: "pixel" | "realism";
|
|
60
|
+
}
|
|
61
|
+
/** What a target can draw: whether it lights, its most colours (0: no limit) and its largest screen (0: any). */
|
|
62
|
+
export interface LookTarget {
|
|
63
|
+
readonly lit: boolean;
|
|
64
|
+
readonly paletteLimit: number;
|
|
65
|
+
readonly screen: 0 | 2 | 4 | 8;
|
|
66
|
+
}
|
|
67
|
+
/** keel-engine core's targets, as lookTarget gives them (`lit` is native on a GPU that can light). */
|
|
68
|
+
export declare const LOOK_TARGETS: Readonly<Record<"lit" | "native" | "16-bit" | "8-bit" | "game-boy", LookTarget>>;
|
|
69
|
+
export interface ResolvedRealism {
|
|
70
|
+
readonly exposure: number;
|
|
71
|
+
readonly tonemap: "neutral" | "agx" | "aces";
|
|
72
|
+
readonly ao: number;
|
|
73
|
+
readonly density: number;
|
|
74
|
+
readonly grade: PixelLook | null;
|
|
75
|
+
}
|
|
76
|
+
export type ResolvedLook = {
|
|
77
|
+
readonly kind: "pixel";
|
|
78
|
+
readonly pixel: PixelLook;
|
|
79
|
+
readonly limit: {
|
|
80
|
+
readonly levels: number;
|
|
81
|
+
readonly colours: number;
|
|
82
|
+
};
|
|
83
|
+
} | {
|
|
84
|
+
readonly kind: "realism";
|
|
85
|
+
readonly realism: ResolvedRealism;
|
|
86
|
+
};
|
|
87
|
+
export declare const REALISM_DEFAULTS: {
|
|
88
|
+
readonly exposure: 1;
|
|
89
|
+
readonly tonemap: "neutral";
|
|
90
|
+
readonly ao: 0.7;
|
|
91
|
+
readonly density: 2;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Throws on anything that isn't a keel-look@1 recipe.
|
|
95
|
+
*
|
|
96
|
+
* @param recipe Untrusted input.
|
|
97
|
+
* @returns The same recipe.
|
|
98
|
+
*/
|
|
99
|
+
export declare function checkLookRecipe(recipe: unknown): LookRecipe;
|
|
100
|
+
/**
|
|
101
|
+
* The most tone steps per channel a target holds: levels cubed colours at most, under its palette limit.
|
|
102
|
+
*
|
|
103
|
+
* @param t The target.
|
|
104
|
+
* @returns Tone steps, or 0 for no limit.
|
|
105
|
+
*/
|
|
106
|
+
export declare function maxLevels(t: LookTarget): number;
|
|
107
|
+
/**
|
|
108
|
+
* The look a target draws from a recipe: realism where the target lights and the recipe prefers it (or has nothing
|
|
109
|
+
* else), otherwise the pixel look narrowed to the target.
|
|
110
|
+
*
|
|
111
|
+
* @param recipe A keel-look@1 recipe.
|
|
112
|
+
* @param target What the target can draw.
|
|
113
|
+
* @returns The look, with every realism field settled, or the pixel look and the target's limits.
|
|
114
|
+
*/
|
|
115
|
+
export declare function resolveLook(recipe: LookRecipe, target: LookTarget): ResolvedLook;
|
|
116
|
+
/**
|
|
117
|
+
* tree-render's options for one tree (`createTreeRender`): realism draws real blades and bark, without the looks made
|
|
118
|
+
* for a few pixels per leaf. The pixel look leaves the host's own.
|
|
119
|
+
*/
|
|
120
|
+
export interface TreeLook {
|
|
121
|
+
readonly form?: "smooth";
|
|
122
|
+
readonly features?: {
|
|
123
|
+
readonly sprays: false;
|
|
124
|
+
readonly clumps: false;
|
|
125
|
+
readonly rootSink: false;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
/** How a keel/lit stage draws a resolved look. */
|
|
129
|
+
export interface LitStageLook {
|
|
130
|
+
readonly kind: "pixel" | "realism";
|
|
131
|
+
/** voxel-dither's input (the pixel look, or realism's grade), or null to draw the lit picture straight. */
|
|
132
|
+
readonly dither: (PixelLook & {
|
|
133
|
+
readonly limit?: {
|
|
134
|
+
readonly levels: number;
|
|
135
|
+
readonly colours: number;
|
|
136
|
+
};
|
|
137
|
+
}) | null;
|
|
138
|
+
/** keel/lit's tone mapping for a host without lit-finish, or null to keep the host's. */
|
|
139
|
+
readonly toneMapping: "neutral" | "agx" | "aces-filmic" | null;
|
|
140
|
+
readonly exposure: number;
|
|
141
|
+
/** Ambient occlusion strength for a post that draws it (0 off). */
|
|
142
|
+
readonly ao: number;
|
|
143
|
+
/** Multiplies the generators' detail (plant fields, a forest's baked leaves, ground cover). */
|
|
144
|
+
readonly density: number;
|
|
145
|
+
readonly trees: TreeLook;
|
|
146
|
+
/** lit-finish's input (`createLitFinish`: AO, haze, tone map, grade), or null for the pixel look. */
|
|
147
|
+
readonly finish: {
|
|
148
|
+
readonly exposure: number;
|
|
149
|
+
readonly tonemap: ResolvedRealism["tonemap"];
|
|
150
|
+
readonly ao: number;
|
|
151
|
+
} | null;
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* What a keel/lit stage sets for a resolved look.
|
|
155
|
+
*
|
|
156
|
+
* @param look From resolveLook.
|
|
157
|
+
* @returns The dither input, tone mapping, exposure, AO, density, tree switches and lit-finish's input.
|
|
158
|
+
*/
|
|
159
|
+
export declare function stageOfLook(look: ResolvedLook): LitStageLook;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './look/index.js'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"protocol": "keel-module-inputs@1",
|
|
3
|
+
"fields": [
|
|
4
|
+
{
|
|
5
|
+
"key": "prefer",
|
|
6
|
+
"label": "Look",
|
|
7
|
+
"required": false,
|
|
8
|
+
"help": "Where a target can draw both. A small or retro target always draws the pixel look.",
|
|
9
|
+
"type": "select",
|
|
10
|
+
"options": [
|
|
11
|
+
{
|
|
12
|
+
"value": "pixel",
|
|
13
|
+
"label": "Pixel art"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"value": "realism",
|
|
17
|
+
"label": "Realism"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
"default": "pixel"
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// look@0.1.0 from keel-modules 53c36d0 (MIT). Generated: don't edit.
|
|
2
|
+
var e="keel-look@1",t=["auto","bayer2","bayer4","bayer8","halftone","lines","diagonal","hatch","ign","stipple","checker","none"],r={lit:{lit:!0,paletteLimit:0,screen:0},native:{lit:!1,paletteLimit:0,screen:0},"16-bit":{lit:!1,paletteLimit:256,screen:4},"8-bit":{lit:!1,paletteLimit:16,screen:2},"game-boy":{lit:!1,paletteLimit:4,screen:2}},i={exposure:1,tonemap:"neutral",ao:.7,density:2},o=new Set(["style","screen","pixel","levels","palette","amount","shading","bands","outline","crease","contrast","saturation"]),a=new Set(["exposure","tonemap","ao","density","grade"]),l=new Set(["format","pixel","realism","prefer"]),n=/^#[0-9a-f]{6}$/iu,s={bayer2:2,bayer4:4,bayer8:8},p={2:"bayer2",4:"bayer4",8:"bayer8"};function m(e,t,r,i){if(void 0!==t&&("number"!=typeof t||!Number.isFinite(t)||t<r||t>i))throw new RangeError(`${e} must be a number in ${String(r)}..${String(i)}`)}function u(e,t,r){for(let i of Object.keys(t))if(!r.has(i))throw new TypeError(`${e}.${i} is not a look field`)}function c(e,r){if(u(e,r,o),void 0!==r.style&&"string"!=typeof r.style)throw new TypeError(`${e}.style must be a style id`);if(void 0!==r.screen&&!t.includes(r.screen))throw new RangeError(`${e}.screen is not a screen`);if(void 0!==r.shading&&"smooth"!==r.shading&&"cel"!==r.shading)throw new RangeError(`${e}.shading must be smooth or cel`);if(void 0!==r.palette&&!function(e){return Array.isArray(e)&&e.length<=32&&e.every(e=>"string"==typeof e&&n.test(e))}(r.palette))throw new RangeError(`${e}.palette must be up to 32 #rrggbb colours`);let i=[["pixel",0,12],["levels",2,16],["amount",0,1],["bands",2,8],["outline",0,1],["crease",0,1],["contrast",.5,2],["saturation",0,2]];for(let[t,o,a]of i)m(`${e}.${t}`,r[t],o,a)}function d(t){if(null===t||"object"!=typeof t||t.format!==e)throw new TypeError(`A look recipe is { format: "${e}", ... }`);let r=t;if(u("look",r,l),void 0!==r.prefer&&"pixel"!==r.prefer&&"realism"!==r.prefer)throw new RangeError("look.prefer must be pixel or realism");void 0!==r.pixel&&c("look.pixel",r.pixel);let i=r.realism;if(void 0!==i){if(u("look.realism",i,a),m("look.realism.exposure",i.exposure,0,16),m("look.realism.ao",i.ao,0,1),m("look.realism.density",i.density,1,4),void 0!==i.tonemap&&!["neutral","agx","aces"].includes(i.tonemap))throw new RangeError("look.realism.tonemap must be neutral, agx or aces");i.grade&&c("look.realism.grade",i.grade)}return t}function f(e){return e.paletteLimit?Math.max(2,Math.floor(Math.cbrt(e.paletteLimit))):0}function y(e,t){let r={...e};if(t.paletteLimit&&(r.palette&&r.palette.length>t.paletteLimit&&(r.palette=r.palette.slice(0,t.paletteLimit)),void 0!==r.levels&&(r.levels=Math.min(r.levels,f(t)))),t.screen){let e=r.screen?s[r.screen]:void 0;(void 0===e||e>t.screen)&&(r={...r,screen:p[t.screen]})}return r}function g(e,t){d(e);let r=e.realism;if(void 0!==r&&("realism"===e.prefer||void 0===e.pixel)&&t.lit)return{kind:"realism",realism:{exposure:r.exposure??i.exposure,tonemap:r.tonemap??i.tonemap,ao:r.ao??i.ao,density:r.density??i.density,grade:r.grade??null}};let o={levels:f(t),colours:t.paletteLimit};return{kind:"pixel",pixel:y(e.pixel??{},t),limit:o}}var x={neutral:"neutral",agx:"agx",aces:"aces-filmic"};function h(e){if("pixel"===e.kind)return{kind:"pixel",dither:e.limit.levels||e.limit.colours?{...e.pixel,limit:e.limit}:e.pixel,toneMapping:null,exposure:1,ao:0,density:1,trees:{},finish:null};let t=e.realism;return{kind:"realism",dither:t.grade,toneMapping:x[t.tonemap],exposure:t.exposure,ao:t.ao,density:t.density,trees:{form:"smooth",features:{sprays:!1,clumps:!1,rootSink:!1}},finish:{exposure:t.exposure,tonemap:t.tonemap,ao:t.ao}}}export{e as LOOK_RECIPE_FORMAT,t as LOOK_SCREENS,r as LOOK_TARGETS,i as REALISM_DEFAULTS,d as checkLookRecipe,f as maxLevels,g as resolveLook,h as stageOfLook};
|