kaliset explorer
In 2015, i started shadertoying 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 on fractal forums. Other shadertoyers had picked on the formula already. Like Dave Hoskins, huwb or guil and Kali 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. There to find good magic parameters. A disciplined form of interactive evolution.
And there are some good magic parameters! I was looking for ways to use the resulting numbers in a signed distance field (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 and second try where just nicely coloring the artifacts so they might look deliberate. This shader by guil somehow rendered complicated 3d surfaces but i did not understand the accumulation part. Later i found a visually pleasing way of making it look right which brought eiffie to an elegant method of approximating a true distance function.
Here’s an example in 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<ITERATIONS; ++i) {
float dot_p = dot(p, p);
scale /= dot_p; // stretch the space accordingly
p = abs(p) / dot_p; // the magic formula
dist = min(dist, // find closest distance
length(p.xyz) * scale // measure distance in stretched space
);
p -= param; // the magic parameter
}
return dist;
}
The geometric union is
assembled from spheres at the unit position at each iteration step. By using the scale
parameter the distance function stays true-ish.
This made 3d environments like KaliTrace or Cave Quest a piece of cake. Apart from the eiffie mod, one can simply disregard the distance and just look for the surface in fixed steps or by random search. Here’s one by janiorca.
Now, this post has been lying around for a while. It shows the true kaliset, without polishing. And no 3d. And in ordered chaoticity. And allows a couple of parameters to change.
The accumulator setting defines how the color is calculated from the p
value.
You can check the GLSL source
for detail.
- final: simply the last value of p
- average: average of all p values
- xyz: sum of x > y, y > z or z > x
- min and max: the minimum or maximum value of p
- exp: sum of exp(-p * exp_scale)
- plane X: distance to a place perpendicular to x axis
- cylinder XY: distance to a cylinder extending on the xy plane
- sphere XYZ: distance to a sphere
- cube XYZW: distance to a 3d cube in 4 dimensions or.. i don’t know really
If one of the distance accumulators is selected, additional parameters pop up and allow changing the size and position of the objects and you can turn on the eiffie mod. The rest of the settings should be inferable.
Thanks to Kali, eiffie, Dave, iq and all the others for the fantastic shadertoy years.