Created
October 1, 2024 04:17
-
-
Save otanodesignco/d9fdae0d12c0a713dd41c85e2794deef to your computer and use it in GitHub Desktop.
Twirl function for glsl ported from unity shader graph node
This file contains 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
vec2 twirl( vec2 uv, vec2 center, float strength, vec2 offset ) | |
{ | |
vec2 delta = uv - center; | |
float angle = strength * length(delta); | |
float x = cos(angle) * delta.x - sin(angle) * delta.y; | |
float y = sin(angle) * delta.x + cos(angle) * delta.y; | |
return vec2(x + center.x + offset.x, y + center.y + offset.y); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment