@react-three/postprocessing 3.0.3 → 3.0.5
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 +21 -21
- package/README.md +81 -81
- package/dist/EffectComposer.d.ts +28 -0
- package/dist/Selection.d.ts +17 -0
- package/dist/effects/ASCII.d.ts +19 -0
- package/dist/effects/Autofocus.d.ts +23 -0
- package/dist/effects/Bloom.d.ts +2 -0
- package/dist/effects/BrightnessContrast.d.ts +2 -0
- package/dist/effects/ChromaticAberration.d.ts +8 -0
- package/dist/effects/ColorAverage.d.ts +7 -0
- package/dist/effects/ColorDepth.d.ts +2 -0
- package/dist/effects/Depth.d.ts +2 -0
- package/dist/effects/DepthOfField.d.ts +14 -0
- package/dist/effects/DotScreen.d.ts +2 -0
- package/dist/effects/FXAA.d.ts +2 -0
- package/dist/effects/Glitch.d.ts +13 -0
- package/dist/effects/GodRays.d.ts +9 -0
- package/dist/effects/Grid.d.ts +11 -0
- package/dist/effects/HueSaturation.d.ts +2 -0
- package/dist/effects/LUT.d.ts +10 -0
- package/dist/effects/LensFlare.d.ts +54 -0
- package/dist/effects/N8AO.d.ts +19 -0
- package/dist/effects/Noise.d.ts +2 -0
- package/dist/effects/Outline.d.ts +11 -0
- package/dist/effects/Pixelation.d.ts +7 -0
- package/dist/effects/Ramp.d.ts +74 -0
- package/dist/effects/SMAA.d.ts +2 -0
- package/dist/effects/SSAO.d.ts +7 -0
- package/dist/effects/ScanlineEffect.d.ts +2 -0
- package/dist/effects/SelectiveBloom.d.ts +15 -0
- package/dist/effects/Sepia.d.ts +2 -0
- package/dist/effects/ShockWave.d.ts +2 -0
- package/dist/effects/Texture.d.ts +10 -0
- package/dist/effects/TiltShift.d.ts +2 -0
- package/dist/effects/TiltShift2.d.ts +18 -0
- package/dist/effects/ToneMapping.d.ts +4 -0
- package/dist/effects/Vignette.d.ts +2 -0
- package/dist/effects/Water.d.ts +8 -0
- package/dist/index.d.ts +38 -1
- package/dist/index.js +855 -551
- package/dist/index.js.map +1 -1
- package/dist/tests/test-utils.d.ts +12 -0
- package/dist/util.d.ts +25 -0
- package/dist/wrapEffect.d.ts +12 -0
- package/package.json +73 -66
- package/src/EffectComposer.tsx +278 -200
- package/src/Selection.tsx +86 -46
- package/src/effects/ASCII.tsx +136 -135
- package/src/effects/Autofocus.tsx +175 -153
- package/src/effects/Bloom.tsx +6 -6
- package/src/effects/BrightnessContrast.tsx +4 -4
- package/src/effects/ChromaticAberration.tsx +30 -5
- package/src/effects/ColorAverage.tsx +17 -15
- package/src/effects/ColorDepth.tsx +4 -4
- package/src/effects/Depth.tsx +4 -4
- package/src/effects/DepthOfField.tsx +87 -89
- package/src/effects/DotScreen.tsx +4 -4
- package/src/effects/FXAA.tsx +4 -4
- package/src/effects/Glitch.tsx +37 -40
- package/src/effects/GodRays.tsx +20 -16
- package/src/effects/Grid.tsx +28 -21
- package/src/effects/HueSaturation.tsx +4 -4
- package/src/effects/LUT.tsx +27 -26
- package/src/effects/LensFlare.tsx +611 -611
- package/src/effects/N8AO.tsx +81 -81
- package/src/effects/Noise.tsx +4 -4
- package/src/effects/Outline.tsx +85 -117
- package/src/effects/Pixelation.tsx +17 -15
- package/src/effects/Ramp.tsx +150 -150
- package/src/effects/SMAA.tsx +4 -4
- package/src/effects/SSAO.tsx +44 -41
- package/src/effects/ScanlineEffect.tsx +7 -7
- package/src/effects/SelectiveBloom.tsx +116 -126
- package/src/effects/Sepia.tsx +4 -4
- package/src/effects/ShockWave.tsx +4 -4
- package/src/effects/Texture.tsx +27 -23
- package/src/effects/TiltShift.tsx +4 -4
- package/src/effects/TiltShift2.tsx +90 -90
- package/src/effects/ToneMapping.tsx +6 -6
- package/src/effects/Vignette.tsx +4 -4
- package/src/effects/Water.tsx +35 -35
- package/src/index.ts +41 -40
- package/src/tests/ChromaticAberration.test.tsx +31 -0
- package/src/tests/EffectComposer.test.tsx +911 -0
- package/src/tests/Outline.test.tsx +89 -0
- package/src/tests/Selection.test.tsx +324 -0
- package/src/tests/SelectiveBloom.test.tsx +118 -0
- package/src/tests/effects.smoke.test.tsx +234 -0
- package/src/tests/test-utils.tsx +96 -0
- package/src/tests/wrapEffect.test.tsx +209 -0
- package/src/util.tsx +96 -55
- package/src/wrapEffect.tsx +122 -0
- package/src/EffectComposer.test.tsx +0 -126
package/dist/index.js
CHANGED
|
@@ -1,555 +1,859 @@
|
|
|
1
|
-
import
|
|
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
|
-
float fl = floor(p);
|
|
27
|
-
float fc = fract(p);
|
|
28
|
-
return mix(rand(fl),rand(fl + 1.0), fc);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
vec3 hsv2rgb(vec3 c)
|
|
32
|
-
{
|
|
33
|
-
vec4 k = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
|
|
34
|
-
vec3 p = abs(fract(c.xxx + k.xyz) * 6.0 - k.www);
|
|
35
|
-
return c.z * mix(k.xxx, clamp(p - k.xxx, 0.0, 1.0), c.y);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
float saturate(float x)
|
|
39
|
-
{
|
|
40
|
-
return clamp(x, 0.,1.);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
vec2 rotateUV(vec2 uv, float rotation)
|
|
44
|
-
{
|
|
45
|
-
return vec2(
|
|
46
|
-
cos(rotation) * uv.x + sin(rotation) * uv.y,
|
|
47
|
-
cos(rotation) * uv.y - sin(rotation) * uv.x
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// Based on https://www.shadertoy.com/view/XtKfRV
|
|
52
|
-
vec3 drawflare(vec2 p, float intensity, float rnd, float speed, int id)
|
|
53
|
-
{
|
|
54
|
-
float flarehueoffset = (1. / 32.) * float(id) * 0.1;
|
|
55
|
-
float lingrad = distance(vec2(0.), p);
|
|
56
|
-
float expgrad = 1. / exp(lingrad * (fract(rnd) * 0.66 + 0.33));
|
|
57
|
-
vec3 colgrad = hsv2rgb(vec3( fract( (expgrad * 8.) + speed * flareSpeed + flarehueoffset), pow(1.-abs(expgrad*2.-1.), 0.45), 20.0 * expgrad * intensity)); //rainbow spectrum effect
|
|
58
|
-
|
|
59
|
-
float internalStarPoints;
|
|
60
|
-
|
|
61
|
-
if(anamorphic){
|
|
62
|
-
internalStarPoints = 1.0;
|
|
63
|
-
} else{
|
|
64
|
-
internalStarPoints = starPoints;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
float blades = length(p * flareShape * sin(internalStarPoints * atan(p.x, p.y)));
|
|
68
|
-
|
|
69
|
-
float comp = pow(1.-saturate(blades), ( anamorphic ? 100. : 12.));
|
|
70
|
-
comp += saturate(expgrad-0.9) * 3.;
|
|
71
|
-
comp = pow(comp * expgrad, 8. + (1.-intensity) * 5.);
|
|
72
|
-
|
|
73
|
-
if(flareSpeed > 0.0){
|
|
74
|
-
return vec3(comp) * colgrad;
|
|
75
|
-
} else{
|
|
76
|
-
return vec3(comp) * flareSize * 15.;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
float dist(vec3 a, vec3 b) { return abs(a.x - b.x) + abs(a.y - b.y) + abs(a.z - b.z); }
|
|
81
|
-
|
|
82
|
-
vec3 saturate(vec3 x)
|
|
83
|
-
{
|
|
84
|
-
return clamp(x, vec3(0.0), vec3(1.0));
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Based on https://www.shadertoy.com/view/XtKfRV
|
|
88
|
-
float glare(vec2 uv, vec2 pos, float size)
|
|
89
|
-
{
|
|
90
|
-
vec2 main;
|
|
91
|
-
|
|
92
|
-
if(animated){
|
|
93
|
-
main = rotateUV(uv-pos, time * 0.1);
|
|
94
|
-
} else{
|
|
95
|
-
main = uv-pos;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
float ang = atan(main.y, main.x) * (anamorphic ? 1.0 : starPoints);
|
|
99
|
-
float dist = length(main);
|
|
100
|
-
dist = pow(dist, .9);
|
|
101
|
-
|
|
102
|
-
float f0 = 1.0/(length(uv-pos)*(1.0/size*16.0)+.2);
|
|
103
|
-
|
|
104
|
-
return f0+f0*(sin((ang))*.2 +.3);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
float sdHex(vec2 p){
|
|
108
|
-
p = abs(p);
|
|
109
|
-
vec2 q = vec2(p.x*2.0*0.5773503, p.y + p.x*0.5773503);
|
|
110
|
-
return dot(step(q.xy,q.yx), 1.0-q.yx);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
//Based on https://www.shadertoy.com/view/dllSRX
|
|
114
|
-
float fpow(float x, float k){
|
|
115
|
-
return x > k ? pow((x-k)/(1.0-k),2.0) : 0.0;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
vec3 renderhex(vec2 uv, vec2 p, float s, vec3 col){
|
|
119
|
-
uv -= p;
|
|
120
|
-
if (abs(uv.x) < 0.2*s && abs(uv.y) < 0.2*s){
|
|
121
|
-
return mix(vec3(0),mix(vec3(0),col,0.1 + fpow(length(uv/s),0.1)*10.0),smoothstep(0.0,0.1,sdHex(uv*20.0/s)));
|
|
122
|
-
}
|
|
123
|
-
return vec3(0);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Based on https://www.shadertoy.com/view/4sX3Rs
|
|
127
|
-
vec3 LensFlare(vec2 uv, vec2 pos)
|
|
128
|
-
{
|
|
129
|
-
vec2 main = uv-pos;
|
|
130
|
-
vec2 uvd = uv*(length(uv));
|
|
131
|
-
|
|
132
|
-
float ang = atan(main.x,main.y);
|
|
133
|
-
|
|
134
|
-
float f0 = .3/(length(uv-pos)*16.0+1.0);
|
|
135
|
-
|
|
136
|
-
f0 = f0*(sin(noise(sin(ang*3.9-(animated ? time : 0.0) * 0.3) * starPoints))*.2 );
|
|
137
|
-
|
|
138
|
-
float f1 = max(0.01-pow(length(uv+1.2*pos),1.9),.0)*7.0;
|
|
139
|
-
|
|
140
|
-
float f2 = max(.9/(10.0+32.0*pow(length(uvd+0.99*pos),2.0)),.0)*0.35;
|
|
141
|
-
float f22 = max(.9/(11.0+32.0*pow(length(uvd+0.85*pos),2.0)),.0)*0.23;
|
|
142
|
-
float f23 = max(.9/(12.0+32.0*pow(length(uvd+0.95*pos),2.0)),.0)*0.6;
|
|
143
|
-
|
|
144
|
-
vec2 uvx = mix(uv,uvd, 0.1);
|
|
145
|
-
|
|
146
|
-
float f4 = max(0.01-pow(length(uvx+0.4*pos),2.9),.0)*4.02;
|
|
147
|
-
float f42 = max(0.0-pow(length(uvx+0.45*pos),2.9),.0)*4.1;
|
|
148
|
-
float f43 = max(0.01-pow(length(uvx+0.5*pos),2.9),.0)*4.6;
|
|
149
|
-
|
|
150
|
-
uvx = mix(uv,uvd,-.4);
|
|
151
|
-
|
|
152
|
-
float f5 = max(0.01-pow(length(uvx+0.1*pos),5.5),.0)*2.0;
|
|
153
|
-
float f52 = max(0.01-pow(length(uvx+0.2*pos),5.5),.0)*2.0;
|
|
154
|
-
float f53 = max(0.01-pow(length(uvx+0.1*pos),5.5),.0)*2.0;
|
|
155
|
-
|
|
156
|
-
uvx = mix(uv,uvd, 2.1);
|
|
157
|
-
|
|
158
|
-
float f6 = max(0.01-pow(length(uvx-0.3*pos),1.61),.0)*3.159;
|
|
159
|
-
float f62 = max(0.01-pow(length(uvx-0.325*pos),1.614),.0)*3.14;
|
|
160
|
-
float f63 = max(0.01-pow(length(uvx-0.389*pos),1.623),.0)*3.12;
|
|
161
|
-
|
|
162
|
-
vec3 c = vec3(glare(uv,pos, glareSize));
|
|
163
|
-
|
|
164
|
-
vec2 prot;
|
|
165
|
-
|
|
166
|
-
if(animated){
|
|
167
|
-
prot = rotateUV(uv - pos, (time * 0.1));
|
|
168
|
-
} else if(anamorphic){
|
|
169
|
-
prot = rotateUV(uv - pos, 1.570796);
|
|
170
|
-
} else {
|
|
171
|
-
prot = uv - pos;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
c += drawflare(prot, (anamorphic ? flareSize * 10. : flareSize), 0.1, time, 1);
|
|
175
|
-
|
|
176
|
-
c.r+=f1+f2+f4+f5+f6; c.g+=f1+f22+f42+f52+f62; c.b+=f1+f23+f43+f53+f63;
|
|
177
|
-
c = c*1.3 * vec3(length(uvd)+.09);
|
|
178
|
-
c+=vec3(f0);
|
|
179
|
-
|
|
180
|
-
return c;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
vec3 cc(vec3 color, float factor,float factor2)
|
|
184
|
-
{
|
|
185
|
-
float w = color.x+color.y+color.z;
|
|
186
|
-
return mix(color,vec3(w)*factor,w*factor2);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
float rnd(vec2 p)
|
|
190
|
-
{
|
|
191
|
-
float f = fract(sin(dot(p, vec2(12.1234, 72.8392) )*45123.2));
|
|
192
|
-
return f;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
float rnd(float w)
|
|
196
|
-
{
|
|
197
|
-
float f = fract(sin(w)*1000.);
|
|
198
|
-
return f;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
float regShape(vec2 p, int N)
|
|
202
|
-
{
|
|
203
|
-
float f;
|
|
204
|
-
|
|
205
|
-
float a=atan(p.x,p.y)+.2;
|
|
206
|
-
float b=6.28319/float(N);
|
|
207
|
-
f=smoothstep(.5,.51, cos(floor(.5+a/b)*b-a)*length(p.xy)* 2.0 -ghostScale);
|
|
208
|
-
|
|
209
|
-
return f;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
// Based on https://www.shadertoy.com/view/Xlc3D2
|
|
213
|
-
vec3 circle(vec2 p, float size, float decay, vec3 color, vec3 color2, float dist, vec2 position)
|
|
214
|
-
{
|
|
215
|
-
float l = length(p + position*(dist*2.))+size/2.;
|
|
216
|
-
float l2 = length(p + position*(dist*4.))+size/3.;
|
|
217
|
-
|
|
218
|
-
float c = max(0.01-pow(length(p + position*dist), size*ghostScale), 0.0)*10.;
|
|
219
|
-
float c1 = max(0.001-pow(l-0.3, 1./40.)+sin(l*20.), 0.0)*3.;
|
|
220
|
-
float c2 = max(0.09/pow(length(p-position*dist/.5)*1., .95), 0.0)/20.;
|
|
221
|
-
float s = max(0.02-pow(regShape(p*5. + position*dist*5. + decay, 6) , 1.), 0.0)*1.5;
|
|
222
|
-
|
|
223
|
-
color = cos(vec3(0.44, .24, .2)*16. + dist/8.)*0.5+.5;
|
|
224
|
-
vec3 f = c*color;
|
|
225
|
-
f += c1*color;
|
|
226
|
-
f += c2*color;
|
|
227
|
-
f += s*color;
|
|
228
|
-
return f;
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
vec4 getLensColor(float x){
|
|
232
|
-
return vec4(vec3(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(vec3(0., 0., 0.),
|
|
233
|
-
vec3(0., 0., 0.), smoothstep(0.0, 0.063, x)),
|
|
234
|
-
vec3(0., 0., 0.), smoothstep(0.063, 0.125, x)),
|
|
235
|
-
vec3(0.0, 0., 0.), smoothstep(0.125, 0.188, x)),
|
|
236
|
-
vec3(0.188, 0.131, 0.116), smoothstep(0.188, 0.227, x)),
|
|
237
|
-
vec3(0.31, 0.204, 0.537), smoothstep(0.227, 0.251, x)),
|
|
238
|
-
vec3(0.192, 0.106, 0.286), smoothstep(0.251, 0.314, x)),
|
|
239
|
-
vec3(0.102, 0.008, 0.341), smoothstep(0.314, 0.392, x)),
|
|
240
|
-
vec3(0.086, 0.0, 0.141), smoothstep(0.392, 0.502, x)),
|
|
241
|
-
vec3(1.0, 0.31, 0.0), smoothstep(0.502, 0.604, x)),
|
|
242
|
-
vec3(.1, 0.1, 0.1), smoothstep(0.604, 0.643, x)),
|
|
243
|
-
vec3(1.0, 0.929, 0.0), smoothstep(0.643, 0.761, x)),
|
|
244
|
-
vec3(1.0, 0.086, 0.424), smoothstep(0.761, 0.847, x)),
|
|
245
|
-
vec3(1.0, 0.49, 0.0), smoothstep(0.847, 0.89, x)),
|
|
246
|
-
vec3(0.945, 0.275, 0.475), smoothstep(0.89, 0.941, x)),
|
|
247
|
-
vec3(0.251, 0.275, 0.796), smoothstep(0.941, 1.0, x))),
|
|
248
|
-
1.0);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
float dirtNoise(vec2 p){
|
|
252
|
-
vec2 f = fract(p);
|
|
253
|
-
f = (f * f) * (3.0 - (2.0 * f));
|
|
254
|
-
float n = dot(floor(p), vec2(1.0, 157.0));
|
|
255
|
-
vec4 a = fract(sin(vec4(n + 0.0, n + 1.0, n + 157.0, n + 158.0)) * 43758.5453123);
|
|
256
|
-
return mix(mix(a.x, a.y, f.x), mix(a.z, a.w, f.x), f.y);
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
float fbm(vec2 p){
|
|
260
|
-
const mat2 m = mat2(0.80, -0.60, 0.60, 0.80);
|
|
261
|
-
float f = 0.0;
|
|
262
|
-
f += 0.5000*dirtNoise(p); p = m*p*2.02;
|
|
263
|
-
f += 0.2500*dirtNoise(p); p = m*p*2.03;
|
|
264
|
-
f += 0.1250*dirtNoise(p); p = m*p*2.01;
|
|
265
|
-
f += 0.0625*dirtNoise(p);
|
|
266
|
-
return f/0.9375;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
vec4 getLensStar(vec2 p){
|
|
270
|
-
vec2 pp = (p - vec2(0.5)) * 2.0;
|
|
271
|
-
float a = atan(pp.y, pp.x);
|
|
272
|
-
vec4 cp = vec4(sin(a * 1.0), length(pp), sin(a * 13.0), sin(a * 53.0));
|
|
273
|
-
float d = sin(clamp(pow(length(vec2(0.5) - p) * 0.5 + haloScale /2., 5.0), 0.0, 1.0) * 3.14159);
|
|
274
|
-
vec3 c = vec3(d) * vec3(fbm(cp.xy * 16.0) * fbm(cp.zw * 9.0) * max(max(max(max(0.5, sin(a * 1.0)), sin(a * 3.0) * 0.8), sin(a * 7.0) * 0.8), sin(a * 9.0) * 10.6));
|
|
275
|
-
c *= vec3(mix(2.0, (sin(length(pp.xy) * 256.0) * 0.5) + 0.5, sin((clamp((length(pp.xy) - 0.875) / 0.1, 0.0, 1.0) + 0.0) * 2.0 * 3.14159) * 1.5) + 0.5) * 0.3275;
|
|
276
|
-
return vec4(vec3(c * 1.0), d);
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
vec4 getLensDirt(vec2 p){
|
|
280
|
-
p.xy += vec2(fbm(p.yx * 3.0), fbm(p.yx * 2.0)) * 0.0825;
|
|
281
|
-
vec3 o = vec3(mix(0.125, 0.25, max(max(smoothstep(0.1, 0.0, length(p - vec2(0.25))),
|
|
282
|
-
smoothstep(0.4, 0.0, length(p - vec2(0.75)))),
|
|
283
|
-
smoothstep(0.8, 0.0, length(p - vec2(0.875, 0.125))))));
|
|
284
|
-
o += vec3(max(fbm(p * 1.0) - 0.5, 0.0)) * 0.5;
|
|
285
|
-
o += vec3(max(fbm(p * 2.0) - 0.5, 0.0)) * 0.5;
|
|
286
|
-
o += vec3(max(fbm(p * 4.0) - 0.5, 0.0)) * 0.25;
|
|
287
|
-
o += vec3(max(fbm(p * 8.0) - 0.75, 0.0)) * 1.0;
|
|
288
|
-
o += vec3(max(fbm(p * 16.0) - 0.75, 0.0)) * 0.75;
|
|
289
|
-
o += vec3(max(fbm(p * 64.0) - 0.75, 0.0)) * 0.5;
|
|
290
|
-
return vec4(clamp(o, vec3(0.15), vec3(1.0)), 1.0);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
vec4 textureLimited(sampler2D tex, vec2 texCoord){
|
|
294
|
-
if(((texCoord.x < 0.) || (texCoord.y < 0.)) || ((texCoord.x > 1.) || (texCoord.y > 1.))){
|
|
295
|
-
return vec4(0.0);
|
|
296
|
-
}else{
|
|
297
|
-
return texture(tex, texCoord);
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
vec4 textureDistorted(sampler2D tex, vec2 texCoord, vec2 direction, vec3 distortion) {
|
|
302
|
-
return vec4(textureLimited(tex, (texCoord + (direction * distortion.r))).r,
|
|
303
|
-
textureLimited(tex, (texCoord + (direction * distortion.g))).g,
|
|
304
|
-
textureLimited(tex, (texCoord + (direction * distortion.b))).b,
|
|
305
|
-
1.0);
|
|
306
|
-
}
|
|
307
|
-
|
|
308
|
-
// Based on https://www.shadertoy.com/view/4sK3W3
|
|
309
|
-
vec4 getStartBurst(){
|
|
310
|
-
vec2 aspectTexCoord = vec2(1.0) - (((vTexCoord - vec2(0.5)) * vec2(1.0)) + vec2(0.5));
|
|
311
|
-
vec2 texCoord = vec2(1.0) - vTexCoord;
|
|
312
|
-
vec2 ghostVec = (vec2(0.5) - texCoord) * 0.3 - lensPosition;
|
|
313
|
-
vec2 ghostVecAspectNormalized = normalize(ghostVec * vec2(1.0)) * vec2(1.0);
|
|
314
|
-
vec2 haloVec = normalize(ghostVec) * 0.6;
|
|
315
|
-
vec2 haloVecAspectNormalized = ghostVecAspectNormalized * 0.6;
|
|
316
|
-
vec2 texelSize = vec2(1.0) / vec2(screenRes.xy);
|
|
317
|
-
vec3 distortion = vec3(-(texelSize.x * 1.5), 0.2, texelSize.x * 1.5);
|
|
318
|
-
vec4 c = vec4(0.0);
|
|
319
|
-
for (int i = 0; i < 8; i++) {
|
|
320
|
-
vec2 offset = texCoord + (ghostVec * float(i));
|
|
321
|
-
c += textureDistorted(lensDirtTexture, offset, ghostVecAspectNormalized, distortion) * pow(max(0.0, 1.0 - (length(vec2(0.5) - offset) / length(vec2(0.5)))), 10.0);
|
|
322
|
-
}
|
|
323
|
-
vec2 haloOffset = texCoord + haloVecAspectNormalized;
|
|
324
|
-
return (c * getLensColor((length(vec2(0.5) - aspectTexCoord) / length(vec2(haloScale))))) +
|
|
325
|
-
(textureDistorted(lensDirtTexture, haloOffset, ghostVecAspectNormalized, distortion) * pow(max(0.0, 1.0 - (length(vec2(0.5) - haloOffset) / length(vec2(0.5)))), 10.0));
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
void mainImage(vec4 inputColor, vec2 uv, out vec4 outputColor)
|
|
329
|
-
{
|
|
330
|
-
vec2 myUV = uv -0.5;
|
|
331
|
-
myUV.y *= screenRes.y/screenRes.x;
|
|
332
|
-
vec2 finalLensPosition = lensPosition * 0.5;
|
|
333
|
-
finalLensPosition.y *= screenRes.y/screenRes.x;
|
|
334
|
-
|
|
335
|
-
//First Lens flare pass
|
|
336
|
-
vec3 finalColor = LensFlare(myUV, finalLensPosition) * 20.0 * colorGain / 256.;
|
|
337
|
-
|
|
338
|
-
//Aditional streaks
|
|
339
|
-
if(aditionalStreaks){
|
|
340
|
-
vec3 circColor = vec3(0.9, 0.2, 0.1);
|
|
341
|
-
vec3 circColor2 = vec3(0.3, 0.1, 0.9);
|
|
342
|
-
|
|
343
|
-
for(float i=0.;i<10.;i++){
|
|
344
|
-
finalColor += circle(myUV, pow(rnd(i*2000.)*2.8, .1)+1.41, 0.0, circColor+i , circColor2+i, rnd(i*20.)*3.+0.2-.5, lensPosition);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
//Alternative ghosts
|
|
349
|
-
if(secondaryGhosts){
|
|
350
|
-
vec3 altGhosts = vec3(0);
|
|
351
|
-
altGhosts += renderhex(myUV, -lensPosition*0.25, ghostScale * 1.4, vec3(0.25,0.35,0));
|
|
352
|
-
altGhosts += renderhex(myUV, lensPosition*0.25, ghostScale * 0.5, vec3(1,0.5,0.5));
|
|
353
|
-
altGhosts += renderhex(myUV, lensPosition*0.1, ghostScale * 1.6, vec3(1,1,1));
|
|
354
|
-
altGhosts += renderhex(myUV, lensPosition*1.8, ghostScale * 2.0, vec3(0,0.5,0.75));
|
|
355
|
-
altGhosts += renderhex(myUV, lensPosition*1.25, ghostScale * 0.8, vec3(1,1,0.5));
|
|
356
|
-
altGhosts += renderhex(myUV, -lensPosition*1.25, ghostScale * 5.0, vec3(0.5,0.5,0.25));
|
|
357
|
-
|
|
358
|
-
//Circular ghosts
|
|
359
|
-
altGhosts += fpow(1.0 - abs(distance(lensPosition*0.8,myUV) - 0.7),0.985)*colorGain / 2100.;
|
|
360
|
-
finalColor += altGhosts;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
//Starburst
|
|
365
|
-
if(starBurst){
|
|
366
|
-
vTexCoord = myUV + 0.5;
|
|
367
|
-
vec4 lensMod = getLensDirt(myUV);
|
|
368
|
-
float tooBright = 1.0 - (clamp(0.5, 0.0, 0.5) * 2.0);
|
|
369
|
-
float tooDark = clamp(0.5 - 0.5, 0.0, 0.5) * 2.0;
|
|
370
|
-
lensMod += mix(lensMod, pow(lensMod * 2.0, vec4(2.0)) * 0.5, tooBright);
|
|
371
|
-
float lensStarRotationAngle = ((myUV.x + myUV.y)) * (1.0 / 6.0);
|
|
372
|
-
vec2 lensStarTexCoord = (mat2(cos(lensStarRotationAngle), -sin(lensStarRotationAngle), sin(lensStarRotationAngle), cos(lensStarRotationAngle)) * vTexCoord);
|
|
373
|
-
lensMod += getLensStar(lensStarTexCoord) * 2.;
|
|
374
|
-
|
|
375
|
-
finalColor += clamp((lensMod.rgb * getStartBurst().rgb ), 0.01, 1.0);
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
//Final composed output
|
|
379
|
-
if(enabled){
|
|
380
|
-
outputColor = vec4(mix(finalColor, vec3(.0), opacity) + inputColor.rgb, inputColor.a);
|
|
381
|
-
} else {
|
|
382
|
-
outputColor = vec4(inputColor);
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
`};class fe extends W{constructor({blendFunction:t,enabled:o,glareSize:r,lensPosition:a,screenRes:n,starPoints:i,flareSize:s,flareSpeed:l,flareShape:p,animated:_,anamorphic:S,colorGain:g,lensDirtTexture:d,haloScale:m,secondaryGhosts:v,aditionalStreaks:x,ghostScale:f,opacity:u,starBurst:c}){super("LensFlareEffect",_t.fragmentShader,{blendFunction:t,uniforms:/*@__PURE__*/new Map([["enabled",new h.Uniform(o)],["glareSize",new h.Uniform(r)],["lensPosition",new h.Uniform(a)],["time",new h.Uniform(0)],["screenRes",new h.Uniform(n)],["starPoints",new h.Uniform(i)],["flareSize",new h.Uniform(s)],["flareSpeed",new h.Uniform(l)],["flareShape",new h.Uniform(p)],["animated",new h.Uniform(_)],["anamorphic",new h.Uniform(S)],["colorGain",new h.Uniform(g)],["lensDirtTexture",new h.Uniform(d)],["haloScale",new h.Uniform(m)],["secondaryGhosts",new h.Uniform(v)],["aditionalStreaks",new h.Uniform(x)],["ghostScale",new h.Uniform(f)],["starBurst",new h.Uniform(c)],["opacity",new h.Uniform(u)]])})}update(t,o,r){const a=this.uniforms.get("time");a&&(a.value+=r)}}const xt=/*@__PURE__*/P(fe),gt=({smoothTime:e=.07,blendFunction:t=23,enabled:o=!0,glareSize:r=.2,lensPosition:a=new h.Vector3(-25,6,-60),screenRes:n=new h.Vector2(0,0),starPoints:i=6,flareSize:s=.01,flareSpeed:l=.01,flareShape:p=.01,animated:_=!0,anamorphic:S=!1,colorGain:g=new h.Color(20,20,20),lensDirtTexture:d=null,haloScale:m=.5,secondaryGhosts:v=!0,aditionalStreaks:x=!0,ghostScale:f=0,opacity:u=1,starBurst:c=!1})=>{const U=V(({viewport:T})=>T),b=V(({raycaster:T})=>T),{scene:F,camera:X}=M(D),[C]=j(()=>new h.Vector2),[R]=j(()=>new h.Vector3),E=O(null);return J((T,N)=>{if(!E?.current)return;const q=E.current.uniforms.get("lensPosition"),$=E.current.uniforms.get("opacity");if(!q||!$)return;let G=1;if(R.copy(a).project(X),R.z>1)return;q.value.x=R.x,q.value.y=R.y,C.x=R.x,C.y=R.y,b.setFromCamera(C,X);const ve=b.intersectObjects(F.children,!0),{object:I}=ve[0]||{};I&&(I.userData?.lensflare==="no-occlusion"?G=0:I instanceof h.Mesh&&(I.material.uniforms?._transmission?.value>.2||I.material._transmission&&I.material._transmission>.2?G=.2:I.material.transparent&&(G=I.material.opacity))),se.damp($,"value",G,e,N)}),A(()=>{if(!E?.current)return;const T=E.current.uniforms.get("screenRes");T&&(T.value.x=U.width,T.value.y=U.height)},[U]),/*@__PURE__*/w(xt,{ref:E,blendFunction:t,enabled:o,glareSize:r,lensPosition:a,screenRes:n,starPoints:i,flareSize:s,flareSpeed:l,flareShape:p,animated:_,anamorphic:S,colorGain:g,lensDirtTexture:d,haloScale:m,secondaryGhosts:v,aditionalStreaks:x,ghostScale:f,opacity:u,starBurst:c})},wt=/*@__PURE__*/P(Ie,{blendFunction:0}),St=/*@__PURE__*/P(Le),yt=/*@__PURE__*/P(Ne),Pt=/*@__PURE__*/B(function({blendFunction:e=23},t){const o=z(()=>new je(e),[e]);return /*@__PURE__*/w("primitive",{ref:t,object:o,dispose:null})}),bt=/*@__PURE__*/P(Oe),Et=/*@__PURE__*/P(We),Rt=/*@__PURE__*/P(Xe),Ut=/*@__PURE__*/B(function({active:e=!0,...t},o){const r=V(p=>p.invalidate),a=Z(t,"delay"),n=Z(t,"duration"),i=Z(t,"strength"),s=Z(t,"chromaticAberrationOffset"),l=z(()=>new qe({...t,delay:a,duration:n,strength:i,chromaticAberrationOffset:s}),[a,n,t,i,s]);return L(()=>{l.mode=e?t.mode||ne.SPORADIC:ne.DISABLED,r()},[e,l,r,t.mode]),A(()=>()=>{l.dispose?.()},[l]),/*@__PURE__*/w("primitive",{ref:o,object:l,dispose:null})}),Ct=/*@__PURE__*/B(function(e,t){const{camera:o}=M(D),r=z(()=>new He(o,k(e.sun),e),[o,e]);return L(()=>void(r.lightSource=k(e.sun)),[r,e.sun]),/*@__PURE__*/w("primitive",{ref:t,object:r,dispose:null})}),zt=/*@__PURE__*/B(function({size:e,...t},o){const r=V(n=>n.invalidate),a=z(()=>new Ze(t),[t]);return L(()=>{e&&a.setSize(e.width,e.height),r()},[a,e,r]),/*@__PURE__*/w("primitive",{ref:o,object:a,dispose:null})}),Tt=/*@__PURE__*/P($e),At=/*@__PURE__*/P(Ke,{blendFunction:5}),Bt=/*@__PURE__*/B(function({selection:e=[],selectionLayer:t=10,blendFunction:o,patternTexture:r,edgeStrength:a,pulseSpeed:n,visibleEdgeColor:i,hiddenEdgeColor:s,width:l,height:p,kernelSize:_,blur:S,xRay:g,...d},m){const v=V(U=>U.invalidate),{scene:x,camera:f}=M(D),u=z(()=>new Ye(x,f,{blendFunction:o,patternTexture:r,edgeStrength:a,pulseSpeed:n,visibleEdgeColor:i,hiddenEdgeColor:s,width:l,height:p,kernelSize:_,blur:S,xRay:g,...d}),[o,S,f,a,p,s,_,r,n,x,i,l,g]),c=M(H);return A(()=>{if(!c&&e)return u.selection.set(Array.isArray(e)?e.map(k):[k(e)]),v(),()=>{u.selection.clear(),v()}},[u,e,c,v]),A(()=>{u.selectionLayer=t,v()},[u,v,t]),O(void 0),A(()=>{if(c&&c.enabled&&c.selected?.length)return u.selection.set(c.selected),v(),()=>{u.selection.clear(),v()}},[c,u.selection,v]),A(()=>()=>{u.dispose()},[u]),/*@__PURE__*/w("primitive",{ref:m,object:u})}),Vt=/*@__PURE__*/B(function({granularity:e=5},t){const o=z(()=>new Je(e),[e]);return /*@__PURE__*/w("primitive",{ref:t,object:o,dispose:null})}),Ft=/*@__PURE__*/P(Qe,{blendFunction:24,density:1.25}),Mt=(e,t)=>e.layers.enable(t.selection.layer),Dt=(e,t)=>e.layers.disable(t.selection.layer),kt=/*@__PURE__*/B(function({selection:e=[],selectionLayer:t=10,lights:o=[],inverted:r=!1,ignoreBackground:a=!1,luminanceThreshold:n,luminanceSmoothing:i,intensity:s,width:l,height:p,kernelSize:_,mipmapBlur:S,...g},d){o.length===0&&console.warn("SelectiveBloom requires lights to work.");const m=V(c=>c.invalidate),{scene:v,camera:x}=M(D),f=z(()=>{const c=new et(v,x,{blendFunction:0,luminanceThreshold:n,luminanceSmoothing:i,intensity:s,width:l,height:p,kernelSize:_,mipmapBlur:S,...g});return c.inverted=r,c.ignoreBackground=a,c},[v,x,n,i,s,l,p,_,S,r,a,g]),u=M(H);return A(()=>{if(!u&&e)return f.selection.set(Array.isArray(e)?e.map(k):[k(e)]),m(),()=>{f.selection.clear(),m()}},[f,e,u,m]),A(()=>{f.selection.layer=t,m()},[f,m,t]),A(()=>{if(o&&o.length>0)return o.forEach(c=>Mt(k(c),f)),m(),()=>{o.forEach(c=>Dt(k(c),f)),m()}},[f,m,o,t]),A(()=>{if(u&&u.enabled&&u.selected?.length)return f.selection.set(u.selected),m(),()=>{f.selection.clear(),m()}},[u,f.selection,m]),/*@__PURE__*/w("primitive",{ref:d,object:f,dispose:null})}),Gt=/*@__PURE__*/P(tt),It=/*@__PURE__*/B(function(e,t){const{camera:o,normalPass:r,downSamplingPass:a,resolutionScale:n}=M(D),i=z(()=>r===null&&a===null?(console.error("Please enable the NormalPass in the EffectComposer in order to use SSAO."),{}):new ot(o,r&&!a?r.texture:null,{blendFunction:21,samples:30,rings:4,distanceThreshold:1,distanceFalloff:0,rangeThreshold:.5,rangeFalloff:.1,luminanceInfluence:.9,radius:20,bias:.5,intensity:1,color:void 0,normalDepthBuffer:a?a.texture:null,resolutionScale:n??1,depthAwareUpsampling:!0,...e}),[o,a,r,n]);return /*@__PURE__*/w("primitive",{ref:t,object:i,dispose:null})}),Lt=/*@__PURE__*/P(at),Nt=/*@__PURE__*/P(rt),jt={fragmentShader:`
|
|
386
|
-
uniform int rampType;
|
|
387
|
-
|
|
388
|
-
uniform vec2 rampStart;
|
|
389
|
-
uniform vec2 rampEnd;
|
|
390
|
-
|
|
391
|
-
uniform vec4 startColor;
|
|
392
|
-
uniform vec4 endColor;
|
|
393
|
-
|
|
394
|
-
uniform float rampBias;
|
|
395
|
-
uniform float rampGain;
|
|
396
|
-
|
|
397
|
-
uniform bool rampMask;
|
|
398
|
-
uniform bool rampInvert;
|
|
399
|
-
|
|
400
|
-
float getBias(float time, float bias) {
|
|
401
|
-
return time / (((1.0 / bias) - 2.0) * (1.0 - time) + 1.0);
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
float getGain(float time, float gain) {
|
|
405
|
-
if (time < 0.5)
|
|
406
|
-
return getBias(time * 2.0, gain) / 2.0;
|
|
407
|
-
else
|
|
408
|
-
return getBias(time * 2.0 - 1.0, 1.0 - gain) / 2.0 + 0.5;
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
|
|
412
|
-
vec2 centerPixel = uv * resolution;
|
|
413
|
-
vec2 startPixel = rampStart * resolution;
|
|
414
|
-
vec2 endPixel = rampEnd * resolution;
|
|
415
|
-
|
|
416
|
-
float rampAlpha;
|
|
417
|
-
|
|
418
|
-
if (rampType == 1) {
|
|
419
|
-
vec2 fuv = centerPixel / resolution.y;
|
|
420
|
-
vec2 suv = startPixel / resolution.y;
|
|
421
|
-
vec2 euv = endPixel / resolution.y;
|
|
422
|
-
|
|
423
|
-
float radius = length(suv - euv);
|
|
424
|
-
float falloff = length(fuv - suv);
|
|
425
|
-
rampAlpha = smoothstep(0.0, radius, falloff);
|
|
426
|
-
} else {
|
|
427
|
-
float radius = length(startPixel - endPixel);
|
|
428
|
-
vec2 direction = normalize(vec2(endPixel.x - startPixel.x, -(startPixel.y - endPixel.y)));
|
|
429
|
-
|
|
430
|
-
float fade = dot(centerPixel - startPixel, direction);
|
|
431
|
-
if (rampType == 2) fade = abs(fade);
|
|
432
|
-
|
|
433
|
-
rampAlpha = smoothstep(0.0, 1.0, fade / radius);
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
rampAlpha = abs((rampInvert ? 1.0 : 0.0) - getBias(rampAlpha, rampBias) * getGain(rampAlpha, rampGain));
|
|
437
|
-
|
|
438
|
-
if (rampMask) {
|
|
439
|
-
vec4 inputBuff = texture2D(inputBuffer, uv);
|
|
440
|
-
outputColor = mix(inputBuff, inputColor, rampAlpha);
|
|
441
|
-
} else {
|
|
442
|
-
outputColor = mix(startColor, endColor, rampAlpha);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
`};var ue=/*@__PURE__*/(e=>(e[e.Linear=0]="Linear",e[e.Radial=1]="Radial",e[e.MirroredLinear=2]="MirroredLinear",e))(ue||{});class pe extends W{constructor({rampType:t=0,rampStart:o=[.5,.5],rampEnd:r=[1,1],startColor:a=[0,0,0,1],endColor:n=[1,1,1,1],rampBias:i=.5,rampGain:s=.5,rampMask:l=!1,rampInvert:p=!1,..._}={}){super("RampEffect",jt.fragmentShader,{..._,uniforms:/*@__PURE__*/new Map([["rampType",new y(t)],["rampStart",new y(o)],["rampEnd",new y(r)],["startColor",new y(a)],["endColor",new y(n)],["rampBias",new y(i)],["rampGain",new y(s)],["rampMask",new y(l)],["rampInvert",new y(p)]])})}}const Ot=/*@__PURE__*/P(pe),Wt=/*@__PURE__*/B(function({textureSrc:e,texture:t,opacity:o=1,...r},a){const n=Ue(we,e);L(()=>{n.colorSpace=Se,n.wrapS=n.wrapT=Y},[n]);const i=z(()=>new nt({...r,texture:n||t}),[r,n,t]);return /*@__PURE__*/w("primitive",{ref:a,object:i,"blendMode-opacity-value":o,dispose:null})}),Xt=/*@__PURE__*/P(st),qt=/*@__PURE__*/P(it),Ht=/*@__PURE__*/P(lt),Zt=/*@__PURE__*/B(function({lut:e,tetrahedralInterpolation:t,...o},r){const a=z(()=>new ct(e,o),[e,o]),n=V(i=>i.invalidate);return L(()=>{t&&(a.tetrahedralInterpolation=t),e&&(a.lut=e),n()},[a,n,e,t]),/*@__PURE__*/w("primitive",{ref:r,object:a,dispose:null})}),$t=/*@__PURE__*/P(ft,{blendFunction:0}),Kt={fragmentShader:`
|
|
446
|
-
|
|
447
|
-
// original shader by Evan Wallace
|
|
448
|
-
|
|
449
|
-
#define MAX_ITERATIONS 100
|
|
450
|
-
|
|
451
|
-
uniform float blur;
|
|
452
|
-
uniform float taper;
|
|
453
|
-
uniform vec2 start;
|
|
454
|
-
uniform vec2 end;
|
|
455
|
-
uniform vec2 direction;
|
|
456
|
-
uniform int samples;
|
|
457
|
-
|
|
458
|
-
float random(vec3 scale, float seed) {
|
|
459
|
-
/* use the fragment position for a different seed per-pixel */
|
|
460
|
-
return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {
|
|
464
|
-
vec4 color = vec4(0.0);
|
|
465
|
-
float total = 0.0;
|
|
466
|
-
vec2 startPixel = vec2(start.x * resolution.x, start.y * resolution.y);
|
|
467
|
-
vec2 endPixel = vec2(end.x * resolution.x, end.y * resolution.y);
|
|
468
|
-
float f_samples = float(samples);
|
|
469
|
-
float half_samples = f_samples / 2.0;
|
|
470
|
-
|
|
471
|
-
// use screen diagonal to normalize blur radii
|
|
472
|
-
float maxScreenDistance = distance(vec2(0.0), resolution); // diagonal distance
|
|
473
|
-
float gradientRadius = taper * (maxScreenDistance);
|
|
474
|
-
float blurRadius = blur * (maxScreenDistance / 16.0);
|
|
475
|
-
|
|
476
|
-
/* randomize the lookup values to hide the fixed number of samples */
|
|
477
|
-
float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);
|
|
478
|
-
vec2 normal = normalize(vec2(startPixel.y - endPixel.y, endPixel.x - startPixel.x));
|
|
479
|
-
float radius = smoothstep(0.0, 1.0, abs(dot(uv * resolution - startPixel, normal)) / gradientRadius) * blurRadius;
|
|
480
|
-
|
|
481
|
-
#pragma unroll_loop_start
|
|
482
|
-
for (int i = 0; i <= MAX_ITERATIONS; i++) {
|
|
483
|
-
if (i >= samples) { break; } // return early if over sample count
|
|
484
|
-
float f_i = float(i);
|
|
485
|
-
float s_i = -half_samples + f_i;
|
|
486
|
-
float percent = (s_i + offset - 0.5) / half_samples;
|
|
487
|
-
float weight = 1.0 - abs(percent);
|
|
488
|
-
vec4 sample_i = texture2D(inputBuffer, uv + normalize(direction) / resolution * percent * radius);
|
|
489
|
-
/* switch to pre-multiplied alpha to correctly blur transparent images */
|
|
490
|
-
sample_i.rgb *= sample_i.a;
|
|
491
|
-
color += sample_i * weight;
|
|
492
|
-
total += weight;
|
|
493
|
-
}
|
|
494
|
-
#pragma unroll_loop_end
|
|
495
|
-
|
|
496
|
-
outputColor = color / total;
|
|
497
|
-
|
|
498
|
-
/* switch back from pre-multiplied alpha */
|
|
499
|
-
outputColor.rgb /= outputColor.a + 0.00001;
|
|
500
|
-
}
|
|
501
|
-
`};class me extends W{constructor({blendFunction:t=23,blur:o=.15,taper:r=.5,start:a=[.5,0],end:n=[.5,1],samples:i=10,direction:s=[1,1]}={}){super("TiltShiftEffect",Kt.fragmentShader,{blendFunction:t,attributes:2,uniforms:/*@__PURE__*/new Map([["blur",new y(o)],["taper",new y(r)],["start",new y(a)],["end",new y(n)],["samples",new y(i)],["direction",new y(s)]])})}}const Yt=/*@__PURE__*/P(me,{blendFunction:23}),Jt=`
|
|
502
|
-
uniform sampler2D uCharacters;
|
|
503
|
-
uniform float uCharactersCount;
|
|
504
|
-
uniform float uCellSize;
|
|
505
|
-
uniform bool uInvert;
|
|
506
|
-
uniform vec3 uColor;
|
|
507
|
-
|
|
508
|
-
const vec2 SIZE = vec2(16.);
|
|
509
|
-
|
|
510
|
-
vec3 greyscale(vec3 color, float strength) {
|
|
511
|
-
float g = dot(color, vec3(0.299, 0.587, 0.114));
|
|
512
|
-
return mix(color, vec3(g), strength);
|
|
1
|
+
import { applyProps as e, createPortal as t, extend as n, useFrame as r, useLoader as i, useThree as a } from "@react-three/fiber";
|
|
2
|
+
import { BloomEffect as o, BrightnessContrastEffect as s, ChromaticAberrationEffect as c, ColorAverageEffect as l, ColorDepthEffect as u, CopyPass as d, DepthDownsamplingPass as f, DepthEffect as p, DepthOfFieldEffect as m, DepthPickingPass as h, DotScreenEffect as g, Effect as _, EffectComposer as v, EffectPass as y, FXAAEffect as b, GlitchEffect as x, GlitchMode as S, GodRaysEffect as C, GridEffect as w, HueSaturationEffect as T, LUT3DEffect as E, MaskFunction as D, NoiseEffect as O, NormalPass as ee, OutlineEffect as te, Pass as ne, PixelationEffect as re, RenderPass as ie, SMAAEffect as ae, SSAOEffect as oe, ScanlineEffect as se, SelectiveBloomEffect as ce, SepiaEffect as le, ShockWaveEffect as ue, TextureEffect as de, TiltShiftEffect as fe, ToneMappingEffect as pe, VignetteEffect as me } from "postprocessing";
|
|
3
|
+
import { createContext as he, memo as ge, use as k, useCallback as _e, useContext as A, useEffect as j, useImperativeHandle as M, useLayoutEffect as N, useMemo as P, useRef as F, useState as I } from "react";
|
|
4
|
+
import { CanvasTexture as ve, Color as L, HalfFloatType as ye, Mesh as be, NearestFilter as R, NoToneMapping as xe, RepeatWrapping as z, SRGBColorSpace as Se, Texture as Ce, TextureLoader as we, Uniform as B, Vector2 as V, Vector3 as H } from "three";
|
|
5
|
+
import { Fragment as Te, jsx as U, jsxs as W } from "react/jsx-runtime";
|
|
6
|
+
import { easing as Ee } from "maath";
|
|
7
|
+
import { N8AOPostPass as De } from "n8ao";
|
|
8
|
+
//#region src/EffectComposer.tsx
|
|
9
|
+
var G = /* @__PURE__ */ he(null), Oe = (e) => (e.getAttributes() & 2) == 2;
|
|
10
|
+
function ke(e) {
|
|
11
|
+
let t = /* @__PURE__ */ new WeakMap();
|
|
12
|
+
return {
|
|
13
|
+
acquire(n, r) {
|
|
14
|
+
let i = t.get(n);
|
|
15
|
+
i ? (i.count++, i.forcedValue = r) : t.set(n, {
|
|
16
|
+
count: 1,
|
|
17
|
+
original: n[e],
|
|
18
|
+
forcedValue: r
|
|
19
|
+
});
|
|
20
|
+
},
|
|
21
|
+
release(n) {
|
|
22
|
+
let r = t.get(n);
|
|
23
|
+
r && --r.count <= 0 && (n[e] === r.forcedValue && (n[e] = r.original), t.delete(n));
|
|
24
|
+
}
|
|
25
|
+
};
|
|
513
26
|
}
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
27
|
+
var Ae = /* @__PURE__ */ ke("autoClear"), je = /* @__PURE__ */ ke("toneMapping");
|
|
28
|
+
function Me(e, t) {
|
|
29
|
+
let n = [];
|
|
30
|
+
for (let r = 0; r < e.length; r++) {
|
|
31
|
+
let i = e[r];
|
|
32
|
+
if (i instanceof _) {
|
|
33
|
+
let a = [i];
|
|
34
|
+
if (!Oe(i)) {
|
|
35
|
+
let t;
|
|
36
|
+
for (; (t = e[r + 1]) instanceof _ && !Oe(t);) a.push(t), r++;
|
|
37
|
+
}
|
|
38
|
+
n.push(new y(t, ...a));
|
|
39
|
+
} else i instanceof ne && n.push(i);
|
|
40
|
+
}
|
|
41
|
+
return n;
|
|
517
42
|
}
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
43
|
+
var Ne = /* @__PURE__ */ ge(function({ children: e, camera: t, scene: n, resolutionScale: i, enabled: o = !0, renderPriority: s = 1, autoClear: c = !0, depthBuffer: l, enableNormalPass: u, stencilBuffer: d, multisampling: p = 8, frameBufferType: m = ye, ref: h }) {
|
|
44
|
+
let { gl: g, scene: y, camera: b, size: x } = a(), S = n || y, C = t || b, [w, T] = I(null);
|
|
45
|
+
j(() => {
|
|
46
|
+
Ae.acquire(g, !1);
|
|
47
|
+
let e = new v(g, {
|
|
48
|
+
depthBuffer: l,
|
|
49
|
+
stencilBuffer: d,
|
|
50
|
+
multisampling: p,
|
|
51
|
+
frameBufferType: m
|
|
52
|
+
});
|
|
53
|
+
e.addPass(new ie(S, C));
|
|
54
|
+
let t = null, n = null;
|
|
55
|
+
return u && (t = new ee(S, C), t.enabled = !1, e.addPass(t), i !== void 0 && (n = new f({
|
|
56
|
+
normalBuffer: t.texture,
|
|
57
|
+
resolutionScale: i
|
|
58
|
+
}), n.enabled = !1, e.addPass(n))), e.setSize(x.width, x.height), T({
|
|
59
|
+
composer: e,
|
|
60
|
+
normalPass: t,
|
|
61
|
+
downSamplingPass: n
|
|
62
|
+
}), () => {
|
|
63
|
+
e.dispose(), Ae.release(g);
|
|
64
|
+
};
|
|
65
|
+
}, [
|
|
66
|
+
C,
|
|
67
|
+
g,
|
|
68
|
+
l,
|
|
69
|
+
d,
|
|
70
|
+
p,
|
|
71
|
+
m,
|
|
72
|
+
S,
|
|
73
|
+
u,
|
|
74
|
+
i
|
|
75
|
+
]), j(() => {
|
|
76
|
+
w?.composer.setSize(x.width, x.height);
|
|
77
|
+
}, [w, x]), r((e, t) => {
|
|
78
|
+
if (!o || !w) return;
|
|
79
|
+
let { composer: n } = w, r = g.autoClear;
|
|
80
|
+
g.autoClear = c, d && !c && g.clearStencil(), n.render(t), g.autoClear = r;
|
|
81
|
+
}, o ? s : 0);
|
|
82
|
+
let E = F(null);
|
|
83
|
+
N(() => {
|
|
84
|
+
if (!w) return;
|
|
85
|
+
let { composer: e, normalPass: t, downSamplingPass: n } = w, r = [], i = E.current.__r3f;
|
|
86
|
+
if (i) {
|
|
87
|
+
let e = i.children.map((e) => e.object).filter((e) => e instanceof _ || e instanceof ne);
|
|
88
|
+
r.push(...Me(e, C));
|
|
89
|
+
}
|
|
90
|
+
for (let t of r) e.addPass(t);
|
|
91
|
+
return r.length && (t && (t.enabled = !0), n && (n.enabled = !0)), () => {
|
|
92
|
+
for (let t of r) e.removePass(t);
|
|
93
|
+
t && (t.enabled = !1), n && (n.enabled = !1);
|
|
94
|
+
};
|
|
95
|
+
}, [
|
|
96
|
+
w,
|
|
97
|
+
e,
|
|
98
|
+
C
|
|
99
|
+
]), j(() => (je.acquire(g, xe), g.toneMapping = xe, () => {
|
|
100
|
+
je.release(g);
|
|
101
|
+
}), [g]);
|
|
102
|
+
let D = P(() => w ? {
|
|
103
|
+
composer: w.composer,
|
|
104
|
+
normalPass: w.normalPass,
|
|
105
|
+
downSamplingPass: w.downSamplingPass,
|
|
106
|
+
resolutionScale: i,
|
|
107
|
+
camera: C,
|
|
108
|
+
scene: S
|
|
109
|
+
} : null, [
|
|
110
|
+
w,
|
|
111
|
+
i,
|
|
112
|
+
C,
|
|
113
|
+
S
|
|
114
|
+
]);
|
|
115
|
+
return M(h, () => w?.composer, [w]), D ? /* @__PURE__ */ U(G.Provider, {
|
|
116
|
+
value: D,
|
|
117
|
+
children: /* @__PURE__ */ U("group", {
|
|
118
|
+
ref: E,
|
|
119
|
+
children: e
|
|
120
|
+
})
|
|
121
|
+
}) : null;
|
|
122
|
+
}), K = /* @__PURE__ */ he(null);
|
|
123
|
+
function Pe({ children: e, enabled: t = !0 }) {
|
|
124
|
+
let [n, r] = I([]), i = P(() => ({
|
|
125
|
+
selected: n,
|
|
126
|
+
select: r,
|
|
127
|
+
enabled: t
|
|
128
|
+
}), [
|
|
129
|
+
n,
|
|
130
|
+
r,
|
|
131
|
+
t
|
|
132
|
+
]);
|
|
133
|
+
return /* @__PURE__ */ U(K.Provider, {
|
|
134
|
+
value: i,
|
|
135
|
+
children: e
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
function Fe(e) {
|
|
139
|
+
let t = e;
|
|
140
|
+
return !!(t.isMesh || t.isLine || t.isPoints);
|
|
141
|
+
}
|
|
142
|
+
function Ie({ enabled: e = !1, children: t, ...n }) {
|
|
143
|
+
let r = F(null), i = k(K)?.select, a = F([]);
|
|
144
|
+
return j(() => {
|
|
145
|
+
if (!i) return;
|
|
146
|
+
let t = [];
|
|
147
|
+
e && r.current.traverse((e) => {
|
|
148
|
+
Fe(e) && t.push(e);
|
|
149
|
+
});
|
|
150
|
+
let n = a.current;
|
|
151
|
+
a.current = t, i((e) => {
|
|
152
|
+
let r = new Set(e), i = new Set(t), a = t.filter((e) => !r.has(e)), o = n.filter((e) => !i.has(e) && r.has(e));
|
|
153
|
+
if (!a.length && !o.length) return e;
|
|
154
|
+
let s = o.length ? new Set(o) : null, c = s ? e.filter((e) => !s.has(e)) : e;
|
|
155
|
+
return a.length ? [...c, ...a] : c;
|
|
156
|
+
});
|
|
157
|
+
}, [
|
|
158
|
+
e,
|
|
159
|
+
t,
|
|
160
|
+
i
|
|
161
|
+
]), j(() => () => {
|
|
162
|
+
if (!i || !a.current.length) return;
|
|
163
|
+
let e = new Set(a.current);
|
|
164
|
+
i((t) => {
|
|
165
|
+
let n = t.filter((t) => !e.has(t));
|
|
166
|
+
return n.length === t.length ? t : n;
|
|
167
|
+
});
|
|
168
|
+
}, [i]), /* @__PURE__ */ U("group", {
|
|
169
|
+
ref: r,
|
|
170
|
+
...n,
|
|
171
|
+
children: t
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region src/util.tsx
|
|
176
|
+
var q = [], J = (e) => typeof e == "object" && e && "current" in e ? e.current : e;
|
|
177
|
+
function Y(e, t, n) {
|
|
178
|
+
let r = a((e) => e.invalidate), i = k(K);
|
|
179
|
+
j(() => {
|
|
180
|
+
e.selection.layer = n, r();
|
|
181
|
+
}, [
|
|
182
|
+
e,
|
|
183
|
+
r,
|
|
184
|
+
n
|
|
185
|
+
]), j(() => {
|
|
186
|
+
if (i) return;
|
|
187
|
+
let n = (Array.isArray(t) ? t.map((e) => J(e)) : [J(t)]).filter((e) => e != null);
|
|
188
|
+
if (n.length) return e.selection.set(n), r(), () => {
|
|
189
|
+
e.selection.clear(), r();
|
|
190
|
+
};
|
|
191
|
+
}, [
|
|
192
|
+
e,
|
|
193
|
+
t,
|
|
194
|
+
i,
|
|
195
|
+
r
|
|
196
|
+
]), j(() => {
|
|
197
|
+
if (i && i.enabled && i.selected?.length) return e.selection.set(i.selected), r(), () => {
|
|
198
|
+
e.selection.clear(), r();
|
|
199
|
+
};
|
|
200
|
+
}, [
|
|
201
|
+
i,
|
|
202
|
+
e.selection,
|
|
203
|
+
r
|
|
204
|
+
]);
|
|
205
|
+
}
|
|
206
|
+
var X = (e) => {
|
|
207
|
+
let t = F(/* @__PURE__ */ new WeakSet());
|
|
208
|
+
j(() => {
|
|
209
|
+
let n = t.current;
|
|
210
|
+
return () => {
|
|
211
|
+
e && typeof e == "object" && !n.has(e) && (n.add(e), e.dispose?.());
|
|
212
|
+
};
|
|
213
|
+
}, [e]);
|
|
214
|
+
}, Z = (e, t) => {
|
|
215
|
+
let n = e[t];
|
|
216
|
+
return P(() => typeof n == "number" ? new V(n, n) : n ? new V(...n) : new V(), [n]);
|
|
217
|
+
}, Le = 0, Re = /* @__PURE__ */ new WeakMap(), ze = /* @__PURE__ */ new WeakMap(), Be = 0;
|
|
218
|
+
function Ve(e) {
|
|
219
|
+
let t = ze.get(e);
|
|
220
|
+
return t === void 0 && (t = Be++, ze.set(e, t)), t;
|
|
221
|
+
}
|
|
222
|
+
function Q(e, t) {
|
|
223
|
+
if (typeof e != "object" || !e) return e;
|
|
224
|
+
if (t.has(e)) return "[Circular]";
|
|
225
|
+
if (ArrayBuffer.isView(e) || e instanceof ArrayBuffer) return Ve(e);
|
|
226
|
+
if (t.add(e), Array.isArray(e)) return e.map((e) => Q(e, t));
|
|
227
|
+
let n = {};
|
|
228
|
+
for (let r of Object.keys(e).sort()) n[r] = Q(e[r], t);
|
|
229
|
+
return n;
|
|
230
|
+
}
|
|
231
|
+
function He(e) {
|
|
232
|
+
return JSON.stringify(Q(e, /* @__PURE__ */ new WeakSet()));
|
|
233
|
+
}
|
|
234
|
+
function $(e, t) {
|
|
235
|
+
return function({ ref: r, blendFunction: i = t?.blendFunction, opacity: o = t?.opacity, ...s }) {
|
|
236
|
+
let c = Re.get(e);
|
|
237
|
+
if (!c) {
|
|
238
|
+
let t = `@react-three/postprocessing/${e.name}-${Le++}`;
|
|
239
|
+
n({ [t]: e }), Re.set(e, c = t);
|
|
240
|
+
}
|
|
241
|
+
let l = a((e) => e.camera), u = P(() => [...t?.args ?? [], ...s.args ?? [{
|
|
242
|
+
...t,
|
|
243
|
+
...s
|
|
244
|
+
}]], [He(s)]);
|
|
245
|
+
return /* @__PURE__ */ U(c, {
|
|
246
|
+
camera: l,
|
|
247
|
+
"blendMode-blendFunction": i,
|
|
248
|
+
"blendMode-opacity-value": o,
|
|
249
|
+
...s,
|
|
250
|
+
args: u,
|
|
251
|
+
ref: r
|
|
252
|
+
});
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
//#endregion
|
|
256
|
+
//#region src/effects/ASCII.tsx
|
|
257
|
+
var Ue = "\n uniform sampler2D uCharacters;\n uniform float uCharactersCount;\n uniform float uCellSize;\n uniform bool uInvert;\n uniform vec3 uColor;\n\n const vec2 SIZE = vec2(16.);\n\n vec3 greyscale(vec3 color, float strength) {\n float g = dot(color, vec3(0.299, 0.587, 0.114));\n return mix(color, vec3(g), strength);\n }\n\n vec3 greyscale(vec3 color) {\n return greyscale(color, 1.0);\n }\n\n void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {\n vec2 cell = resolution / uCellSize;\n vec2 grid = 1.0 / cell;\n vec2 pixelizedUV = grid * (0.5 + floor(uv / grid));\n vec4 pixelized = texture2D(inputBuffer, pixelizedUV);\n float greyscaled = greyscale(pixelized.rgb).r;\n\n if (uInvert) {\n greyscaled = 1.0 - greyscaled;\n }\n\n float characterIndex = floor((uCharactersCount - 1.0) * greyscaled);\n vec2 characterPosition = vec2(mod(characterIndex, SIZE.x), floor(characterIndex / SIZE.y));\n vec2 offset = vec2(characterPosition.x, -characterPosition.y) / SIZE;\n vec2 charUV = mod(uv * (cell / SIZE), 1.0 / SIZE) - vec2(0., 1.0 / SIZE) + offset;\n vec4 asciiCharacter = texture2D(uCharacters, charUV);\n\n asciiCharacter.rgb = uColor * asciiCharacter.r;\n asciiCharacter.a = pixelized.a;\n outputColor = asciiCharacter;\n }\n", We = class extends _ {
|
|
258
|
+
constructor({ font: e = "arial", characters: t = " .:,'-^=*+?!|0#X%WM@", fontSize: n = 54, cellSize: r = 16, color: i = "#ffffff", invert: a = !1 } = {}) {
|
|
259
|
+
let o = /* @__PURE__ */ new Map([
|
|
260
|
+
["uCharacters", new B(new Ce())],
|
|
261
|
+
["uCellSize", new B(r)],
|
|
262
|
+
["uCharactersCount", new B(t.length)],
|
|
263
|
+
["uColor", new B(new L(i))],
|
|
264
|
+
["uInvert", new B(a)]
|
|
265
|
+
]);
|
|
266
|
+
super("ASCIIEffect", Ue, { uniforms: o });
|
|
267
|
+
let s = this.uniforms.get("uCharacters");
|
|
268
|
+
s && (s.value = this.createCharactersTexture(t, e, n));
|
|
269
|
+
}
|
|
270
|
+
createCharactersTexture(e, t, n) {
|
|
271
|
+
let r = document.createElement("canvas"), i = 1024;
|
|
272
|
+
r.width = r.height = i;
|
|
273
|
+
let a = new ve(r, void 0, z, z, R, R), o = r.getContext("2d");
|
|
274
|
+
if (!o) throw Error("Context not available");
|
|
275
|
+
o.clearRect(0, 0, i, i), o.font = `${n}px ${t}`, o.textAlign = "center", o.textBaseline = "middle", o.fillStyle = "#fff";
|
|
276
|
+
for (let t = 0; t < e.length; t++) {
|
|
277
|
+
let n = e[t], r = t % 16, i = Math.floor(t / 16);
|
|
278
|
+
o.fillText(n, r * 64 + 64 / 2, i * 64 + 64 / 2);
|
|
279
|
+
}
|
|
280
|
+
return a.needsUpdate = !0, a;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
function Ge({ font: e = "arial", characters: t = " .:,'-^=*+?!|0#X%WM@", fontSize: n = 54, cellSize: r = 16, color: i = "#ffffff", invert: a = !1, ref: o }) {
|
|
284
|
+
let s = P(() => new We({
|
|
285
|
+
characters: t,
|
|
286
|
+
font: e,
|
|
287
|
+
fontSize: n,
|
|
288
|
+
cellSize: r,
|
|
289
|
+
color: i,
|
|
290
|
+
invert: a
|
|
291
|
+
}), [
|
|
292
|
+
t,
|
|
293
|
+
n,
|
|
294
|
+
r,
|
|
295
|
+
i,
|
|
296
|
+
a,
|
|
297
|
+
e
|
|
298
|
+
]);
|
|
299
|
+
return X(s), /* @__PURE__ */ U("primitive", {
|
|
300
|
+
ref: o,
|
|
301
|
+
object: s
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/effects/DepthOfField.tsx
|
|
306
|
+
function Ke({ ref: e, blendFunction: t, worldFocusDistance: n, worldFocusRange: r, focusDistance: i, focusRange: a, focalLength: o, bokehScale: s, resolutionScale: c, resolutionX: l, resolutionY: u, width: d, height: f, target: p, depthTexture: h, ...g }) {
|
|
307
|
+
let { camera: _ } = k(G), v = p != null, y = P(() => {
|
|
308
|
+
let e = new m(_, {
|
|
309
|
+
blendFunction: t,
|
|
310
|
+
worldFocusDistance: n,
|
|
311
|
+
worldFocusRange: r,
|
|
312
|
+
focusDistance: i,
|
|
313
|
+
focusRange: a,
|
|
314
|
+
focalLength: o,
|
|
315
|
+
bokehScale: s,
|
|
316
|
+
resolutionScale: c,
|
|
317
|
+
resolutionX: l,
|
|
318
|
+
resolutionY: u,
|
|
319
|
+
width: d,
|
|
320
|
+
height: f
|
|
321
|
+
});
|
|
322
|
+
v && (e.target = new H()), h && e.setDepthTexture(h.texture, h.packing);
|
|
323
|
+
let p = e.maskPass;
|
|
324
|
+
return p.maskFunction = D.MULTIPLY_RGB_SET_ALPHA, e;
|
|
325
|
+
}, [
|
|
326
|
+
_,
|
|
327
|
+
t,
|
|
328
|
+
n,
|
|
329
|
+
r,
|
|
330
|
+
i,
|
|
331
|
+
a,
|
|
332
|
+
o,
|
|
333
|
+
s,
|
|
334
|
+
c,
|
|
335
|
+
l,
|
|
336
|
+
u,
|
|
337
|
+
d,
|
|
338
|
+
f,
|
|
339
|
+
v,
|
|
340
|
+
h
|
|
341
|
+
]);
|
|
342
|
+
return X(y), /* @__PURE__ */ U("primitive", {
|
|
343
|
+
...g,
|
|
344
|
+
object: y,
|
|
345
|
+
ref: e,
|
|
346
|
+
target: p
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
//#endregion
|
|
350
|
+
//#region src/effects/Autofocus.tsx
|
|
351
|
+
function qe(e) {
|
|
352
|
+
let t = !1, n = e.dispose.bind(e);
|
|
353
|
+
return e.dispose = () => {
|
|
354
|
+
t || (t = !0, n());
|
|
355
|
+
}, e;
|
|
356
|
+
}
|
|
357
|
+
function Je({ target: e = void 0, mouse: n = !1, debug: i = void 0, manual: o = !1, smoothTime: s = .25, ref: c, ...l }) {
|
|
358
|
+
let u = F(null), f = F(null), p = F(null), m = a(({ scene: e }) => e), g = a(({ pointer: e }) => e), { composer: _, camera: v } = A(G), [y] = I(() => qe(new h())), [b] = I(() => qe(new d()));
|
|
359
|
+
j(() => (_.addPass(y), _.addPass(b), () => {
|
|
360
|
+
_.removePass(y), _.removePass(b);
|
|
361
|
+
}), [
|
|
362
|
+
_,
|
|
363
|
+
y,
|
|
364
|
+
b
|
|
365
|
+
]), j(() => () => {
|
|
366
|
+
y.dispose(), b.dispose();
|
|
367
|
+
}, [y, b]);
|
|
368
|
+
let [x] = I(() => new H(0, 0, 0)), [S] = I(() => new H(0, 0, 0)), C = _e(async (e, t) => (S.x = e, S.y = t, S.z = await y.readDepth(S), S.z = S.z * 2 - 1, 1 - S.z > 1e-7 && S.unproject(v)), [
|
|
369
|
+
S,
|
|
370
|
+
y,
|
|
371
|
+
v
|
|
372
|
+
]), w = _e(async (t, r = !0) => {
|
|
373
|
+
if (e) x.set(...e);
|
|
374
|
+
else {
|
|
375
|
+
let { x: e, y: t } = n ? g : {
|
|
376
|
+
x: 0,
|
|
377
|
+
y: 0
|
|
378
|
+
}, r = await C(e, t);
|
|
379
|
+
r && x.copy(r);
|
|
380
|
+
}
|
|
381
|
+
r && u.current?.target && (s > 0 && t > 0 ? Ee.damp3(u.current.target, x, s, t) : u.current.target.copy(x));
|
|
382
|
+
}, [
|
|
383
|
+
e,
|
|
384
|
+
x,
|
|
385
|
+
n,
|
|
386
|
+
C,
|
|
387
|
+
s,
|
|
388
|
+
g
|
|
389
|
+
]);
|
|
390
|
+
r(async (e, t) => {
|
|
391
|
+
o || w(t), f.current && f.current.position.copy(x), p.current && u.current?.target && p.current.position.copy(u.current.target);
|
|
392
|
+
});
|
|
393
|
+
let T = P(() => ({
|
|
394
|
+
dofRef: u,
|
|
395
|
+
hitpoint: x,
|
|
396
|
+
update: w
|
|
397
|
+
}), [x, w]);
|
|
398
|
+
return M(c, () => T, [T]), /* @__PURE__ */ W(Te, { children: [i ? t(/* @__PURE__ */ W(Te, { children: [/* @__PURE__ */ W("mesh", {
|
|
399
|
+
ref: f,
|
|
400
|
+
children: [/* @__PURE__ */ U("sphereGeometry", { args: [
|
|
401
|
+
i,
|
|
402
|
+
16,
|
|
403
|
+
16
|
|
404
|
+
] }), /* @__PURE__ */ U("meshBasicMaterial", {
|
|
405
|
+
color: "#00ff00",
|
|
406
|
+
opacity: 1,
|
|
407
|
+
transparent: !0,
|
|
408
|
+
depthWrite: !1
|
|
409
|
+
})]
|
|
410
|
+
}), /* @__PURE__ */ W("mesh", {
|
|
411
|
+
ref: p,
|
|
412
|
+
children: [/* @__PURE__ */ U("sphereGeometry", { args: [
|
|
413
|
+
i / 2,
|
|
414
|
+
16,
|
|
415
|
+
16
|
|
416
|
+
] }), /* @__PURE__ */ U("meshBasicMaterial", {
|
|
417
|
+
color: "#00ff00",
|
|
418
|
+
opacity: .5,
|
|
419
|
+
transparent: !0,
|
|
420
|
+
depthWrite: !1
|
|
421
|
+
})]
|
|
422
|
+
})] }), m) : null, /* @__PURE__ */ U(Ke, {
|
|
423
|
+
ref: u,
|
|
424
|
+
...l,
|
|
425
|
+
target: x
|
|
426
|
+
})] });
|
|
427
|
+
}
|
|
428
|
+
//#endregion
|
|
429
|
+
//#region src/effects/Bloom.tsx
|
|
430
|
+
var Ye = /* @__PURE__ */ $(o, { blendFunction: 0 }), Xe = /* @__PURE__ */ $(s);
|
|
431
|
+
//#endregion
|
|
432
|
+
//#region src/effects/ChromaticAberration.tsx
|
|
433
|
+
function Ze({ ref: e, ...t }) {
|
|
434
|
+
let n = Z(t, "offset"), r = P(() => new c({
|
|
435
|
+
...t,
|
|
436
|
+
offset: n
|
|
437
|
+
}), [n, t]);
|
|
438
|
+
return X(r), /* @__PURE__ */ U("primitive", {
|
|
439
|
+
object: r,
|
|
440
|
+
ref: e
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
//#endregion
|
|
444
|
+
//#region src/effects/ColorAverage.tsx
|
|
445
|
+
function Qe({ blendFunction: e = 23, ref: t }) {
|
|
446
|
+
let n = P(() => new l(e), [e]);
|
|
447
|
+
return X(n), /* @__PURE__ */ U("primitive", {
|
|
448
|
+
object: n,
|
|
449
|
+
ref: t
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
//#endregion
|
|
453
|
+
//#region src/effects/ColorDepth.tsx
|
|
454
|
+
var $e = /* @__PURE__ */ $(u), et = /* @__PURE__ */ $(p), tt = /* @__PURE__ */ $(g), nt = /* @__PURE__ */ $(b);
|
|
455
|
+
//#endregion
|
|
456
|
+
//#region src/effects/Glitch.tsx
|
|
457
|
+
function rt({ active: e = !0, ref: t, ...n }) {
|
|
458
|
+
let r = a((e) => e.invalidate), i = Z(n, "delay"), o = Z(n, "duration"), s = Z(n, "strength"), c = Z(n, "chromaticAberrationOffset"), l = P(() => new x({
|
|
459
|
+
...n,
|
|
460
|
+
delay: i,
|
|
461
|
+
duration: o,
|
|
462
|
+
strength: s,
|
|
463
|
+
chromaticAberrationOffset: c
|
|
464
|
+
}), [
|
|
465
|
+
i,
|
|
466
|
+
o,
|
|
467
|
+
n,
|
|
468
|
+
s,
|
|
469
|
+
c
|
|
470
|
+
]);
|
|
471
|
+
return N(() => {
|
|
472
|
+
l.mode = e ? n.mode || S.SPORADIC : S.DISABLED, r();
|
|
473
|
+
}, [
|
|
474
|
+
e,
|
|
475
|
+
l,
|
|
476
|
+
r,
|
|
477
|
+
n.mode
|
|
478
|
+
]), X(l), /* @__PURE__ */ U("primitive", {
|
|
479
|
+
ref: t,
|
|
480
|
+
object: l
|
|
481
|
+
});
|
|
482
|
+
}
|
|
483
|
+
//#endregion
|
|
484
|
+
//#region src/effects/GodRays.tsx
|
|
485
|
+
function it({ ref: e, ...t }) {
|
|
486
|
+
let { camera: n } = A(G), r = P(() => new C(n, J(t.sun), t), [n, t]);
|
|
487
|
+
return N(() => void (r.lightSource = J(t.sun)), [r, t.sun]), X(r), /* @__PURE__ */ U("primitive", {
|
|
488
|
+
ref: e,
|
|
489
|
+
object: r
|
|
490
|
+
});
|
|
491
|
+
}
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/effects/Grid.tsx
|
|
494
|
+
function at({ size: e, ref: t, ...n }) {
|
|
495
|
+
let r = a((e) => e.invalidate), i = P(() => new w(n), [n]);
|
|
496
|
+
return N(() => {
|
|
497
|
+
e && i.setSize(e.width, e.height), r();
|
|
498
|
+
}, [
|
|
499
|
+
i,
|
|
500
|
+
e,
|
|
501
|
+
r
|
|
502
|
+
]), X(i), /* @__PURE__ */ U("primitive", {
|
|
503
|
+
ref: t,
|
|
504
|
+
object: i
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/effects/HueSaturation.tsx
|
|
509
|
+
var ot = /* @__PURE__ */ $(T), st = { fragmentShader: "\n uniform float time;\n uniform vec2 lensPosition;\n uniform vec2 screenRes;\n uniform vec3 colorGain;\n uniform float starPoints;\n uniform float glareSize;\n uniform float flareSize;\n uniform float flareSpeed;\n uniform float flareShape;\n uniform float haloScale;\n uniform float opacity;\n uniform bool animated;\n uniform bool anamorphic;\n uniform bool enabled;\n uniform bool secondaryGhosts;\n uniform bool starBurst;\n uniform float ghostScale;\n uniform bool aditionalStreaks;\n uniform sampler2D lensDirtTexture;\n vec2 vTexCoord;\n \n float rand(float n){return fract(sin(n) * 43758.5453123);}\n\n float noise(float p){\n float fl = floor(p);\n float fc = fract(p);\n return mix(rand(fl),rand(fl + 1.0), fc);\n }\n\n vec3 hsv2rgb(vec3 c)\n {\n vec4 k = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);\n vec3 p = abs(fract(c.xxx + k.xyz) * 6.0 - k.www);\n return c.z * mix(k.xxx, clamp(p - k.xxx, 0.0, 1.0), c.y);\n }\n\n float saturate(float x)\n {\n return clamp(x, 0.,1.);\n }\n\n vec2 rotateUV(vec2 uv, float rotation)\n {\n return vec2(\n cos(rotation) * uv.x + sin(rotation) * uv.y,\n cos(rotation) * uv.y - sin(rotation) * uv.x\n );\n }\n\n // Based on https://www.shadertoy.com/view/XtKfRV\n vec3 drawflare(vec2 p, float intensity, float rnd, float speed, int id)\n {\n float flarehueoffset = (1. / 32.) * float(id) * 0.1;\n float lingrad = distance(vec2(0.), p);\n float expgrad = 1. / exp(lingrad * (fract(rnd) * 0.66 + 0.33));\n vec3 colgrad = hsv2rgb(vec3( fract( (expgrad * 8.) + speed * flareSpeed + flarehueoffset), pow(1.-abs(expgrad*2.-1.), 0.45), 20.0 * expgrad * intensity)); //rainbow spectrum effect\n\n float internalStarPoints;\n\n if(anamorphic){\n internalStarPoints = 1.0;\n } else{\n internalStarPoints = starPoints;\n }\n \n float blades = length(p * flareShape * sin(internalStarPoints * atan(p.x, p.y)));\n \n float comp = pow(1.-saturate(blades), ( anamorphic ? 100. : 12.));\n comp += saturate(expgrad-0.9) * 3.;\n comp = pow(comp * expgrad, 8. + (1.-intensity) * 5.);\n \n if(flareSpeed > 0.0){\n return vec3(comp) * colgrad;\n } else{\n return vec3(comp) * flareSize * 15.;\n }\n }\n\n float dist(vec3 a, vec3 b) { return abs(a.x - b.x) + abs(a.y - b.y) + abs(a.z - b.z); }\n\n vec3 saturate(vec3 x)\n {\n return clamp(x, vec3(0.0), vec3(1.0));\n }\n\n // Based on https://www.shadertoy.com/view/XtKfRV\n float glare(vec2 uv, vec2 pos, float size)\n {\n vec2 main;\n\n if(animated){\n main = rotateUV(uv-pos, time * 0.1); \n } else{\n main = uv-pos; \n }\n \n float ang = atan(main.y, main.x) * (anamorphic ? 1.0 : starPoints);\n float dist = length(main); \n dist = pow(dist, .9);\n \n float f0 = 1.0/(length(uv-pos)*(1.0/size*16.0)+.2);\n\n return f0+f0*(sin((ang))*.2 +.3);\n }\n\n float sdHex(vec2 p){\n p = abs(p);\n vec2 q = vec2(p.x*2.0*0.5773503, p.y + p.x*0.5773503);\n return dot(step(q.xy,q.yx), 1.0-q.yx);\n }\n\n //Based on https://www.shadertoy.com/view/dllSRX\n float fpow(float x, float k){\n return x > k ? pow((x-k)/(1.0-k),2.0) : 0.0;\n }\n\n vec3 renderhex(vec2 uv, vec2 p, float s, vec3 col){\n uv -= p;\n if (abs(uv.x) < 0.2*s && abs(uv.y) < 0.2*s){\n return mix(vec3(0),mix(vec3(0),col,0.1 + fpow(length(uv/s),0.1)*10.0),smoothstep(0.0,0.1,sdHex(uv*20.0/s)));\n }\n return vec3(0);\n }\n\n // Based on https://www.shadertoy.com/view/4sX3Rs\n vec3 LensFlare(vec2 uv, vec2 pos)\n {\n vec2 main = uv-pos;\n vec2 uvd = uv*(length(uv));\n \n float ang = atan(main.x,main.y);\n \n float f0 = .3/(length(uv-pos)*16.0+1.0);\n \n f0 = f0*(sin(noise(sin(ang*3.9-(animated ? time : 0.0) * 0.3) * starPoints))*.2 );\n \n float f1 = max(0.01-pow(length(uv+1.2*pos),1.9),.0)*7.0;\n\n float f2 = max(.9/(10.0+32.0*pow(length(uvd+0.99*pos),2.0)),.0)*0.35;\n float f22 = max(.9/(11.0+32.0*pow(length(uvd+0.85*pos),2.0)),.0)*0.23;\n float f23 = max(.9/(12.0+32.0*pow(length(uvd+0.95*pos),2.0)),.0)*0.6;\n \n vec2 uvx = mix(uv,uvd, 0.1);\n \n float f4 = max(0.01-pow(length(uvx+0.4*pos),2.9),.0)*4.02;\n float f42 = max(0.0-pow(length(uvx+0.45*pos),2.9),.0)*4.1;\n float f43 = max(0.01-pow(length(uvx+0.5*pos),2.9),.0)*4.6;\n \n uvx = mix(uv,uvd,-.4);\n \n float f5 = max(0.01-pow(length(uvx+0.1*pos),5.5),.0)*2.0;\n float f52 = max(0.01-pow(length(uvx+0.2*pos),5.5),.0)*2.0;\n float f53 = max(0.01-pow(length(uvx+0.1*pos),5.5),.0)*2.0;\n \n uvx = mix(uv,uvd, 2.1);\n \n float f6 = max(0.01-pow(length(uvx-0.3*pos),1.61),.0)*3.159;\n float f62 = max(0.01-pow(length(uvx-0.325*pos),1.614),.0)*3.14;\n float f63 = max(0.01-pow(length(uvx-0.389*pos),1.623),.0)*3.12;\n \n vec3 c = vec3(glare(uv,pos, glareSize));\n\n vec2 prot;\n\n if(animated){\n prot = rotateUV(uv - pos, (time * 0.1)); \n } else if(anamorphic){\n prot = rotateUV(uv - pos, 1.570796); \n } else {\n prot = uv - pos;\n }\n\n c += drawflare(prot, (anamorphic ? flareSize * 10. : flareSize), 0.1, time, 1);\n \n c.r+=f1+f2+f4+f5+f6; c.g+=f1+f22+f42+f52+f62; c.b+=f1+f23+f43+f53+f63;\n c = c*1.3 * vec3(length(uvd)+.09);\n c+=vec3(f0);\n \n return c;\n }\n\n vec3 cc(vec3 color, float factor,float factor2)\n {\n float w = color.x+color.y+color.z;\n return mix(color,vec3(w)*factor,w*factor2);\n } \n\n float rnd(vec2 p)\n {\n float f = fract(sin(dot(p, vec2(12.1234, 72.8392) )*45123.2));\n return f; \n }\n\n float rnd(float w)\n {\n float f = fract(sin(w)*1000.);\n return f; \n }\n\n float regShape(vec2 p, int N)\n {\n float f;\n \n float a=atan(p.x,p.y)+.2;\n float b=6.28319/float(N);\n f=smoothstep(.5,.51, cos(floor(.5+a/b)*b-a)*length(p.xy)* 2.0 -ghostScale);\n \n return f;\n }\n\n // Based on https://www.shadertoy.com/view/Xlc3D2\n vec3 circle(vec2 p, float size, float decay, vec3 color, vec3 color2, float dist, vec2 position)\n {\n float l = length(p + position*(dist*2.))+size/2.;\n float l2 = length(p + position*(dist*4.))+size/3.;\n \n float c = max(0.01-pow(length(p + position*dist), size*ghostScale), 0.0)*10.;\n float c1 = max(0.001-pow(l-0.3, 1./40.)+sin(l*20.), 0.0)*3.;\n float c2 = max(0.09/pow(length(p-position*dist/.5)*1., .95), 0.0)/20.;\n float s = max(0.02-pow(regShape(p*5. + position*dist*5. + decay, 6) , 1.), 0.0)*1.5;\n \n color = cos(vec3(0.44, .24, .2)*16. + dist/8.)*0.5+.5;\n vec3 f = c*color;\n f += c1*color;\n f += c2*color; \n f += s*color;\n return f;\n }\n\n vec4 getLensColor(float x){\n return vec4(vec3(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(mix(vec3(0., 0., 0.),\n vec3(0., 0., 0.), smoothstep(0.0, 0.063, x)),\n vec3(0., 0., 0.), smoothstep(0.063, 0.125, x)),\n vec3(0.0, 0., 0.), smoothstep(0.125, 0.188, x)),\n vec3(0.188, 0.131, 0.116), smoothstep(0.188, 0.227, x)),\n vec3(0.31, 0.204, 0.537), smoothstep(0.227, 0.251, x)),\n vec3(0.192, 0.106, 0.286), smoothstep(0.251, 0.314, x)),\n vec3(0.102, 0.008, 0.341), smoothstep(0.314, 0.392, x)),\n vec3(0.086, 0.0, 0.141), smoothstep(0.392, 0.502, x)),\n vec3(1.0, 0.31, 0.0), smoothstep(0.502, 0.604, x)),\n vec3(.1, 0.1, 0.1), smoothstep(0.604, 0.643, x)),\n vec3(1.0, 0.929, 0.0), smoothstep(0.643, 0.761, x)),\n vec3(1.0, 0.086, 0.424), smoothstep(0.761, 0.847, x)),\n vec3(1.0, 0.49, 0.0), smoothstep(0.847, 0.89, x)),\n vec3(0.945, 0.275, 0.475), smoothstep(0.89, 0.941, x)),\n vec3(0.251, 0.275, 0.796), smoothstep(0.941, 1.0, x))),\n 1.0);\n }\n\n float dirtNoise(vec2 p){\n vec2 f = fract(p);\n f = (f * f) * (3.0 - (2.0 * f)); \n float n = dot(floor(p), vec2(1.0, 157.0));\n vec4 a = fract(sin(vec4(n + 0.0, n + 1.0, n + 157.0, n + 158.0)) * 43758.5453123);\n return mix(mix(a.x, a.y, f.x), mix(a.z, a.w, f.x), f.y);\n } \n\n float fbm(vec2 p){\n const mat2 m = mat2(0.80, -0.60, 0.60, 0.80);\n float f = 0.0;\n f += 0.5000*dirtNoise(p); p = m*p*2.02;\n f += 0.2500*dirtNoise(p); p = m*p*2.03;\n f += 0.1250*dirtNoise(p); p = m*p*2.01;\n f += 0.0625*dirtNoise(p);\n return f/0.9375;\n }\n\n vec4 getLensStar(vec2 p){\n vec2 pp = (p - vec2(0.5)) * 2.0;\n float a = atan(pp.y, pp.x);\n vec4 cp = vec4(sin(a * 1.0), length(pp), sin(a * 13.0), sin(a * 53.0));\n float d = sin(clamp(pow(length(vec2(0.5) - p) * 0.5 + haloScale /2., 5.0), 0.0, 1.0) * 3.14159);\n vec3 c = vec3(d) * vec3(fbm(cp.xy * 16.0) * fbm(cp.zw * 9.0) * max(max(max(max(0.5, sin(a * 1.0)), sin(a * 3.0) * 0.8), sin(a * 7.0) * 0.8), sin(a * 9.0) * 10.6));\n c *= vec3(mix(2.0, (sin(length(pp.xy) * 256.0) * 0.5) + 0.5, sin((clamp((length(pp.xy) - 0.875) / 0.1, 0.0, 1.0) + 0.0) * 2.0 * 3.14159) * 1.5) + 0.5) * 0.3275;\n return vec4(vec3(c * 1.0), d); \n }\n\n vec4 getLensDirt(vec2 p){\n p.xy += vec2(fbm(p.yx * 3.0), fbm(p.yx * 2.0)) * 0.0825;\n vec3 o = vec3(mix(0.125, 0.25, max(max(smoothstep(0.1, 0.0, length(p - vec2(0.25))),\n smoothstep(0.4, 0.0, length(p - vec2(0.75)))),\n smoothstep(0.8, 0.0, length(p - vec2(0.875, 0.125))))));\n o += vec3(max(fbm(p * 1.0) - 0.5, 0.0)) * 0.5;\n o += vec3(max(fbm(p * 2.0) - 0.5, 0.0)) * 0.5;\n o += vec3(max(fbm(p * 4.0) - 0.5, 0.0)) * 0.25;\n o += vec3(max(fbm(p * 8.0) - 0.75, 0.0)) * 1.0;\n o += vec3(max(fbm(p * 16.0) - 0.75, 0.0)) * 0.75;\n o += vec3(max(fbm(p * 64.0) - 0.75, 0.0)) * 0.5;\n return vec4(clamp(o, vec3(0.15), vec3(1.0)), 1.0); \n }\n\n vec4 textureLimited(sampler2D tex, vec2 texCoord){\n if(((texCoord.x < 0.) || (texCoord.y < 0.)) || ((texCoord.x > 1.) || (texCoord.y > 1.))){\n return vec4(0.0);\n }else{\n return texture(tex, texCoord); \n }\n }\n\n vec4 textureDistorted(sampler2D tex, vec2 texCoord, vec2 direction, vec3 distortion) {\n return vec4(textureLimited(tex, (texCoord + (direction * distortion.r))).r,\n textureLimited(tex, (texCoord + (direction * distortion.g))).g,\n textureLimited(tex, (texCoord + (direction * distortion.b))).b,\n 1.0);\n }\n\n // Based on https://www.shadertoy.com/view/4sK3W3\n vec4 getStartBurst(){\n vec2 aspectTexCoord = vec2(1.0) - (((vTexCoord - vec2(0.5)) * vec2(1.0)) + vec2(0.5)); \n vec2 texCoord = vec2(1.0) - vTexCoord; \n vec2 ghostVec = (vec2(0.5) - texCoord) * 0.3 - lensPosition;\n vec2 ghostVecAspectNormalized = normalize(ghostVec * vec2(1.0)) * vec2(1.0);\n vec2 haloVec = normalize(ghostVec) * 0.6;\n vec2 haloVecAspectNormalized = ghostVecAspectNormalized * 0.6;\n vec2 texelSize = vec2(1.0) / vec2(screenRes.xy);\n vec3 distortion = vec3(-(texelSize.x * 1.5), 0.2, texelSize.x * 1.5);\n vec4 c = vec4(0.0);\n for (int i = 0; i < 8; i++) {\n vec2 offset = texCoord + (ghostVec * float(i));\n c += textureDistorted(lensDirtTexture, offset, ghostVecAspectNormalized, distortion) * pow(max(0.0, 1.0 - (length(vec2(0.5) - offset) / length(vec2(0.5)))), 10.0);\n } \n vec2 haloOffset = texCoord + haloVecAspectNormalized; \n return (c * getLensColor((length(vec2(0.5) - aspectTexCoord) / length(vec2(haloScale))))) + \n (textureDistorted(lensDirtTexture, haloOffset, ghostVecAspectNormalized, distortion) * pow(max(0.0, 1.0 - (length(vec2(0.5) - haloOffset) / length(vec2(0.5)))), 10.0));\n } \n\n void mainImage(vec4 inputColor, vec2 uv, out vec4 outputColor)\n {\n vec2 myUV = uv -0.5;\n myUV.y *= screenRes.y/screenRes.x;\n vec2 finalLensPosition = lensPosition * 0.5;\n finalLensPosition.y *= screenRes.y/screenRes.x;\n \n //First Lens flare pass\n vec3 finalColor = LensFlare(myUV, finalLensPosition) * 20.0 * colorGain / 256.;\n\n //Aditional streaks\n if(aditionalStreaks){\n vec3 circColor = vec3(0.9, 0.2, 0.1);\n vec3 circColor2 = vec3(0.3, 0.1, 0.9);\n\n for(float i=0.;i<10.;i++){\n finalColor += circle(myUV, pow(rnd(i*2000.)*2.8, .1)+1.41, 0.0, circColor+i , circColor2+i, rnd(i*20.)*3.+0.2-.5, lensPosition);\n }\n }\n\n //Alternative ghosts\n if(secondaryGhosts){\n vec3 altGhosts = vec3(0);\n altGhosts += renderhex(myUV, -lensPosition*0.25, ghostScale * 1.4, vec3(0.25,0.35,0));\n altGhosts += renderhex(myUV, lensPosition*0.25, ghostScale * 0.5, vec3(1,0.5,0.5));\n altGhosts += renderhex(myUV, lensPosition*0.1, ghostScale * 1.6, vec3(1,1,1));\n altGhosts += renderhex(myUV, lensPosition*1.8, ghostScale * 2.0, vec3(0,0.5,0.75));\n altGhosts += renderhex(myUV, lensPosition*1.25, ghostScale * 0.8, vec3(1,1,0.5));\n altGhosts += renderhex(myUV, -lensPosition*1.25, ghostScale * 5.0, vec3(0.5,0.5,0.25));\n \n //Circular ghosts\n altGhosts += fpow(1.0 - abs(distance(lensPosition*0.8,myUV) - 0.7),0.985)*colorGain / 2100.;\n finalColor += altGhosts;\n }\n \n\n //Starburst \n if(starBurst){\n vTexCoord = myUV + 0.5;\n vec4 lensMod = getLensDirt(myUV);\n float tooBright = 1.0 - (clamp(0.5, 0.0, 0.5) * 2.0); \n float tooDark = clamp(0.5 - 0.5, 0.0, 0.5) * 2.0;\n lensMod += mix(lensMod, pow(lensMod * 2.0, vec4(2.0)) * 0.5, tooBright);\n float lensStarRotationAngle = ((myUV.x + myUV.y)) * (1.0 / 6.0);\n vec2 lensStarTexCoord = (mat2(cos(lensStarRotationAngle), -sin(lensStarRotationAngle), sin(lensStarRotationAngle), cos(lensStarRotationAngle)) * vTexCoord);\n lensMod += getLensStar(lensStarTexCoord) * 2.;\n \n finalColor += clamp((lensMod.rgb * getStartBurst().rgb ), 0.01, 1.0);\n }\n\n //Final composed output\n if(enabled){\n outputColor = vec4(mix(finalColor, vec3(.0), opacity) + inputColor.rgb, inputColor.a);\n } else {\n outputColor = vec4(inputColor);\n }\n }\n " }, ct = class extends _ {
|
|
510
|
+
constructor({ blendFunction: e, enabled: t, glareSize: n, lensPosition: r, screenRes: i, starPoints: a, flareSize: o, flareSpeed: s, flareShape: c, animated: l, anamorphic: u, colorGain: d, lensDirtTexture: f, haloScale: p, secondaryGhosts: m, aditionalStreaks: h, ghostScale: g, opacity: _, starBurst: v }) {
|
|
511
|
+
super("LensFlareEffect", st.fragmentShader, {
|
|
512
|
+
blendFunction: e,
|
|
513
|
+
uniforms: /* @__PURE__ */ new Map([
|
|
514
|
+
["enabled", new B(t)],
|
|
515
|
+
["glareSize", new B(n)],
|
|
516
|
+
["lensPosition", new B(r)],
|
|
517
|
+
["time", new B(0)],
|
|
518
|
+
["screenRes", new B(i)],
|
|
519
|
+
["starPoints", new B(a)],
|
|
520
|
+
["flareSize", new B(o)],
|
|
521
|
+
["flareSpeed", new B(s)],
|
|
522
|
+
["flareShape", new B(c)],
|
|
523
|
+
["animated", new B(l)],
|
|
524
|
+
["anamorphic", new B(u)],
|
|
525
|
+
["colorGain", new B(d)],
|
|
526
|
+
["lensDirtTexture", new B(f)],
|
|
527
|
+
["haloScale", new B(p)],
|
|
528
|
+
["secondaryGhosts", new B(m)],
|
|
529
|
+
["aditionalStreaks", new B(h)],
|
|
530
|
+
["ghostScale", new B(g)],
|
|
531
|
+
["starBurst", new B(v)],
|
|
532
|
+
["opacity", new B(_)]
|
|
533
|
+
])
|
|
534
|
+
});
|
|
535
|
+
}
|
|
536
|
+
update(e, t, n) {
|
|
537
|
+
let r = this.uniforms.get("time");
|
|
538
|
+
r && (r.value += n);
|
|
539
|
+
}
|
|
540
|
+
}, lt = /* @__PURE__ */ $(ct), ut = ({ smoothTime: e = .07, blendFunction: t = 23, enabled: n = !0, glareSize: i = .2, lensPosition: o = new H(-25, 6, -60), screenRes: s = new V(0, 0), starPoints: c = 6, flareSize: l = .01, flareSpeed: u = .01, flareShape: d = .01, animated: f = !0, anamorphic: p = !1, colorGain: m = new L(20, 20, 20), lensDirtTexture: h = null, haloScale: g = .5, secondaryGhosts: _ = !0, aditionalStreaks: v = !0, ghostScale: y = 0, opacity: b = 1, starBurst: x = !1 }) => {
|
|
541
|
+
let S = a(({ viewport: e }) => e), C = a(({ raycaster: e }) => e), { scene: w, camera: T } = A(G), [E] = I(() => new V()), [D] = I(() => new H()), O = F(null);
|
|
542
|
+
return r((t, n) => {
|
|
543
|
+
if (!O?.current) return;
|
|
544
|
+
let r = O.current.uniforms.get("lensPosition"), i = O.current.uniforms.get("opacity");
|
|
545
|
+
if (!r || !i) return;
|
|
546
|
+
let a = 1;
|
|
547
|
+
if (D.copy(o).project(T), D.z > 1) return;
|
|
548
|
+
r.value.x = D.x, r.value.y = D.y, E.x = D.x, E.y = D.y, C.setFromCamera(E, T);
|
|
549
|
+
let { object: s } = C.intersectObjects(w.children, !0)[0] || {};
|
|
550
|
+
s && (s.userData?.lensflare === "no-occlusion" ? a = 0 : s instanceof be && (s.material.uniforms?._transmission?.value > .2 || s.material._transmission && s.material._transmission > .2 ? a = .2 : s.material.transparent && (a = s.material.opacity))), Ee.damp(i, "value", a, e, n);
|
|
551
|
+
}), j(() => {
|
|
552
|
+
if (!O?.current) return;
|
|
553
|
+
let e = O.current.uniforms.get("screenRes");
|
|
554
|
+
e && (e.value.x = S.width, e.value.y = S.height);
|
|
555
|
+
}, [S]), /* @__PURE__ */ U(lt, {
|
|
556
|
+
ref: O,
|
|
557
|
+
blendFunction: t,
|
|
558
|
+
enabled: n,
|
|
559
|
+
glareSize: i,
|
|
560
|
+
lensPosition: o,
|
|
561
|
+
screenRes: s,
|
|
562
|
+
starPoints: c,
|
|
563
|
+
flareSize: l,
|
|
564
|
+
flareSpeed: u,
|
|
565
|
+
flareShape: d,
|
|
566
|
+
animated: f,
|
|
567
|
+
anamorphic: p,
|
|
568
|
+
colorGain: m,
|
|
569
|
+
lensDirtTexture: h,
|
|
570
|
+
haloScale: g,
|
|
571
|
+
secondaryGhosts: _,
|
|
572
|
+
aditionalStreaks: v,
|
|
573
|
+
ghostScale: y,
|
|
574
|
+
opacity: b,
|
|
575
|
+
starBurst: x
|
|
576
|
+
});
|
|
577
|
+
};
|
|
578
|
+
//#endregion
|
|
579
|
+
//#region src/effects/LUT.tsx
|
|
580
|
+
function dt({ lut: e, tetrahedralInterpolation: t, ref: n, ...r }) {
|
|
581
|
+
let i = P(() => new E(e, r), [e, r]), o = a((e) => e.invalidate);
|
|
582
|
+
return N(() => {
|
|
583
|
+
t && (i.tetrahedralInterpolation = t), e && (i.lut = e), o();
|
|
584
|
+
}, [
|
|
585
|
+
i,
|
|
586
|
+
o,
|
|
587
|
+
e,
|
|
588
|
+
t
|
|
589
|
+
]), X(i), /* @__PURE__ */ U("primitive", {
|
|
590
|
+
ref: n,
|
|
591
|
+
object: i
|
|
592
|
+
});
|
|
593
|
+
}
|
|
594
|
+
//#endregion
|
|
595
|
+
//#region src/effects/Noise.tsx
|
|
596
|
+
var ft = /* @__PURE__ */ $(O, { blendFunction: 5 });
|
|
597
|
+
//#endregion
|
|
598
|
+
//#region src/effects/Outline.tsx
|
|
599
|
+
function pt({ selection: e = q, selectionLayer: t = 10, blendFunction: n, patternTexture: r, patternScale: i, edgeStrength: a, pulseSpeed: o, visibleEdgeColor: s, hiddenEdgeColor: c, multisampling: l, resolutionScale: u, resolutionX: d, resolutionY: f, width: p, height: m, kernelSize: h, blur: g, xRay: _, ref: v }) {
|
|
600
|
+
let { scene: y, camera: b } = k(G), x = P(() => new te(y, b, {
|
|
601
|
+
blendFunction: n,
|
|
602
|
+
patternTexture: r,
|
|
603
|
+
patternScale: i,
|
|
604
|
+
edgeStrength: a,
|
|
605
|
+
pulseSpeed: o,
|
|
606
|
+
visibleEdgeColor: s,
|
|
607
|
+
hiddenEdgeColor: c,
|
|
608
|
+
multisampling: l,
|
|
609
|
+
resolutionScale: u,
|
|
610
|
+
resolutionX: d,
|
|
611
|
+
resolutionY: f,
|
|
612
|
+
width: p,
|
|
613
|
+
height: m,
|
|
614
|
+
kernelSize: h,
|
|
615
|
+
blur: g,
|
|
616
|
+
xRay: _
|
|
617
|
+
}), [
|
|
618
|
+
n,
|
|
619
|
+
r,
|
|
620
|
+
i,
|
|
621
|
+
a,
|
|
622
|
+
o,
|
|
623
|
+
s,
|
|
624
|
+
c,
|
|
625
|
+
l,
|
|
626
|
+
u,
|
|
627
|
+
d,
|
|
628
|
+
f,
|
|
629
|
+
p,
|
|
630
|
+
m,
|
|
631
|
+
h,
|
|
632
|
+
g,
|
|
633
|
+
_,
|
|
634
|
+
b,
|
|
635
|
+
y
|
|
636
|
+
]);
|
|
637
|
+
return Y(x, e, t), X(x), /* @__PURE__ */ U("primitive", {
|
|
638
|
+
ref: v,
|
|
639
|
+
object: x
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
//#endregion
|
|
643
|
+
//#region src/effects/Pixelation.tsx
|
|
644
|
+
function mt({ granularity: e = 5, ref: t }) {
|
|
645
|
+
let n = P(() => new re(e), [e]);
|
|
646
|
+
return X(n), /* @__PURE__ */ U("primitive", {
|
|
647
|
+
ref: t,
|
|
648
|
+
object: n
|
|
649
|
+
});
|
|
650
|
+
}
|
|
651
|
+
//#endregion
|
|
652
|
+
//#region src/effects/Ramp.tsx
|
|
653
|
+
var ht = { fragmentShader: "\n uniform int rampType;\n\n uniform vec2 rampStart;\n uniform vec2 rampEnd;\n\n uniform vec4 startColor;\n uniform vec4 endColor;\n\n uniform float rampBias;\n uniform float rampGain;\n\n uniform bool rampMask;\n uniform bool rampInvert;\n\n float getBias(float time, float bias) {\n return time / (((1.0 / bias) - 2.0) * (1.0 - time) + 1.0);\n }\n\n float getGain(float time, float gain) {\n if (time < 0.5)\n return getBias(time * 2.0, gain) / 2.0;\n else\n return getBias(time * 2.0 - 1.0, 1.0 - gain) / 2.0 + 0.5;\n }\n\n void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {\n vec2 centerPixel = uv * resolution;\n vec2 startPixel = rampStart * resolution;\n vec2 endPixel = rampEnd * resolution;\n\n float rampAlpha;\n\n if (rampType == 1) {\n vec2 fuv = centerPixel / resolution.y;\n vec2 suv = startPixel / resolution.y;\n vec2 euv = endPixel / resolution.y;\n\n float radius = length(suv - euv);\n float falloff = length(fuv - suv);\n rampAlpha = smoothstep(0.0, radius, falloff);\n } else {\n float radius = length(startPixel - endPixel);\n vec2 direction = normalize(vec2(endPixel.x - startPixel.x, -(startPixel.y - endPixel.y)));\n\n float fade = dot(centerPixel - startPixel, direction);\n if (rampType == 2) fade = abs(fade);\n\n rampAlpha = smoothstep(0.0, 1.0, fade / radius);\n }\n\n rampAlpha = abs((rampInvert ? 1.0 : 0.0) - getBias(rampAlpha, rampBias) * getGain(rampAlpha, rampGain));\n\n if (rampMask) {\n vec4 inputBuff = texture2D(inputBuffer, uv);\n outputColor = mix(inputBuff, inputColor, rampAlpha);\n } else {\n outputColor = mix(startColor, endColor, rampAlpha);\n }\n }\n " }, gt = /* @__PURE__ */ function(e) {
|
|
654
|
+
return e[e.Linear = 0] = "Linear", e[e.Radial = 1] = "Radial", e[e.MirroredLinear = 2] = "MirroredLinear", e;
|
|
655
|
+
}({}), _t = class extends _ {
|
|
656
|
+
constructor({ rampType: e = 0, rampStart: t = [.5, .5], rampEnd: n = [1, 1], startColor: r = [
|
|
657
|
+
0,
|
|
658
|
+
0,
|
|
659
|
+
0,
|
|
660
|
+
1
|
|
661
|
+
], endColor: i = [
|
|
662
|
+
1,
|
|
663
|
+
1,
|
|
664
|
+
1,
|
|
665
|
+
1
|
|
666
|
+
], rampBias: a = .5, rampGain: o = .5, rampMask: s = !1, rampInvert: c = !1, ...l } = {}) {
|
|
667
|
+
super("RampEffect", ht.fragmentShader, {
|
|
668
|
+
...l,
|
|
669
|
+
uniforms: /* @__PURE__ */ new Map([
|
|
670
|
+
["rampType", new B(e)],
|
|
671
|
+
["rampStart", new B(t)],
|
|
672
|
+
["rampEnd", new B(n)],
|
|
673
|
+
["startColor", new B(r)],
|
|
674
|
+
["endColor", new B(i)],
|
|
675
|
+
["rampBias", new B(a)],
|
|
676
|
+
["rampGain", new B(o)],
|
|
677
|
+
["rampMask", new B(s)],
|
|
678
|
+
["rampInvert", new B(c)]
|
|
679
|
+
])
|
|
680
|
+
});
|
|
681
|
+
}
|
|
682
|
+
}, vt = /* @__PURE__ */ $(_t), yt = /* @__PURE__ */ $(se, {
|
|
683
|
+
blendFunction: 24,
|
|
684
|
+
density: 1.25
|
|
685
|
+
}), bt = (e, t) => e.layers.enable(t.selection.layer), xt = (e, t) => e.layers.disable(t.selection.layer);
|
|
686
|
+
function St({ selection: e = q, selectionLayer: t = 10, lights: n = q, inverted: r = !1, ignoreBackground: i = !1, luminanceThreshold: o, luminanceSmoothing: s, mipmapBlur: c, intensity: l, radius: u, levels: d, kernelSize: f, resolutionScale: p, width: m, height: h, resolutionX: g, resolutionY: _, ref: v }) {
|
|
687
|
+
let { scene: y, camera: b } = k(G), x = a((e) => e.invalidate), S = P(() => {
|
|
688
|
+
let e = new ce(y, b, {
|
|
689
|
+
blendFunction: 0,
|
|
690
|
+
luminanceThreshold: o,
|
|
691
|
+
luminanceSmoothing: s,
|
|
692
|
+
mipmapBlur: c,
|
|
693
|
+
intensity: l,
|
|
694
|
+
radius: u,
|
|
695
|
+
levels: d,
|
|
696
|
+
kernelSize: f,
|
|
697
|
+
resolutionScale: p,
|
|
698
|
+
width: m,
|
|
699
|
+
height: h,
|
|
700
|
+
resolutionX: g,
|
|
701
|
+
resolutionY: _
|
|
702
|
+
});
|
|
703
|
+
return e.inverted = r, e.ignoreBackground = i, e;
|
|
704
|
+
}, [
|
|
705
|
+
y,
|
|
706
|
+
b,
|
|
707
|
+
o,
|
|
708
|
+
s,
|
|
709
|
+
c,
|
|
710
|
+
l,
|
|
711
|
+
u,
|
|
712
|
+
d,
|
|
713
|
+
f,
|
|
714
|
+
p,
|
|
715
|
+
m,
|
|
716
|
+
h,
|
|
717
|
+
g,
|
|
718
|
+
_,
|
|
719
|
+
r,
|
|
720
|
+
i
|
|
721
|
+
]);
|
|
722
|
+
return Y(S, e, t), j(() => {
|
|
723
|
+
if (n.length === 0) {
|
|
724
|
+
console.warn("SelectiveBloom requires lights to work.");
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
let e = n.map((e) => J(e)).filter((e) => e != null);
|
|
728
|
+
if (e.length !== 0) return e.forEach((e) => bt(e, S)), x(), () => {
|
|
729
|
+
e.forEach((e) => xt(e, S)), x();
|
|
730
|
+
};
|
|
731
|
+
}, [
|
|
732
|
+
S,
|
|
733
|
+
x,
|
|
734
|
+
n,
|
|
735
|
+
t
|
|
736
|
+
]), X(S), /* @__PURE__ */ U("primitive", {
|
|
737
|
+
ref: v,
|
|
738
|
+
object: S
|
|
739
|
+
});
|
|
740
|
+
}
|
|
741
|
+
//#endregion
|
|
742
|
+
//#region src/effects/Sepia.tsx
|
|
743
|
+
var Ct = /* @__PURE__ */ $(le), wt = /* @__PURE__ */ $(ue), Tt = /* @__PURE__ */ $(ae);
|
|
744
|
+
//#endregion
|
|
745
|
+
//#region src/effects/SSAO.tsx
|
|
746
|
+
function Et({ ref: e, ...t }) {
|
|
747
|
+
let { camera: n, normalPass: r, downSamplingPass: i, resolutionScale: a } = A(G), o = P(() => r === null && i === null ? (console.error("Please enable the NormalPass in the EffectComposer in order to use SSAO."), {}) : new oe(n, r && !i ? r.texture : null, {
|
|
748
|
+
blendFunction: 21,
|
|
749
|
+
samples: 30,
|
|
750
|
+
rings: 4,
|
|
751
|
+
distanceThreshold: 1,
|
|
752
|
+
distanceFalloff: 0,
|
|
753
|
+
rangeThreshold: .5,
|
|
754
|
+
rangeFalloff: .1,
|
|
755
|
+
luminanceInfluence: .9,
|
|
756
|
+
radius: 20,
|
|
757
|
+
bias: .5,
|
|
758
|
+
intensity: 1,
|
|
759
|
+
color: void 0,
|
|
760
|
+
normalDepthBuffer: i ? i.texture : null,
|
|
761
|
+
resolutionScale: a ?? 1,
|
|
762
|
+
depthAwareUpsampling: !0,
|
|
763
|
+
...t
|
|
764
|
+
}), [
|
|
765
|
+
n,
|
|
766
|
+
i,
|
|
767
|
+
r,
|
|
768
|
+
a
|
|
769
|
+
]);
|
|
770
|
+
return X(o), /* @__PURE__ */ U("primitive", {
|
|
771
|
+
ref: e,
|
|
772
|
+
object: o
|
|
773
|
+
});
|
|
774
|
+
}
|
|
775
|
+
//#endregion
|
|
776
|
+
//#region src/effects/Texture.tsx
|
|
777
|
+
function Dt({ textureSrc: e, texture: t, opacity: n = 1, ref: r, ...a }) {
|
|
778
|
+
let o = i(we, e);
|
|
779
|
+
N(() => {
|
|
780
|
+
o.colorSpace = Se, o.wrapS = o.wrapT = z;
|
|
781
|
+
}, [o]);
|
|
782
|
+
let s = P(() => new de({
|
|
783
|
+
...a,
|
|
784
|
+
texture: o || t
|
|
785
|
+
}), []);
|
|
786
|
+
return X(s), /* @__PURE__ */ U("primitive", {
|
|
787
|
+
ref: r,
|
|
788
|
+
object: s,
|
|
789
|
+
"blendMode-opacity-value": n
|
|
790
|
+
});
|
|
791
|
+
}
|
|
792
|
+
//#endregion
|
|
793
|
+
//#region src/effects/TiltShift.tsx
|
|
794
|
+
var Ot = /* @__PURE__ */ $(fe, { blendFunction: 0 }), kt = { fragmentShader: "\n\n // original shader by Evan Wallace\n\n #define MAX_ITERATIONS 100\n\n uniform float blur;\n uniform float taper;\n uniform vec2 start;\n uniform vec2 end;\n uniform vec2 direction;\n uniform int samples;\n\n float random(vec3 scale, float seed) {\n /* use the fragment position for a different seed per-pixel */\n return fract(sin(dot(gl_FragCoord.xyz + seed, scale)) * 43758.5453 + seed);\n }\n\n void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {\n vec4 color = vec4(0.0);\n float total = 0.0;\n vec2 startPixel = vec2(start.x * resolution.x, start.y * resolution.y);\n vec2 endPixel = vec2(end.x * resolution.x, end.y * resolution.y);\n float f_samples = float(samples);\n float half_samples = f_samples / 2.0;\n\n // use screen diagonal to normalize blur radii\n float maxScreenDistance = distance(vec2(0.0), resolution); // diagonal distance\n float gradientRadius = taper * (maxScreenDistance);\n float blurRadius = blur * (maxScreenDistance / 16.0);\n\n /* randomize the lookup values to hide the fixed number of samples */\n float offset = random(vec3(12.9898, 78.233, 151.7182), 0.0);\n vec2 normal = normalize(vec2(startPixel.y - endPixel.y, endPixel.x - startPixel.x));\n float radius = smoothstep(0.0, 1.0, abs(dot(uv * resolution - startPixel, normal)) / gradientRadius) * blurRadius;\n\n #pragma unroll_loop_start\n for (int i = 0; i <= MAX_ITERATIONS; i++) {\n if (i >= samples) { break; } // return early if over sample count\n float f_i = float(i);\n float s_i = -half_samples + f_i;\n float percent = (s_i + offset - 0.5) / half_samples;\n float weight = 1.0 - abs(percent);\n vec4 sample_i = texture2D(inputBuffer, uv + normalize(direction) / resolution * percent * radius);\n /* switch to pre-multiplied alpha to correctly blur transparent images */\n sample_i.rgb *= sample_i.a;\n color += sample_i * weight;\n total += weight;\n }\n #pragma unroll_loop_end\n\n outputColor = color / total;\n\n /* switch back from pre-multiplied alpha */\n outputColor.rgb /= outputColor.a + 0.00001;\n }\n " }, At = class extends _ {
|
|
795
|
+
constructor({ blendFunction: e = 23, blur: t = .15, taper: n = .5, start: r = [.5, 0], end: i = [.5, 1], samples: a = 10, direction: o = [1, 1] } = {}) {
|
|
796
|
+
super("TiltShiftEffect", kt.fragmentShader, {
|
|
797
|
+
blendFunction: e,
|
|
798
|
+
attributes: 2,
|
|
799
|
+
uniforms: /* @__PURE__ */ new Map([
|
|
800
|
+
["blur", new B(t)],
|
|
801
|
+
["taper", new B(n)],
|
|
802
|
+
["start", new B(r)],
|
|
803
|
+
["end", new B(i)],
|
|
804
|
+
["samples", new B(a)],
|
|
805
|
+
["direction", new B(o)]
|
|
806
|
+
])
|
|
807
|
+
});
|
|
808
|
+
}
|
|
809
|
+
}, jt = /* @__PURE__ */ $(At, { blendFunction: 23 }), Mt = /* @__PURE__ */ $(pe), Nt = /* @__PURE__ */ $(me), Pt = { fragmentShader: "\n uniform float factor;\n\n void mainImage(const in vec4 inputColor, const in vec2 uv, out vec4 outputColor) {\n vec2 vUv = uv;\n float frequency = 6.0 * factor;\n float amplitude = 0.015 * factor;\n float x = vUv.y * frequency + time * 0.7; \n float y = vUv.x * frequency + time * 0.3;\n vUv.x += cos(x + y) * amplitude * cos(y);\n vUv.y += sin(x - y) * amplitude * cos(y);\n vec4 rgba = texture(inputBuffer, vUv);\n outputColor = rgba;\n }\n " }, Ft = class extends _ {
|
|
810
|
+
constructor({ blendFunction: e = 23, factor: t = 0 } = {}) {
|
|
811
|
+
super("WaterEffect", Pt.fragmentShader, {
|
|
812
|
+
blendFunction: e,
|
|
813
|
+
attributes: 2,
|
|
814
|
+
uniforms: /* @__PURE__ */ new Map([["factor", new B(t)]])
|
|
815
|
+
});
|
|
816
|
+
}
|
|
817
|
+
}, It = /* @__PURE__ */ $(Ft, { blendFunction: 23 });
|
|
818
|
+
//#endregion
|
|
819
|
+
//#region src/effects/N8AO.tsx
|
|
820
|
+
function Lt({ halfRes: t, screenSpaceRadius: n, quality: r, depthAwareUpsampling: i = !0, aoRadius: o = 5, aoSamples: s = 16, denoiseSamples: c = 4, denoiseRadius: l = 12, distanceFalloff: u = 1, intensity: d = 1, color: f, renderMode: p = 0, ref: m }) {
|
|
821
|
+
let { camera: h, scene: g } = a(), _ = P(() => new De(g, h), [h, g]);
|
|
822
|
+
return X(_), N(() => {
|
|
823
|
+
e(_.configuration, {
|
|
824
|
+
color: f,
|
|
825
|
+
aoRadius: o,
|
|
826
|
+
distanceFalloff: u,
|
|
827
|
+
intensity: d,
|
|
828
|
+
aoSamples: s,
|
|
829
|
+
denoiseSamples: c,
|
|
830
|
+
denoiseRadius: l,
|
|
831
|
+
screenSpaceRadius: n,
|
|
832
|
+
renderMode: p,
|
|
833
|
+
halfRes: t,
|
|
834
|
+
depthAwareUpsampling: i
|
|
835
|
+
});
|
|
836
|
+
}, [
|
|
837
|
+
n,
|
|
838
|
+
f,
|
|
839
|
+
o,
|
|
840
|
+
u,
|
|
841
|
+
d,
|
|
842
|
+
s,
|
|
843
|
+
c,
|
|
844
|
+
l,
|
|
845
|
+
p,
|
|
846
|
+
t,
|
|
847
|
+
i,
|
|
848
|
+
_
|
|
849
|
+
]), N(() => {
|
|
850
|
+
r && _.setQualityMode(r.charAt(0).toUpperCase() + r.slice(1));
|
|
851
|
+
}, [_, r]), /* @__PURE__ */ U("primitive", {
|
|
852
|
+
ref: m,
|
|
853
|
+
object: _
|
|
854
|
+
});
|
|
539
855
|
}
|
|
540
|
-
|
|
541
|
-
|
|
856
|
+
//#endregion
|
|
857
|
+
export { Ge as ASCII, Je as Autofocus, Ye as Bloom, Xe as BrightnessContrast, Ze as ChromaticAberration, Qe as ColorAverage, $e as ColorDepth, et as Depth, Ke as DepthOfField, tt as DotScreen, q as EMPTY_ARRAY, Ne as EffectComposer, G as EffectComposerContext, nt as FXAA, rt as Glitch, it as GodRays, at as Grid, ot as HueSaturation, dt as LUT, ut as LensFlare, ct as LensFlareEffect, Lt as N8AO, ft as Noise, pt as Outline, mt as Pixelation, vt as Ramp, _t as RampEffect, gt as RampType, Tt as SMAA, Et as SSAO, yt as Scanline, Ie as Select, Pe as Selection, St as SelectiveBloom, Ct as Sepia, wt as ShockWave, Dt as Texture, Ot as TiltShift, jt as TiltShift2, At as TiltShiftEffect, Mt as ToneMapping, Nt as Vignette, It as WaterEffect, Ft as WaterEffectImpl, J as resolveRef, K as selectionContext, X as useDispose, Y as useSelectionSync, Z as useVector2, $ as wrapEffect };
|
|
542
858
|
|
|
543
|
-
|
|
544
|
-
vec2 vUv = uv;
|
|
545
|
-
float frequency = 6.0 * factor;
|
|
546
|
-
float amplitude = 0.015 * factor;
|
|
547
|
-
float x = vUv.y * frequency + time * 0.7;
|
|
548
|
-
float y = vUv.x * frequency + time * 0.3;
|
|
549
|
-
vUv.x += cos(x + y) * amplitude * cos(y);
|
|
550
|
-
vUv.y += sin(x - y) * amplitude * cos(y);
|
|
551
|
-
vec4 rgba = texture(inputBuffer, vUv);
|
|
552
|
-
outputColor = rgba;
|
|
553
|
-
}
|
|
554
|
-
`};class de extends W{constructor({blendFunction:t=23,factor:o=0}={}){super("WaterEffect",to.fragmentShader,{blendFunction:t,attributes:2,uniforms:/*@__PURE__*/new Map([["factor",new y(o)]])})}}const oo=/*@__PURE__*/P(de,{blendFunction:23}),ao=/*@__PURE__*/B(({halfRes:e,screenSpaceRadius:t,quality:o,depthAwareUpsampling:r=!0,aoRadius:a=5,aoSamples:n=16,denoiseSamples:i=4,denoiseRadius:s=12,distanceFalloff:l=1,intensity:p=1,color:_,renderMode:S=0},g)=>{const{camera:d,scene:m}=V(),v=z(()=>new ut(m,d),[d,m]);return L(()=>{Ce(v.configuration,{color:_,aoRadius:a,distanceFalloff:l,intensity:p,aoSamples:n,denoiseSamples:i,denoiseRadius:s,screenSpaceRadius:t,renderMode:S,halfRes:e,depthAwareUpsampling:r})},[t,_,a,l,p,n,i,s,S,e,r,v]),L(()=>{o&&v.setQualityMode(o.charAt(0).toUpperCase()+o.slice(1))},[v,o]),/*@__PURE__*/w("primitive",{ref:g,object:v})});export{eo as ASCII,ht as Autofocus,wt as Bloom,St as BrightnessContrast,yt as ChromaticAberration,Pt as ColorAverage,bt as ColorDepth,Et as Depth,ce as DepthOfField,Rt as DotScreen,dt as EffectComposer,D as EffectComposerContext,Nt as FXAA,Ut as Glitch,Ct as GodRays,zt as Grid,Tt as HueSaturation,Zt as LUT,gt as LensFlare,fe as LensFlareEffect,ao as N8AO,At as Noise,Bt as Outline,Vt as Pixelation,Ot as Ramp,pe as RampEffect,ue as RampType,Lt as SMAA,It as SSAO,Ft as Scanline,mt as Select,pt as Selection,kt as SelectiveBloom,Gt as Sepia,Ht as ShockWave,Wt as Texture,$t as TiltShift,Yt as TiltShift2,me as TiltShiftEffect,Xt as ToneMapping,qt as Vignette,oo as WaterEffect,de as WaterEffectImpl,k as resolveRef,H as selectionContext,Z as useVector2,P as wrapEffect};
|
|
555
|
-
//# sourceMappingURL=index.js.map
|
|
859
|
+
//# sourceMappingURL=index.js.map
|