Created
December 9, 2024 19:17
-
-
Save CIOSAI/3135f5b97e451d80a823beb08fae7067 to your computer and use it in GitHub Desktop.
simple 2d sdf of a heart
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
float box(vec2 p){ | |
vec2 q = abs(p); | |
return max(q.x,q.y); | |
} | |
// /.-\ | |
// | | | |
// \ / <- center is here, it's a bit top-heavy | |
// \/ | |
float heart(vec2 p){ | |
vec2 q = abs(p); | |
return mix( | |
box(vec2(p.x-p.y,p.x+p.y))/sqrt(2.), | |
length(q-(q.x*q.x+q.y*q.y)/(2.*(q.x+q.y))), | |
step(0.,p.y)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment