JavaScript
var spineContainer = null;
function createSmokeOnTextureShader(width, height) {
// smoke shader
var uniforms = {};
uniforms.resolution = {
type: '2f',
value: {
x: width,
y: height
}
};
uniforms.alpha = {
type: '1f',
value: 0.5
};
uniforms.shift = {
type: '1f',
value: 0.8
};
uniforms.time = {
type: '1f',
value: 10
};
uniforms.speed = {
type: '2f',
value: {
x: 3.7,
y: 3.4
}
};
var fragmentSrc = [
"precision mediump float;",
"uniform vec2 resolution;",
"uniform float time;",
"uniform float alpha;",
"uniform vec2 speed;",
"uniform float shift;",
"varying vec2 vTextureCoord;",
"uniform sampler2D uSampler;",
"float rand(vec2 n) {",
"return fract(cos(dot(n, vec2(12.9898, 4.1414))) * 43758.5453);",
"}",
"float noise(vec2 n) {",
"const vec2 d = vec2(0.0, 1.0);",
"vec2 b = floor(n), f = smoothstep(vec2(0.0), vec2(1.0), fract(n));",
"return mix(mix(rand(b), rand(b + d.yx), f.x), mix(rand(b + d.xy), rand(b + d.yy), f.x), f.y);",
"}",
"float fbm(vec2 n) {",
"float total = 0.0, amplitude = 1.0;",
"for (int i = 0; i < 4; i++) {",
"total += noise(n) * amplitude;",
"n += n;",
"amplitude *= 0.5;",
"}",
"return total;",
"}",
"void main() {",
"vec4 vTexColor = texture2D(uSampler, vTextureCoord);",
"if(vTexColor.a < 0.1) {return;}",
"const vec3 c1 = vec3(126.0/255.0, 0.0/255.0, 97.0/255.0);",
"const vec3 c2 = vec3(173.0/255.0, 0.0/255.0, 161.4/255.0);",
"const vec3 c3 = vec3(0.2, 0.0, 0.0);",
"const vec3 c4 = vec3(164.0/255.0, 1.0/255.0, 214.4/255.0);",
"const vec3 c5 = vec3(0.1);",
"const vec3...