shader-doodle

<shader-doodle> <script type="x-shader/x-fragment"> float random (vec2 _st) { return fract(sin(dot(_st.xy, vec2(12.9898, 78.233))) * 43758.5453123); } // Based on Morgan McGuire @morgan3d // https://www.shadertoy.com/view/4dS3Wd float noise (vec2 _st) { vec2 i = floor(_st); vec2 f = fract(_st); // Four corners in 2D of a tile float a = random(i); float b = random(i + vec2(1.0, 0.0)); float c = random(i + vec2(0.0, 1.0)); float d = random(i + vec2(1.0, 1.0)); vec2 u = f * f * (3.0 - 2.0 * f); return mix(a, b, u.x) + (c - a) * u.y * (1.0 - u.x) + (d - b) * u.x * u.y; } mat2 rotate2d(float _angle){ return mat2(cos(_angle),-sin(_angle), sin(_angle),cos(_angle)); } #define NUM_OCTAVES 5 float fbm (vec2 _st) { float v = 0.0; float a = 0.5; vec2 shift = vec2(100.0); // Rotate to reduce axial bias mat2 rot = mat2(cos(0.5), sin(0.5), -sin(0.5), cos(0.50)); for (int i = 0; i < NUM_OCTAVES; ++i) { v += a * noise(_st); _st = rot * _st * 2.0 + shift; a *= 0.5; } return v; } vec2 skew (vec2 st) { vec2 r = vec2(0.0); r.x = 1.1547 * st.x; r.y = st.y + 0.5 * r.x; return r; } #define PI 3.1415926535897932384626433832795 vec2 simplexGrid (vec2 st) { vec2 p = fract(skew(st)); if (p.x > p.y) { st = 1.0 - vec2(p.x, p.y - p.x); } else { st = 1.0 - vec2(p.x - p.y, p.y); } st -= vec2(0.5); st = rotate2d(PI / 3. * 0.) * st; st += vec2(0.5); return st; } void main() { float m = max(u_resolution.x, u_resolution.y); vec2 st = gl_FragCoord.xy / m; // st = simplexGrid(st * 3.); st -= u_resolution / m / 2.; st += st * ((2. + sin(u_time * 0.4)) * 3.0); st = rotate2d(u_time * .07) * st; st += u_resolution / m / 2.; vec3 color = vec3(0.0); // .5, .5, 0.0); vec2 q = vec2(0.); q.x = fbm(st * 5. + 0.00 * u_time); q.y = fbm(st * 5. + vec2(1.0)); vec2 r = vec2(0.); r.x = fbm(st + 1.0 * q + vec2(1.7,9.2) + 0.15 * u_time ); r.y = fbm(st + 1.0 * q + vec2(8.3,2.8) + 0.126 * u_time); float f = fbm(st + r); vec3 col2 = vec3(1., 1., 1.); vec3 col1 = vec3(.5); color = mix(col1, col2, clamp(f * f * 3.0, 0.0, 1.0)); gl_FragColor = vec4(color, 1.); } </script> </shader-doodle>