3D Fractals

Ive been wanting do this but I am not Super familiar with the patch editor... is it possible to re-create this in lens studio or not yet?


Best Answers

  • Max
    Max Posts: 26 🔥
    #2 Answer ✓

    Ray Marching is what would make this possible, at least to some extent!

    This is a shading technique where you take many small steps forward, away from the camera, until you're inside a 3D shape. This shape is called an SDF, short for 'Signed Distance Function (or Field)'.

    Here is a more in-depth explanation of Ray Marching and SDFs, and you can think of the Mandelbulb as an SDF in this case.

    However, at the time of writing this, there is one bottleneck in Lens Studio making this technique harder to do: Loop nodes cannot be stopped from inside this loop. They will always loop as many times as they're asked to do beforehand (this goes for both the Loop node and the Loop (Dynamic) node).

    This means that the information coming out of the loop can only be a true or a false value, indicating whether the SDF shape was hit. No information about the distance to this shape, or the hit position, is available. And that makes it difficult to do lighting on it, as you'd need that to generate normals.

    I've done Ray Marching with custom SDF shapes in the past, here you can see an example of a 'donut' SDF rendered on a cube. There's no lighting, so it's just a white outline - but it's a start! 😅

    But you don't have to necessarily render it as a solid shape, here's another example I did where I made more of a wireframe and gave it some arbitrary colors for more detail.

    Both of these examples could have been done with Mandelbulb as well! On Shadertoy, you can also see a bunch of examples of it (which are also using Ray Marching), like this one.

    This looping stuff has already been improved in recent versions of Lens Studio, so I have a feeling it might soon be possible to do the 'complete' kind of Ray Marching!

    Hope this helps :)

  • Brendan Stow
    Brendan Stow Posts: 11 🔥
    #3 Answer ✓

    Omg snap added a Ray marching example th the code node template 🤩🙏😍