Skip to content

Commit 1351de3

Browse files
authored
Add files via upload
1 parent 631a1e5 commit 1351de3

16 files changed

Lines changed: 1113 additions & 0 deletions

vulpixism/effects/bloom.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* global define, require */
2+
(function (root, factory) {
3+
'use strict';
4+
if (typeof define === 'function' && define.amd) {
5+
define(['seriously'], factory);
6+
} else if (typeof exports === 'object') {
7+
factory(require('seriously'));
8+
} else {
9+
if (!root.Seriously) {
10+
root.Seriously = { plugin: function (name, opt) { this[name] = opt; } };
11+
}
12+
factory(root.Seriously);
13+
}
14+
}(window, function (Seriously) {
15+
'use strict';
16+
Seriously.plugin('bloom', {
17+
shader: function (inputs, shaderSource) {
18+
return {
19+
fragment: `
20+
precision mediump float;
21+
varying vec2 vTexCoord;
22+
uniform sampler2D source;
23+
uniform float amount;
24+
const float offset = 1.0 / 512.0;
25+
void main() {
26+
vec4 c = texture2D(source, vTexCoord);
27+
vec4 bloom = vec4(0.0);
28+
bloom += texture2D(source, vTexCoord + vec2(-offset, -offset));
29+
bloom += texture2D(source, vTexCoord + vec2(-offset, offset));
30+
bloom += texture2D(source, vTexCoord + vec2(offset, -offset));
31+
bloom += texture2D(source, vTexCoord + vec2(offset, offset));
32+
bloom *= 0.25;
33+
gl_FragColor = mix(c, bloom, amount / 200.0);
34+
}
35+
`
36+
};
37+
},
38+
inputs: {
39+
source: { type: 'image', uniform: 'source' },
40+
amount: { type: 'number', uniform: 'amount', defaultValue: 0, min: 0, max: 200 }
41+
}
42+
});
43+
}));

vulpixism/effects/blur.js

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/* global define, require */
2+
(function (root, factory) {
3+
'use strict';
4+
if (typeof define === 'function' && define.amd) {
5+
define(['seriously'], factory);
6+
} else if (typeof exports === 'object') {
7+
factory(require('seriously'));
8+
} else {
9+
if (!root.Seriously) {
10+
root.Seriously = { plugin: function (name, opt) { this[name] = opt; } };
11+
}
12+
factory(root.Seriously);
13+
}
14+
}(window, function (Seriously) {
15+
'use strict';
16+
17+
Seriously.plugin('blur44', {
18+
shader: function (inputs, shaderSource) {
19+
shaderSource.vertex = [
20+
'precision mediump float;',
21+
'attribute vec2 position;',
22+
'varying vec2 vTexCoord;',
23+
'void main(void) {',
24+
'vTexCoord = (position + 1.0) * 0.5;',
25+
'gl_Position = vec4(position, 0.0, 1.0);',
26+
'}'
27+
].join('\n');
28+
29+
shaderSource.fragment = [
30+
'precision mediump float;',
31+
'uniform sampler2D source;',
32+
'uniform float intensity;',
33+
'varying vec2 vTexCoord;',
34+
'void main(void) {',
35+
'vec2 texel = vec2(1.0) / vec2(textureSize(source, 0));',
36+
'float radius = clamp(intensity, 0.0, 44.0);',
37+
'vec4 color = vec4(0.0);',
38+
'float total = 0.0;',
39+
'for (int x = -44; x <= 44; x++) {',
40+
'for (int y = -44; y <= 44; y++) {',
41+
'float fx = float(x);',
42+
'float fy = float(y);',
43+
'float weight = exp(-(fx*fx + fy*fy) / (2.0 * radius * radius + 0.0001));',
44+
'vec2 offset = vec2(fx, fy) * texel;',
45+
'color += texture2D(source, vTexCoord + offset) * weight;',
46+
'total += weight;',
47+
'}',
48+
'}',
49+
'gl_FragColor = color / total;',
50+
'}'
51+
].join('\n');
52+
53+
return shaderSource;
54+
},
55+
inputs: {
56+
source: {
57+
type: 'image'
58+
},
59+
intensity: {
60+
type: 'number',
61+
min: 0,
62+
max: 44,
63+
defaultValue: 0
64+
}
65+
},
66+
title: 'Blur'
67+
});
68+
69+
}));

vulpixism/effects/chromaabber.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/* global define, require */ (function (root, factory) { 'use strict';
2+
if (typeof define === 'function' && define.amd) {
3+
define(['seriously'], factory);
4+
} else if (typeof exports === 'object') {
5+
factory(require('seriously'));
6+
} else {
7+
if (!root.Seriously) {
8+
root.Seriously = { plugin: function (name, opt) { this[name] = opt; } };
9+
}
10+
factory(root.Seriously);
11+
}
12+
}(window, function (Seriously) {
13+
'use strict';
14+
15+
Seriously.plugin('chromaticAberration', {
16+
shader: function (inputs, shaderSource) {
17+
shaderSource.vertex = [
18+
'precision mediump float;',
19+
'attribute vec2 position;',
20+
'attribute vec2 texCoord;',
21+
'varying vec2 vTexCoord;',
22+
'void main(void) {',
23+
'vTexCoord = texCoord;',
24+
'gl_Position = vec4(position, 0.0, 1.0);',
25+
'}'
26+
].join('\n');
27+
28+
shaderSource.fragment = [
29+
'precision mediump float;',
30+
'varying vec2 vTexCoord;',
31+
'uniform sampler2D source;',
32+
'uniform float amount;',
33+
'uniform float offsetX;',
34+
'uniform float offsetY;',
35+
'void main(void) {',
36+
'vec2 offset = vec2(offsetX, offsetY) * amount;',
37+
'float r = texture2D(source, vTexCoord + offset).r;',
38+
'float g = texture2D(source, vTexCoord).g;',
39+
'float b = texture2D(source, vTexCoord - offset).b;',
40+
'gl_FragColor = vec4(r, g, b, 1.0);',
41+
'}'
42+
].join('\n');
43+
},
44+
45+
inPlace: true,
46+
inputs: {
47+
source: {
48+
type: 'image',
49+
uniform: 'source'
50+
},
51+
amount: {
52+
type: 'number',
53+
uniform: 'amount',
54+
min: 0,
55+
max: 100,
56+
defaultValue: 0
57+
},
58+
x: {
59+
type: 'number',
60+
uniform: 'offsetX',
61+
min: 0,
62+
max: 100,
63+
defaultValue: 0
64+
},
65+
y: {
66+
type: 'number',
67+
uniform: 'offsetY',
68+
min: 0,
69+
max: 100,
70+
defaultValue: 0
71+
}
72+
}
73+
});
74+
75+
}));

vulpixism/effects/fractal.js

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/* global define, require */
2+
(function (root, factory) {
3+
'use strict';
4+
if (typeof define === 'function' && define.amd) {
5+
define(['seriously'], factory);
6+
} else if (typeof exports === 'object') {
7+
factory(require('seriously'));
8+
} else {
9+
if (!root.Seriously) {
10+
root.Seriously = { plugin: function (name, opt) { this[name] = opt; } };
11+
}
12+
factory(root.Seriously);
13+
}
14+
}(window, function (Seriously) {
15+
'use strict';
16+
17+
Seriously.plugin('fractalWarp', {
18+
inputs: {
19+
source: {
20+
type: 'image',
21+
uniform: 'source'
22+
},
23+
amount: {
24+
type: 'number',
25+
uniform: 'amount',
26+
defaultValue: 0,
27+
min: 0,
28+
max: 200
29+
},
30+
frequency: {
31+
type: 'number',
32+
uniform: 'frequency',
33+
defaultValue: 0,
34+
min: 0,
35+
max: 200
36+
},
37+
speed: {
38+
type: 'number',
39+
uniform: 'speed',
40+
defaultValue: 0,
41+
min: 0,
42+
max: 200
43+
},
44+
time: {
45+
type: 'number',
46+
uniform: 'time',
47+
defaultValue: 0
48+
}
49+
},
50+
shader: function (inputs, shaderSource) {
51+
shaderSource.fragment = [
52+
'precision mediump float;',
53+
'varying vec2 vTexCoord;',
54+
'uniform sampler2D source;',
55+
'uniform float amount;',
56+
'uniform float frequency;',
57+
'uniform float speed;',
58+
'uniform float time;',
59+
'float noise(vec2 p){',
60+
'return sin(p.x)*sin(p.y);',
61+
'}',
62+
'vec2 warp(vec2 uv){',
63+
'float t = time * speed * 0.01;',
64+
'float n = noise(uv * frequency * 0.01 + t);',
65+
'float n2 = noise((uv + n) * frequency * 0.02 - t);',
66+
'uv += vec2(n, n2) * amount * 0.002;',
67+
'return uv;',
68+
'}',
69+
'void main(void){',
70+
'vec2 uv = vTexCoord;',
71+
'uv = warp(uv);',
72+
'gl_FragColor = texture2D(source, uv);',
73+
'}'
74+
].join('\n');
75+
return shaderSource;
76+
}
77+
});
78+
79+
}));

vulpixism/effects/glitch.js

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/* global define, require */
2+
(function (root, factory) {
3+
'use strict';
4+
if (typeof define === 'function' && define.amd) {
5+
define(['seriously'], factory);
6+
} else if (typeof exports === 'object') {
7+
factory(require('seriously'));
8+
} else {
9+
if (!root.Seriously) {
10+
root.Seriously = { plugin: function (name, opt) { this[name] = opt; } };
11+
}
12+
factory(root.Seriously);
13+
}
14+
}(window, function (Seriously) {
15+
'use strict';
16+
17+
Seriously.plugin('glitch', {
18+
commonShader: true,
19+
shader: function (inputs, shaderSource) {
20+
shaderSource.vertex = [
21+
'precision mediump float;',
22+
'attribute vec3 position;',
23+
'attribute vec2 texCoord;',
24+
'uniform mat4 transform;',
25+
'varying vec2 vTexCoord;',
26+
'void main(void) {',
27+
' vTexCoord = texCoord;',
28+
' gl_Position = transform * vec4(position, 1.0);',
29+
'}'
30+
].join('\n');
31+
32+
shaderSource.fragment = [
33+
'precision mediump float;',
34+
'varying vec2 vTexCoord;',
35+
'uniform sampler2D source;',
36+
'uniform float amount;',
37+
'uniform float frequency;',
38+
'uniform float speed;',
39+
'uniform float time;',
40+
41+
'float rand(vec2 co) {',
42+
' return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);',
43+
'}',
44+
45+
'void main(void) {',
46+
' vec2 uv = vTexCoord;',
47+
' float t = time * speed * 0.01;',
48+
' float freq = frequency * 0.01;',
49+
' float amt = amount * 0.005;',
50+
51+
' float glitch = step(1.0 - freq, rand(vec2(t, uv.y)));',
52+
53+
' uv.x += glitch * (rand(vec2(uv.y, t)) - 0.5) * amt;',
54+
' uv.y += glitch * (rand(vec2(uv.x, t)) - 0.5) * amt * 0.5;',
55+
56+
' vec4 color = texture2D(source, uv);',
57+
58+
' float r = texture2D(source, uv + vec2(amt * 0.5, 0.0)).r;',
59+
' float g = color.g;',
60+
' float b = texture2D(source, uv - vec2(amt * 0.5, 0.0)).b;',
61+
62+
' gl_FragColor = vec4(r, g, b, color.a);',
63+
'}'
64+
].join('\n');
65+
},
66+
67+
inputs: {
68+
source: {
69+
type: 'image',
70+
uniform: 'source'
71+
},
72+
amount: {
73+
type: 'number',
74+
uniform: 'amount',
75+
defaultValue: 0,
76+
min: 0,
77+
max: 200
78+
},
79+
frequency: {
80+
type: 'number',
81+
uniform: 'frequency',
82+
defaultValue: 0,
83+
min: 0,
84+
max: 200
85+
},
86+
speed: {
87+
type: 'number',
88+
uniform: 'speed',
89+
defaultValue: 0,
90+
min: 0,
91+
max: 200
92+
},
93+
time: {
94+
type: 'number',
95+
uniform: 'time',
96+
defaultValue: 0
97+
}
98+
},
99+
100+
title: 'Glitch'
101+
});
102+
103+
}));

0 commit comments

Comments
 (0)