#version 300 es
precision highp float;
uniform vec2 uResolution;
uniform float uTime;
out vec4 outColor;
const uint UINT_MAX = 0xffffffffu;
uvec3 k = uvec3(0x456789abu, 0x6789ab45u, 0x89ab4567u);
uvec3 u = uvec3(1, 2, 3);
uvec3 uhash33(uvec3 n){
n ^= (n.yzx << u);
n ^= (n.yzx >> u);
n *= k;
n ^= (n.yzx << u);
return n * k;
}
float hash31(vec3 b) {
uvec3 n = floatBitsToUint(b);
return float(uhash33(n).x) / float(UINT_MAX);
}
float vnoise31(vec3 pos) {
vec3 origin = floor(pos);
float corner000 = hash31(origin);
float corner010 = hash31(origin + vec3(0.0, 1.0, 0.0));
float corner011 = hash31(origin + vec3(0.0, 1.0, 1.0));
float corner001 = hash31(origin + vec3(0.0, 0.0, 1.0));
float corner100 = hash31(origin + vec3(1.0, 0.0, 0.0));
float corner110 = hash31(origin + vec3(1.0, 1.0, 0.0));
float corner111 = hash31(origin + vec3(1.0, 1.0, 1.0));
float corner101 = hash31(origin + vec3(1.0, 0.0, 1.0));
vec3 f = smoothstep(0.0, 1.0, fract(pos));
float bottom = mix(
mix(corner000, corner100, f.x),
mix(corner010, corner110, f.x),
f.y
);
float top = mix(
mix(corner001, corner101, f.x),
mix(corner011, corner111, f.x),
f.y
);
return mix(bottom, top, f.z);
}
void main() {
vec2 pos = gl_FragCoord.xy / min(uResolution.x, uResolution.y);
pos *= 10.0;
pos += uTime;
outColor.rgb = vec3(vnoise31(vec3(pos, uTime)));
outColor.a = 1.0;
}