Created
June 8, 2023 19:15
-
-
Save mulrooneydesign/0a6ae3b6cc4a628ba8dbc61b83e648bc to your computer and use it in GitHub Desktop.
A shader toy shader
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| vec3 palette(float t) { | |
| vec3 a = vec3(0.938, 0.328, 0.718); | |
| vec3 b = vec3(0.659, 0.438, 0.328); | |
| vec3 c = vec3(0.388, 0.388, 0.296); | |
| vec3 d = vec3(2.538, 2.478, 0.168); | |
| return a + b * cos(6.28318*(c*t*d)); | |
| } | |
| float noise(in vec2 st) { | |
| return fract(sin(dot(st.xy, vec2(12.9898, 78.233))) * 43758.5453); | |
| } | |
| void mainImage( out vec4 fragColor, in vec2 fragCoord ) | |
| { | |
| vec2 uv = (fragCoord * 2.0 - iResolution.xy) / iResolution.y; | |
| vec2 uvCopy = fract(uv * 0.25); | |
| vec3 myColor = vec3(0.0); | |
| vec2 noiseScale = vec2(0.25, 2.0); | |
| float noiseValue = noise(uv * noiseScale * iTime / 2.0); | |
| float noiseStrength = 0.8; | |
| vec3 noiseColor = vec3(noiseValue) * noiseStrength; | |
| noiseColor = smoothstep(0.7, 1.0, noiseColor); | |
| float rotationSpeed = 0.2; | |
| float angle = iTime * rotationSpeed; | |
| vec2 rotatedDelta = vec2( | |
| uv.x * cos(angle) - uv.y * sin(angle), | |
| uv.x * sin(angle) + uv.y * cos(angle) | |
| ); | |
| vec2 newUV = uv + rotatedDelta; | |
| vec3 rotate = vec3(newUV, 1.0); | |
| for(float i = 0.0; i < 2.0; i++) { | |
| uv = fract(uv * 0.5) - 0.5; | |
| uv = fract(uv * 0.5) - 0.5; | |
| uv = fract(uv * 1.5) - 0.5; | |
| uv = fract(uv * 0.5) - 0.5; | |
| uv = fract(uv * 2.5) - 0.5; | |
| float d = length(uv); | |
| vec3 col = palette(length(uvCopy)); | |
| d = sin(d*22.0 + iTime) / 5.0; | |
| d = abs(d); | |
| d = 0.02 / tan(d); | |
| col *= d; | |
| myColor += col * d; | |
| myColor += noiseColor; | |
| myColor = myColor * rotate; | |
| } | |
| fragColor = vec4(myColor, 1.0); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment