-
Notifications
You must be signed in to change notification settings - Fork 0
/
wandering_stars.sttf
1 lines (1 loc) · 2.33 KB
/
wandering_stars.sttf
1
{"links":[{"end":"RenderOutput","filter":"Linear","slot":0,"start":"Image","wrapMode":"Repeat"}],"metadata":{"Author":"ApeSander","Description":"This is the third shader I ever made. I tried to create something interesting using bezier curves.","Name":"Wandering Stars","ShaderToyURL":"https://www.shadertoy.com/view/DdXyz7"},"nodes":[{"class":"RenderOutput","name":"RenderOutput"},{"class":"GLSLShader","name":"Image","source":"// Function to create the colors (https://iquilezles.org/articles/palettes/)\nvec3 palette( in float t )\n{\n vec3 a = vec3(0.5, 0.5, 0.5);\n vec3 b = vec3(0.5, 0.5, 0.5);\n vec3 c = vec3(1.0, 1.0, 1.0);\n vec3 d = vec3(0.00, 0.10, 0.20);\n \n return a + b*cos( 6.28318*(c*t+d) );\n}\n\nvoid mainImage( out vec4 fragColor, in vec2 fragCoord )\n{\n // Normalize uv with a fixed aspect ratio\n vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y;\n \n vec3 color = palette(uv.x + iTime / 4.0);\n \n float d0 = 0.0;\n for (float j = 1.0; j < 6.0; j++) { // Makes 5 groups of stars\n for (float i = 0.0; i < 20.0; i++) { // Makes 20 stars in every group\n // Bezier curve code (https://www.youtube.com/watch?v=aVwxzDHniEw)\n float t = (sin(iTime + i*2.0) + 1.0) / 2.0;\n \n // 0.84, -0.67, 1.45 and so on are just random values to make the movement look random \n vec2 p1 = vec2(sin(iTime * 0.83 * j), cos(iTime * -0.67 * j / 2.0)); // Multiplying by j to create the kind of flower effect\n vec2 p2 = vec2(cos(iTime * 1.45), cos(iTime * 0.78));\n vec2 p3 = vec2(cos(iTime * -0.67), sin(iTime * 0.23));\n vec2 p4 = vec2(sin(iTime * -0.19), sin(iTime * -0.35));\n vec2 p5 = p1;\n\n vec2 q1 = p1 + t * (p2 - p1);\n vec2 q2 = p2 + t * (p3 - p2);\n vec2 q3 = p3 + t * (p4 - p3);\n vec2 q4 = p4 + t * (p5 - p4);\n\n vec2 r1 = q1 + t * (q2 - q1);\n vec2 r2 = q2 + t * (q3 - q2);\n vec2 r3 = q3 + t * (q4 - q3);\n\n vec2 s1 = r1 + t * (r2 - r1);\n vec2 s2 = r2 + t * (r3 - r2);\n\n vec2 u1 = s1 + t * (s2 - s1);\n\n float d = length(uv - u1);\n\n d = 0.02 / d;\n\n if (d > d0) d0 = d;\n }\n }\n \n fragColor = vec4(color*d0, 1.0);\n}\n","type":"Image"}]}