--- layout: post title: kaliset explorer custom_js: - kali/kali-gl.js custom_css: - kali/kali-gl.css ---
In 2015, i started [shadertoying](https://www.shadertoy.com/user/bergi) a lot. And the first 10 or so shaders where just about the ***kaliset***, a fractal discovered by the *Fractal Supremo* Kali published in [this post](https://www.fractalforums.com/new-theories-and-research/very-simple-formula-for-fractal-patterns) on fractal forums. Other *shadertoyers* had picked on the formula already. Like [Dave Hoskins](https://www.shadertoy.com/view/Msl3WH), [huwb](https://www.shadertoy.com/view/MslGDX) or [guil](https://www.shadertoy.com/view/lsBGWK) and [Kali](https://www.shadertoy.com/view/XlfGRj) himself. The formula is basically: p = abs(p) / dot(p, p) - param Where `p` is the input position and `param` some parameter in about the range [0, 2]. `p` and `param` can have any number of dimensions. The javascript version above is the remake of [this shader](https://www.shadertoy.com/view/XdVSRc). There to find good magic parameters. A disciplined form of [interactive evolution](https://www.shadertoy.com/view/XdyGWw). And there are some good magic parameters! I was looking for ways to use the resulting numbers in a [signed distance field](https://en.wikipedia.org/wiki/Signed_distance_function) (SDF) to render 3D versions which did not work so well. The kaliset is chaotic and discontinuous. Used as a surface displacement it creates exponential peaks and holes and distorts the continuity required for an SDF. The [first](https://www.shadertoy.com/view/4tfGD8) and [second try](https://www.shadertoy.com/view/Xlf3D8) where just nicely coloring the artifacts so they might look deliberate. This [shader by guil](https://www.shadertoy.com/view/MdB3DK) somehow rendered complicated 3d surfaces but i did not understand the accumulation part. Later i found a [visually pleasing way](https://www.shadertoy.com/view/XtlGDH) of making it look right which brought [eiffie](https://www.shadertoy.com/user/eiffie) to [an elegant method](https://www.shadertoy.com/view/XtlGRj) of approximating a true distance function. Here's an example in GLSL. ```glsl float kaliset_distance_sphere(in vec3 p, in vec3 param) { float dist = 1e8; // start distance is infinitely away float scale = 1.; // start with unstretched space for (int i=0; i