Agent Harness · VibeGit
Agent Harness Публичная копия обвязки агентной разработки: гейты, journeys, скиллы и шаблоны. Без ключей и личных данных.
agent-harness / tools / water-assets / uw / engine / PostFX.js 422 строк · изменён 6 нояб., 03:45
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
import * as THREE from 'three' ;
const LEVELS = 6 ;
const METER = 32 ;
const VERT = `
in vec3 position;
out vec2 vUv;
void main() {
vUv = position.xy * 0.5 + 0.5;
gl_Position = vec4(position.xy, 0.0, 1.0);
} ` ;
const HEAD = `
precision highp float;
precision highp sampler2D;
in vec2 vUv;
out vec4 fragColor;
` ;
const DOWN = `
uniform sampler2D tSrc;
uniform vec2 uTexel; // source texel size
#ifdef PREFILTER
uniform vec4 uCurve; // threshold-knee, 2*knee, 0.25/knee, threshold
uniform float uClamp;
#endif
float luma(vec3 c) { return dot(c, vec3(0.2126, 0.7152, 0.0722)); }
vec3 tap(vec2 o) {
vec3 c = texture(tSrc, vUv + o * uTexel).rgb;
#ifdef PREFILTER
c = max(c, 0.0); // negatives (and NaN on most GPUs) -> 0
float l = max(luma(c), 1e-4);
c *= min(1.0, uClamp / l);
l = min(l, uClamp);
float q = clamp(l - uCurve.x, 0.0, uCurve.y);
c *= max(uCurve.z * q * q, l - uCurve.w) / l;
#endif
return c;
}
void main() {
vec3 a = tap(vec2(-2.0, 2.0)), b = tap(vec2(0.0, 2.0)), c = tap(vec2(2.0, 2.0));
vec3 d = tap(vec2(-2.0, 0.0)), e = tap(vec2(0.0, 0.0)), f = tap(vec2(2.0, 0.0));
vec3 g = tap(vec2(-2.0, -2.0)), h = tap(vec2(0.0, -2.0)), i = tap(vec2(2.0, -2.0));
vec3 j = tap(vec2(-1.0, 1.0)), k = tap(vec2(1.0, 1.0)), l = tap(vec2(-1.0, -1.0)), m = tap(vec2(1.0, -1.0));
vec3 g0 = (a + b + d + e) * 0.25, g1 = (b + c + e + f) * 0.25;
vec3 g2 = (d + e + g + h) * 0.25, g3 = (e + f + h + i) * 0.25;
vec3 g4 = (j + k + l + m) * 0.25;
#ifdef PREFILTER
float w0 = 0.125 / (1.0 + luma(g0)), w1 = 0.125 / (1.0 + luma(g1));
float w2 = 0.125 / (1.0 + luma(g2)), w3 = 0.125 / (1.0 + luma(g3));
float w4 = 0.5 / (1.0 + luma(g4));
vec3 r = (g0 * w0 + g1 * w1 + g2 * w2 + g3 * w3 + g4 * w4) / (w0 + w1 + w2 + w3 + w4);
#else
vec3 r = g4 * 0.5 + (g0 + g1 + g2 + g3) * 0.125;
#endif
fragColor = vec4(r, 1.0);
}
frag
uniforms defines extra
params
renderer
i i i
f32 renderer
f32
size renderer
size size
w width h height
w h
h
w h
i i i
w w
h h
i w h
i w h
mat
target
mat src
mat texel
mat target
p m a f
m hdr
m f f
key p lo p p hi p p
a
a
a dt p dt p
a key hi key lo
r p
dt dt dt
dt
prevTarget r prevClear r prevReset r
r
r
p hdrTexture dt
th p knee th
pre
pre th knee knee knee th
pre p
p
hdrTexture
i i i i i i
i i i i i i
u
u hdrTexture
u
u
u p
u p
u p p p p p
u p p
u p
u
u p
u
r prevTarget
r prevClear
r prevReset
rt rt
rt rt
m m
`
;
const
UP
=
`
uniform sampler2D tSrc;
uniform vec2 uTexel; // source (coarser) texel size
void main() {
vec4 d = uTexel.xyxy * vec4(1.0, 1.0, -1.0, 0.0);
vec3 s = texture(tSrc, vUv - d.xy).rgb + texture(tSrc, vUv - d.wy).rgb * 2.0 + texture(tSrc, vUv - d.zy).rgb
+ texture(tSrc, vUv + d.zw).rgb * 2.0 + texture(tSrc, vUv).rgb * 4.0 + texture(tSrc, vUv + d.xw).rgb * 2.0
+ texture(tSrc, vUv + d.zy).rgb + texture(tSrc, vUv + d.wy).rgb * 2.0 + texture(tSrc, vUv + d.xy).rgb;
fragColor = vec4(s * (1.0 / 16.0), 1.0);
} `
;
const
METER_FRAG
=
`
uniform sampler2D tSrc;
uniform vec2 uJitter; // [0,1)^2
void main() {
float s = 0.0;
for (int j = 0; j < 4; j++) for (int i = 0; i < 4; i++) {
vec2 o = (vec2(float(i), float(j)) + uJitter) * 0.25 - 0.5;
vec3 c = max(texture(tSrc, vUv + o * ${ ( 1 / METER ) . toFixed ( 8 ) } ).rgb, 0.0);
s += log2(clamp(dot(c, vec3(0.2126, 0.7152, 0.0722)), 1e-4, 64.0));
}
fragColor = vec4(s * (1.0 / 16.0), 0.0, 0.0, 1.0);
} `
;
const
ADAPT_FRAG
=
`
uniform sampler2D tSrc; // metering target, linear filtered
uniform sampler2D tPrev; // previous 1x1 state
uniform vec2 uK; // blend factor when scene brightens (x) / darkens (y); 1 = snap
uniform vec2 uRange; // allowed log2 luminance range (from min/max exposure)
void main() {
float sum = 0.0;
for (int j = 0; j < 16; j++) for (int i = 0; i < 16; i++)
sum += texture(tSrc, (vec2(float(i), float(j)) + 0.5) * (1.0 / 16.0)).r;
float t = clamp(sum * (1.0 / 256.0), uRange.x, uRange.y);
float prev = texelFetch(tPrev, ivec2(0), 0).r;
float k = t > prev ? uK.x : uK.y;
float s = k >= 1.0 ? t : prev + (t - prev) * k;
if (isnan(s)) s = t;
fragColor = vec4(s, 0.0, 0.0, 1.0);
} `
;
const
COMP
=
`
uniform sampler2D tHdr;
uniform sampler2D tBloom;
uniform sampler2D tExp; // 1x1 adapted log2 average luminance
uniform float uExposure; // exposure compensation (auto) or absolute exposure
uniform float uAuto; // 1 = auto exposure
uniform vec3 uExpo; // keyValue, minExposure, maxExposure
uniform float uBloom;
uniform vec2 uLook; // AgX look: power (contrast), saturation
uniform float uFrame; // 0..255, dither seed
uniform float uDroplets; // 0..1
uniform float uTime; // seconds, wraps at 4096
uniform float uAspect; // width / height
uniform float uResY; // height in pixels
const mat3 SRGB_TO_REC2020 = mat3(
vec3(0.6274, 0.0691, 0.0164), vec3(0.3293, 0.9195, 0.0880), vec3(0.0433, 0.0113, 0.8956));
const mat3 REC2020_TO_SRGB = mat3(
vec3(1.6605, -0.1246, -0.0182), vec3(-0.5876, 1.1329, -0.1006), vec3(-0.0728, -0.0083, 1.1187));
const mat3 AGX_INSET = mat3(
vec3(0.856627153315983, 0.137318972929847, 0.11189821299995),
vec3(0.0951212405381588, 0.761241990602591, 0.0767994186031903),
vec3(0.0482516061458583, 0.101439036467562, 0.811302368396859));
const mat3 AGX_OUTSET = mat3(
vec3(1.1271005818144368, -0.1413297634984383, -0.14132976349843826),
vec3(-0.11060664309660323, 1.157823702216272, -0.11060664309660294),
vec3(-0.016493938717834573, -0.016493938717834257, 1.2519364065950405));
const float AGX_MIN_EV = -12.47393;
const float AGX_MAX_EV = 4.026069;
vec3 agxContrast(vec3 x) {
vec3 x2 = x * x, x4 = x2 * x2;
return 15.5 * x4 * x2 - 40.14 * x4 * x + 31.96 * x4 - 6.868 * x2 * x + 0.4298 * x2 + 0.1191 * x - 0.00232;
}
vec3 agx(vec3 c) {
c = AGX_INSET * (SRGB_TO_REC2020 * c);
c = clamp((log2(max(c, 1e-10)) - AGX_MIN_EV) / (AGX_MAX_EV - AGX_MIN_EV), 0.0, 1.0);
c = agxContrast(c);
// AgX "punchy"-style look in the encoded domain
c = pow(max(c, 0.0), vec3(uLook.x));
float l = dot(c, vec3(0.2126, 0.7152, 0.0722));
c = l + uLook.y * (c - l);
c = AGX_OUTSET * c;
return clamp(REC2020_TO_SRGB * pow(max(c, 0.0), vec3(2.2)), 0.0, 1.0);
}
// Dave Hoskins hash without sine
vec3 hash33(vec3 p) {
p = fract(p * vec3(0.1031, 0.1030, 0.0973));
p += dot(p, p.yxz + 33.33);
return fract((p.xxy + p.yxx) * p.zyx);
}
// ---- lens droplets (only evaluated when uDroplets > 0) -----------------------------------------
// All lengths are in screen-height units (p = vUv * vec2(aspect, 1)). Each drop is a tiny lens: the
// image under it is sampled from the mirrored side of its centre, sample = centre - (K-1) * d, so it
// looks inverted and slightly magnified, with a faint dark rim.
const float DROP_K = 1.8;
// d: pixel - drop centre, r: radius. Returns (uv offset, darkening).
vec3 lensDrop(vec2 d, float r) {
float dist = length(d);
float cov = clamp((r - dist) * uResY + 0.5, 0.0, 1.0); // 1px AA
if (cov <= 0.0) return vec3(0.0);
return vec3(-d * DROP_K * cov, 0.22 * smoothstep(0.6, 1.0, dist / r) * cov);
}
// One drop (at most) per grid cell, kept inside its cell so only the own cell is tested.
vec3 dropLayer(vec2 p, float scale, float density, float seed) {
vec2 q = p * scale + seed * 17.31;
vec2 id = floor(q);
vec3 h = hash33(vec3(id, seed)), g = hash33(vec3(id + 57.0, seed));
if (h.x > density) return vec3(0.0);
float fade = clamp((uDroplets - g.x * 0.8) * 6.0, 0.0, 1.0); // drops dry up one by one (order = g.x)
float rf = mix(0.10, 0.24, h.y * h.y); // radius, cell units
vec2 c = rf + vec2(h.z, g.y) * (1.0 - 2.0 * rf);
return lensDrop((fract(q) - c) / scale, rf * fade / scale);
}
// A drop sliding down the lens, leaving a thin wet trail above it. speed in cycles/s.
// Head enters above the screen and leaves below with its trail fully off-screen, so the wrap never pops.
vec3 streak(vec2 p, float id, float speed, float amp) {
const float R = 0.016, L = 0.45, W = 0.0035;
float u = uTime * speed + id * 0.37;
float cyc = mod(floor(u), 128.0), f = fract(u);
f += 0.012 * sin(f * 47.0); // stick-slip
vec3 h = hash33(vec3(id, cyc, 5.1));
float x0 = (0.08 + 0.84 * h.x) * uAspect;
float hy = mix(1.0 + R, -R - L, f);
float hx = x0 + 0.006 * sin(hy * 14.0 + h.y * 6.28);
vec3 o = lensDrop(p - vec2(hx, hy), R * amp);
float ty = p.y - hy;
if (ty > 0.0 && ty < L) {
float a = smoothstep(0.0, 0.03, ty) * (1.0 - ty / L) * amp;
float tx = (p.x - x0 - 0.006 * sin(p.y * 14.0 + h.y * 6.28)) / W;
float cov = clamp((1.0 - abs(tx)) * W * uResY + 0.5, 0.0, 1.0) * a;
o += vec3(-tx * W * DROP_K * cov, 0.0, 0.12 * smoothstep(0.5, 1.0, abs(tx)) * cov);
}
return o;
}
// Returns (uv offset, darkening).
vec3 droplets() {
vec2 p = vUv * vec2(uAspect, 1.0);
float sa = smoothstep(0.0, 0.4, uDroplets);
vec3 a = dropLayer(p, 6.0, 0.30, 0.0) + dropLayer(p, 10.0, 0.20, 1.0) + dropLayer(p, 17.0, 0.06, 2.0)
+ streak(p, 0.0, 0.0625, sa) + streak(p, 1.0, 0.03125, sa);
return vec3(a.xy / vec2(uAspect, 1.0), min(a.z, 0.5));
}
void main() {
float ex = uExposure;
if (uAuto > 0.5) ex *= clamp(uExpo.x * exp2(-texelFetch(tExp, ivec2(0), 0).r), uExpo.y, uExpo.z);
vec2 uv = vUv;
float dark = 0.0;
if (uDroplets > 0.001) {
vec3 dr = droplets();
uv += dr.xy;
dark = dr.z;
}
vec3 c = (texture(tHdr, uv).rgb + texture(tBloom, uv).rgb * uBloom) * (ex * (1.0 - dark));
vec2 d = (vUv - 0.5) * 1.41421356; // |d|^2 = 1 at corners
c = agx(c) * (1.0 - 0.08 * dot(d, d));
vec3 o = mix(pow(c, vec3(1.0 / 2.4)) * 1.055 - 0.055, c * 12.92, vec3(lessThanEqual(c, vec3(0.0031308))));
// TPDF dither, +-1/255, after sRGB encoding and before the 8-bit store
vec3 n = hash33(vec3(gl_FragCoord.xy, uFrame)) + hash33(vec3(gl_FragCoord.xy, uFrame + 17.0));
fragColor = vec4(o + (n - 1.0) * (1.0 / 255.0), 1.0);
} `
;
const
mk
=
(
frag, uniforms, defines = { } , extra = { }
)
=>
new
THREE. RawShaderMaterial
(
{
glslVersion
:
THREE
.
GLSL3
,
vertexShader
:
VERT
,
fragmentShader
:
HEAD
+
,
,
,
depthTest
:
false
,
depthWrite
:
false
,
...
,
}
)
;
export
class
PostFX
{
=
{
exposure
:
1.0
,
autoExposure
:
true
,
keyValue
:
0.18
,
adaptUp
:
2.5
,
adaptDown
:
1.0
,
minExposure
:
0.05
,
maxExposure
:
20.0
,
bloomStrength
:
0.06
,
bloomThreshold
:
1.0
,
bloomClamp
:
64.0
,
contrast
:
1.12
,
saturation
:
1.3
,
droplets
:
0.0
,
}
;
constructor
(
renderer
)
{
this
.
renderer
=
;
this
.
geometry
=
new
THREE. BufferGeometry
(
)
;
this
.
geometry
.
setAttribute
(
'position'
,
new
THREE. Float32BufferAttribute
(
[
-
1
,
-
1
,
0
,
3
,
-
1
,
0
,
-
1
,
3
,
0
]
,
3
)
)
;
this
.
mesh
=
new
THREE. Mesh
(
this
.
geometry
)
;
this
.
mesh
.
frustumCulled
=
false
;
this
.
camera
=
new
THREE. OrthographicCamera
(
-
1
,
1
,
1
,
-
1
,
0
,
1
)
;
const
src
=
(
)
=>
(
{
tSrc
:
{
value
:
null
}
,
uTexel
:
{
value
:
null
}
}
)
;
this
.
matPre
=
mk
(
DOWN
,
{
...
src
(
)
,
uCurve
:
{
value
:
new
THREE. Vector4
(
)
}
,
uClamp
:
{
value
:
64
}
}
,
{
PREFILTER
:
1
}
)
;
this
.
matDown
=
mk
(
DOWN
,
src
(
)
)
;
this
.
matUp
=
mk
(
UP
,
src
(
)
,
{
}
,
{
blending
:
THREE
.
CustomBlending
,
blendEquation
:
THREE
.
AddEquation
,
blendSrc
:
THREE
.
OneFactor
,
blendDst
:
THREE
.
OneFactor
,
}
)
;
this
.
matMeter
=
mk
(
METER_FRAG
,
{
tSrc
:
{
value
:
null
}
,
uJitter
:
{
value
:
new
THREE. Vector2
(
)
}
}
)
;
this
.
matAdapt
=
mk
(
ADAPT_FRAG
,
{
tSrc
:
{
value
:
null
}
,
tPrev
:
{
value
:
null
}
,
uK
:
{
value
:
new
THREE. Vector2
(
1
,
1
)
}
,
uRange
:
{
value
:
new
THREE. Vector2
(
-
8
,
4
)
}
,
}
)
;
this
.
matComp
=
mk
(
COMP
,
{
tHdr
:
{
value
:
null
}
,
tBloom
:
{
value
:
null
}
,
tExp
:
{
value
:
null
}
,
uExposure
:
{
value
:
1
}
,
uAuto
:
{
value
:
1
}
,
uExpo
:
{
value
:
new
THREE. Vector3
(
0.18
,
0.05
,
20
)
}
,
uBloom
:
{
value
:
0
}
,
uLook
:
{
value
:
new
THREE. Vector2
(
1
,
1
)
}
,
uFrame
:
{
value
:
0
}
,
uDroplets
:
{
value
:
0
}
,
uTime
:
{
value
:
0
}
,
uAspect
:
{
value
:
1
}
,
uResY
:
{
value
:
1
}
,
}
)
;
this
.
levels
=
[
]
;
this
.
texel
=
[
new
THREE. Vector2
(
)
]
;
for
(
let
=
0
;
<
LEVELS
;
++
)
{
this
.
levels
.
push
(
new
THREE. WebGLRenderTarget
(
1
,
1
,
{
type
:
THREE
.
HalfFloatType
,
format
:
THREE
.
RGBAFormat
,
minFilter
:
THREE
.
LinearFilter
,
magFilter
:
THREE
.
LinearFilter
,
wrapS
:
THREE
.
ClampToEdgeWrapping
,
wrapT
:
THREE
.
ClampToEdgeWrapping
,
depthBuffer
:
false
,
stencilBuffer
:
false
,
generateMipmaps
:
false
,
}
)
)
;
this
.
texel
.
push
(
new
THREE. Vector2
(
)
)
;
}
this
.
meterRT
=
new
THREE. WebGLRenderTarget
(
METER
,
METER
,
{
type
:
THREE
.
HalfFloatType
,
format
:
THREE
.
RGBAFormat
,
minFilter
:
THREE
.
LinearFilter
,
magFilter
:
THREE
.
LinearFilter
,
depthBuffer
:
false
,
stencilBuffer
:
false
,
generateMipmaps
:
false
,
}
)
;
const
=
.
extensions
.
has
(
'EXT_color_buffer_float'
)
;
this
.
adapt
=
[
0
,
1
]
.
map
(
(
)
=>
new
THREE. WebGLRenderTarget
(
1
,
1
,
{
type
:
?
THREE
.
FloatType
:
THREE
.
HalfFloatType
,
format
:
THREE
.
RGBAFormat
,
minFilter
:
THREE
.
NearestFilter
,
magFilter
:
THREE
.
NearestFilter
,
depthBuffer
:
false
,
stencilBuffer
:
false
,
generateMipmaps
:
false
,
}
)
)
;
this
.
_cur
=
0
;
this
.
_snap
=
true
;
this
.
_frame
=
0
;
this
.
_time
=
0
;
const
=
.
getDrawingBufferSize
(
new
THREE. Vector2
(
)
)
;
this
.
setSize
(
.
x
,
.
y
)
;
}
setSize
(
width, height
)
{
let
=
Math
.
max
(
1
,
Math
.
floor
(
)
)
,
=
Math
.
max
(
1
,
Math
.
floor
(
)
)
;
this
.
matComp
.
uniforms
.
uAspect
.
value
=
/
;
this
.
matComp
.
uniforms
.
uResY
.
value
=
;
this
.
_snap
=
true
;
this
.
texel
[
0
]
.
set
(
1
/
,
1
/
)
;
for
(
let
=
0
;
<
LEVELS
;
++
)
{
=
Math
.
max
(
1
,
Math
.
floor
(
/
2
)
)
;
=
Math
.
max
(
1
,
Math
.
floor
(
/
2
)
)
;
this
.
levels
[
]
.
setSize
(
,
)
;
this
.
texel
[
+
1
]
.
set
(
1
/
,
1
/
)
;
}
}
_pass
(
mat, target
)
{
this
.
mesh
.
material
=
;
this
.
renderer
.
setRenderTarget
(
)
;
this
.
renderer
.
render
(
this
.
mesh
,
this
.
camera
)
;
}
_blit
(
mat, src, texel, target
)
{
.
uniforms
.
tSrc
.
value
=
;
.
uniforms
.
uTexel
.
value
=
;
this
.
_pass
(
,
)
;
}
_meterExposure
(
hdr, dt
)
{
const
=
this
.
params
,
=
this
.
matMeter
.
uniforms
,
=
this
.
matAdapt
.
uniforms
,
=
this
.
_frame
;
.
tSrc
.
value
=
;
.
uJitter
.
value
.
set
(
(
*
0.7548776662466927
)
%
1
,
(
*
0.5698402909980532
)
%
1
)
;
this
.
_pass
(
this
.
matMeter
,
this
.
meterRT
)
;
const
=
Math
.
max
(
.
keyValue
,
1e-4
)
,
=
Math
.
max
(
Math
.
min
(
.
minExposure
,
.
maxExposure
)
,
1e-4
)
,
=
Math
.
max
(
.
minExposure
,
.
maxExposure
,
1e-4
)
;
.
tSrc
.
value
=
this
.
meterRT
.
texture
;
.
tPrev
.
value
=
this
.
adapt
[
this
.
_cur
]
.
texture
;
.
uK
.
value
.
set
(
this
.
_snap
?
1
:
1
-
Math
.
exp
(
-
*
.
adaptUp
)
,
this
.
_snap
?
1
:
1
-
Math
.
exp
(
-
*
.
adaptDown
)
)
;
.
uRange
.
value
.
set
(
Math
.
log2
(
/
)
,
Math
.
log2
(
/
)
)
;
this
.
_cur
^=
1
;
this
.
_pass
(
this
.
matAdapt
,
this
.
adapt
[
this
.
_cur
]
)
;
this
.
_snap
=
false
;
}
render
(
hdrTexture, dt = 1 / 60
)
{
const
=
this
.
renderer
,
=
this
.
params
,
L
=
this
.
levels
,
T
=
this
.
texel
;
=
>
0
?
Math
.
min
(
,
1
)
:
0
;
this
.
_frame
=
(
this
.
_frame
+
1
)
&
255
;
this
.
_time
=
(
this
.
_time
+
)
%
4096
;
const
=
.
getRenderTarget
(
)
,
=
.
autoClear
,
=
.
info
.
autoReset
;
.
autoClear
=
false
;
.
info
.
autoReset
=
false
;
if
(
.
autoExposure
)
this
.
_meterExposure
(
,
)
;
else
this
.
_snap
=
true
;
const
=
.
bloomThreshold
,
=
Math
.
max
(
*
0.5
,
1e-4
)
;
const
=
this
.
matPre
.
uniforms
;
.
uCurve
.
value
.
set
(
-
,
2
*
,
0.25
/
,
)
;
.
uClamp
.
value
=
.
bloomClamp
;
if
(
.
bloomStrength
>
0
)
{
this
.
_blit
(
this
.
matPre
,
,
T
[
0
]
,
L
[
0
]
)
;
for
(
let
=
1
;
<
LEVELS
;
++
)
this
.
_blit
(
this
.
matDown
,
L
[
-
1
]
.
texture
,
T
[
]
,
L
[
]
)
;
for
(
let
=
LEVELS
-
2
;
>=
0
;
--
)
this
.
_blit
(
this
.
matUp
,
L
[
+
1
]
.
texture
,
T
[
+
2
]
,
L
[
]
)
;
}
const
=
this
.
matComp
.
uniforms
;
.
tHdr
.
value
=
;
.
tBloom
.
value
=
L
[
0
]
.
texture
;
.
tExp
.
value
=
this
.
adapt
[
this
.
_cur
]
.
texture
;
.
uExposure
.
value
=
.
exposure
;
.
uAuto
.
value
=
.
autoExposure
?
1
:
0
;
.
uExpo
.
value
.
set
(
.
keyValue
,
Math
.
min
(
.
minExposure
,
.
maxExposure
)
,
Math
.
max
(
.
minExposure
,
.
maxExposure
)
)
;
.
uLook
.
value
.
set
(
.
contrast
,
.
saturation
)
;
.
uBloom
.
value
=
.
bloomStrength
;
.
uFrame
.
value
=
this
.
_frame
;
.
uDroplets
.
value
=
Math
.
min
(
Math
.
max
(
.
droplets
,
0
)
,
1
)
;
.
uTime
.
value
=
this
.
_time
;
this
.
_pass
(
this
.
matComp
,
null
)
;
.
setRenderTarget
(
)
;
.
autoClear
=
;
.
info
.
autoReset
=
;
}
dispose
(
)
{
for
(
const
of
this
.
levels
)
.
dispose
(
)
;
this
.
meterRT
.
dispose
(
)
;
for
(
const
of
this
.
adapt
)
.
dispose
(
)
;
for
(
const
of
[
this
.
matPre
,
this
.
matDown
,
this
.
matUp
,
this
.
matMeter
,
this
.
matAdapt
,
this
.
matComp
]
)
.
dispose
(
)
;
this
.
geometry
.
dispose
(
)
;
}
}