## juliaSDF (`lygia`/`sdf`/`juliaSDF`)

Returns the Juia set SDF For more information about the Julia set, check this article Some values for c: * vec2(−0.8, 0.156) * vec2(0.285, 0.0) * vec2(-0.8, 0.156); * vec2(0.27334, 0.00742) * vec2(−0.835, −0.2321)

Dependencies:

Use:

``````juliaSDF(<vec2> st, <vec2> c, <float> r)
``````

Check it on Github

``````

#ifndef FNC_JULIASDF
#define FNC_JULIASDF
float juliaSDF( vec2 st, vec2 center, vec2 c, float r) {
st -= 0.5;
st *= 2.0;
vec2 z = vec2(0.0) - (st) * r;
float n = 0.0;
const int I = 500;
for (int i = I; i > 0; i--) {
if ( length(z) > 4.0 ) {
n = float(i)/float(I);
break;
}
z = vec2( (pow2(z.x) - pow2(z.y)) + c.x, (2.0*z.x*z.y) + c.y );
}
return n;
}

float juliaSDF( vec2 st, vec2 c, float r) {
#ifdef CENTER_2D
return juliaSDF(st, CENTER_2D, c, r);
#else
return juliaSDF(st, vec2(0.5), c, r);
#endif
}
#endif
``````

Dependencies:

Use:

``````juliaSDF(<float2> st, <float2> c, <float> r)
``````

Check it on Github

``````

#ifndef FNC_JULIASDF
#define FNC_JULIASDF
float juliaSDF( float2 st, float2 c, float r) {
st = st * 2.0 - 1.0;
float2 z = float2(0.0) - (st) * r;
float n = 0.0;
const int I = 500;
for (int i = I; i > 0; i --) {
if ( length(z) > 4.0 ) {
n = float(i)/float(I);
break;
}
z = float2( (pow2(z.x) - pow2(z.y)) + c.x, (2.0*z.x*z.y) + c.y );
}
return n;
}
#endif
``````