demo
This commit is contained in:
22
shaders/fractal.frag
Normal file
22
shaders/fractal.frag
Normal file
@@ -0,0 +1,22 @@
|
||||
#version 100
|
||||
precision mediump float;
|
||||
uniform float u_time;
|
||||
uniform vec2 u_resolution;
|
||||
|
||||
void main() {
|
||||
vec2 uv = (gl_FragCoord.xy * 2.0 - u_resolution.xy) / u_resolution.y;
|
||||
vec2 u0 = uv;
|
||||
vec3 finalColor = vec3(0.0);
|
||||
|
||||
for (float i = 0.0; i < 4.0; i++) {
|
||||
uv = fract(uv * 1.5) - 0.5;
|
||||
float d = length(uv) * exp(-length(u0));
|
||||
vec3 col = vec3(0.2, 0.5, 0.82);
|
||||
d = sin(d * 8.0 + u_time) / 8.0;
|
||||
d = abs(d);
|
||||
d = pow(0.01 / d, 1.2);
|
||||
finalColor += col * d;
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(finalColor, 1.0);
|
||||
}
|
||||
7
shaders/frag.glsl
Normal file
7
shaders/frag.glsl
Normal file
@@ -0,0 +1,7 @@
|
||||
#version 100
|
||||
precision mediump float;
|
||||
varying vec3 v_color;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(v_color, 1.0);
|
||||
}
|
||||
31
shaders/mandelbrot.frag
Normal file
31
shaders/mandelbrot.frag
Normal file
@@ -0,0 +1,31 @@
|
||||
#version 100
|
||||
precision mediump float;
|
||||
uniform float u_time;
|
||||
uniform vec2 u_resolution;
|
||||
|
||||
void main() {
|
||||
vec2 uv = (gl_FragCoord.xy * 2.0 - u_resolution.xy) / u_resolution.y;
|
||||
|
||||
// Auto zoom
|
||||
float zoom = 1.0 + sin(u_time * 0.1) * 0.5;
|
||||
zoom = pow(zoom, 4.0);
|
||||
vec2 c = uv / zoom - vec2(0.74364388703, 0.13182590421); // Zoom into a specific interesting point
|
||||
|
||||
vec2 z = vec2(0.0);
|
||||
float iter = 0.0;
|
||||
float max_iter = 100.0;
|
||||
|
||||
for (float i = 0.0; i < 100.0; i++) {
|
||||
z = vec2(z.x * z.x - z.y * z.y, 2.0 * z.x * z.y) + c;
|
||||
if (length(z) > 4.0) break;
|
||||
iter += 1.0;
|
||||
}
|
||||
|
||||
float f = iter / max_iter;
|
||||
vec3 col = vec3(f);
|
||||
col = 0.5 + 0.5 * cos(3.0 + f * 10.0 + vec3(0.0, 0.6, 1.0));
|
||||
|
||||
if (iter >= 99.0) col = vec3(0.0);
|
||||
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
}
|
||||
18
shaders/plasma.frag
Normal file
18
shaders/plasma.frag
Normal file
@@ -0,0 +1,18 @@
|
||||
#version 100
|
||||
precision mediump float;
|
||||
uniform float u_time;
|
||||
uniform vec2 u_resolution;
|
||||
|
||||
void main() {
|
||||
vec2 uv = gl_FragCoord.xy / u_resolution.xy;
|
||||
float v = 0.0;
|
||||
vec2 c = uv * 5.0 - vec2(2.5);
|
||||
v += sin((c.x + u_time));
|
||||
v += sin((c.y + u_time) / 2.0);
|
||||
v += sin((c.x + c.y + u_time) / 2.0);
|
||||
c += vec2(sin(u_time / 3.0), cos(u_time / 2.0));
|
||||
v += sin(sqrt(c.x * c.x + c.y * c.y + 1.0) + u_time);
|
||||
v = v / 2.0;
|
||||
vec3 col = vec3(sin(v * 3.14159), sin(v * 3.14159 + 2.09439), sin(v * 3.14159 + 4.18879));
|
||||
gl_FragColor = vec4(col * 0.5 + 0.5, 1.0);
|
||||
}
|
||||
23
shaders/tunnel.frag
Normal file
23
shaders/tunnel.frag
Normal file
@@ -0,0 +1,23 @@
|
||||
#version 100
|
||||
precision mediump float;
|
||||
uniform float u_time;
|
||||
uniform vec2 u_resolution;
|
||||
|
||||
void main() {
|
||||
vec2 p = (2.0 * gl_FragCoord.xy - u_resolution.xy) / u_resolution.y;
|
||||
float a = atan(p.y, p.x);
|
||||
float r = length(p);
|
||||
vec2 uv = vec2(0.5 / r + 0.5 * u_time, a / 3.14159);
|
||||
|
||||
// Simple checkerboard pattern
|
||||
float f = sin(uv.x * 20.0) * sin(uv.y * 20.0);
|
||||
vec3 col = vec3(f);
|
||||
|
||||
// Fade to black in center
|
||||
col *= r;
|
||||
|
||||
// Add some color
|
||||
col *= vec3(0.5 + 0.5 * sin(u_time), 0.5, 0.5 + 0.5 * cos(u_time));
|
||||
|
||||
gl_FragColor = vec4(col, 1.0);
|
||||
}
|
||||
9
shaders/vert.glsl
Normal file
9
shaders/vert.glsl
Normal file
@@ -0,0 +1,9 @@
|
||||
#version 100
|
||||
attribute vec2 position;
|
||||
attribute vec3 color;
|
||||
varying vec3 v_color;
|
||||
|
||||
void main() {
|
||||
gl_Position = vec4(position, 0.0, 1.0);
|
||||
v_color = color;
|
||||
}
|
||||
Reference in New Issue
Block a user