File under: javascript, raymarcher, 3d, development, online
Javascript Ray Marcher
Now I've added a fractal object - the classic 2D mandelbrot set. This shows off the strongest feature of the ray-marcher - it can display any shape at all, provided I can find a formula that says whether a point is inside or outside the shape. Happily, the mandelbrot formula does exactly this.
Only certain kinds of fractals work in this way. The "escape-time" fractals, and "final-state" fractals work particularly well. Escape-time fractals are the formulas where you keep interating a number over and over until it flies off to infinity or you get bored.
z = z * z + c
Final-state fractals are iterated until they reach their final state and stop changing.
Unfortunately other fractal systems like the Iterated Function Systems or Lindenmeyer systems are extremely difficult to render. Calculating them requires creating hundred-thousands or millions of objects and checking all of them for each pixel in the output picture. Render time can go to weeks or even months for a small picture.
So for the moment, Mandelbrot, Julia and other escape fractals.
{{% thumbnail src="/projects/javascriptraymarcher/7.1.png" scale="50" %}}