Created
January 19, 2025 18:29
-
-
Save airicbear/05aeca13372239521bd994ba31f6d82c to your computer and use it in GitHub Desktop.
shadertoy-distance
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
void mainImage( out vec4 fragColor, in vec2 fragCoord ) | |
{ | |
// Normalized pixel coordinates (from 0 to 1) | |
vec2 res = vec2(10.0, 10.0); | |
vec2 uv = fragCoord/res.xy; | |
vec2 uvMouse = iMouse.xy/res.xy; | |
// Calculate distance | |
float uvMouseDistX = uvMouse.x - uv.x; | |
float uvMouseDistY = uvMouse.y - uv.y; | |
float uvMouseDist = sqrt(uvMouseDistX * uvMouseDistX + uvMouseDistY * uvMouseDistY); | |
fragColor = 1.0 / vec4(uvMouseDist) * cos(iTime * 5.0) * 0.5; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment