-
Notifications
You must be signed in to change notification settings - Fork 15
/
Fire Shader Red.sksl
49 lines (40 loc) · 1.38 KB
/
Fire Shader Red.sksl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
uniform float2 iResolution;
uniform float iTime;
// Fire Shader
// Created by codevinsky in 2014-04-10
// https://www.shadertoy.com/view/XsXXRN
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;
}
vec4 main( in vec2 fragCoord ) {
// Vertical flip for GlSL to SkSL
fragCoord.y = iResolution.y - fragCoord.y;
const vec3 c1 = vec3(0.5, 0.0, 0.1);
const vec3 c2 = vec3(0.9, 0.0, 0.0);
const vec3 c3 = vec3(0.2, 0.0, 0.0);
const vec3 c4 = vec3(1.0, 0.9, 0.0);
const vec3 c5 = vec3(0.1);
const vec3 c6 = vec3(0.9);
vec2 speed = vec2(0.7, 0.4);
float shift = 1.6;
float alpha = 1.0;
vec2 p = fragCoord.xy * 8.0 / iResolution.xx;
float q = fbm(p - iTime * 0.1);
vec2 r = vec2(fbm(p + q + iTime * speed.x - p.x - p.y), fbm(p + q - iTime * speed.y));
vec3 c = mix(c1, c2, fbm(p + r)) + mix(c3, c4, r.x) - mix(c5, c6, r.y);
return vec4(c * cos(shift * fragCoord.y / iResolution.y), alpha);
}