tunnel demo

This commit is contained in:
Marco
2023-12-14 15:25:30 +01:00
commit c91f374c53
28 changed files with 9396 additions and 0 deletions

36
src/shaders/fragment.glsl Normal file
View File

@@ -0,0 +1,36 @@
varying vec2 vUv;
uniform float time;
uniform sampler2D u_texture;
// https://www.shadertoy.com/view/4djSRW
float hash12(vec2 p){
vec3 p3 = fract(vec3(p.xyx) * .1031);
p3 += dot(p3, p3.yzx + 33.33);
return fract((p3.x + p3.y) * p3.z);
}
void main() {
vec2 uv = vUv;
uv.x *= 3.142596;
const float numbers = 9.0;
vec2 repeat = vec2(6.0, 12.0);
vec2 cell = (uv * repeat);
cell.x *= numbers;
cell = floor(cell);
float rand = 100.0 * hash12(cell);
float offset = mod(floor(time + rand), numbers) / numbers;
uv = fract(uv * repeat);
uv.x = fract(uv.x + offset);
vec4 color = texture2D(u_texture, uv);
color -= 0.05 * vec4(vec3(rand), 1.0);
gl_FragColor = color;
}

9
src/shaders/vertex.glsl Normal file
View File

@@ -0,0 +1,9 @@
varying vec2 vUv;
uniform float time;
void main() {
vUv = uv;
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}