25 lines
No EOL
764 B
GLSL
25 lines
No EOL
764 B
GLSL
/*
|
|
contributors: Patricio Gonzalez Vivo
|
|
description: Returns a heart shaped SDF
|
|
use: heartSDF(<vec2> st)
|
|
examples:
|
|
- https://raw.githubusercontent.com/patriciogonzalezvivo/lygia_examples/main/draw_shapes.frag
|
|
license:
|
|
- Copyright (c) 2021 Patricio Gonzalez Vivo under Prosperity License - https://prosperitylicense.com/versions/3.0.0
|
|
- Copyright (c) 2021 Patricio Gonzalez Vivo under Patron License - https://lygia.xyz/license
|
|
*/
|
|
|
|
#ifndef FNC_HEARTSDF
|
|
#define FNC_HEARTSDF
|
|
float heartSDF(vec2 st) {
|
|
#ifdef CENTER_2D
|
|
st -= CENTER_2D;
|
|
#else
|
|
st -= 0.5;
|
|
#endif
|
|
st -= vec2(0.0, 0.3);
|
|
float r = length(st) * 5.0;
|
|
st = normalize(st);
|
|
return r - ((st.y * pow(abs(st.x), 0.67)) / (st.y + 1.5) - (2.0) * st.y + 1.26);
|
|
}
|
|
#endif |