I have made a (almost) perfect raymarcher in nodes!

So for the last 2 years or so, ive been attempting to make a raymarcher in blender. Ive always wanted fractals and SDFs as part of blender… and no, not the crappy mesh-ified metaball type things blender already has.

So using some research I saw about raymarching in blender, I wrote a completely new system from scratch.

I implemented a way to create custom shaders for the SDFs and render them with a transparent BSDF + an Emission, and it created these really nice looking fake 3D scenes:

(These are all done with math, no meshes)

I wasnt satisfied there, so I wanted to find a way to render the SDFs with cycles’ lighting, without implementing some crazy formulas or anything.

So after a few months, a buddy of mine showed me his POM system, which was able to render real 3D bump mapping (Like POM is supposed to) which is eons better than Bump mapping or Displacement. Not to mention it interacted with cycles materials and worked simply by plugging in normals.

So I attempted to do a similar thing with my SDFs, plugging in the calculated normals my node gave me, and plugged them into a principled bsdf.

It was horrible looking and had tons of issues…

While doing this, I (accidentally) plugged a vector math node into the normals and set it to face forward… and voila… it just rendered this SDF in cycles lighting, with ambient lighting from the environment and everything, just with a principled BSDF:

Now, I know it isnt perfect… but this is actually amazing. To an extent, we can now render fully raymarched objects like 4D fractals and other things within the sphere and then itll even be affected by cycles lighting.

Im not sure if anyone else was able to achieve a near perfect SDF rendered like this before, so I thought the other nerds out there would love to see this.

I really hope blender will someday implement raymarching / hybrid rendering by default, but this is pretty close as is.

Heres a video of me using a smooth boolean and moving a sphere around in this “fake 3D scene” within my raymarcher’s scene node.