SDF Functions

I’ve uploaded a patch that adds SDF functions to the Shader nodes in Blender. The patch is mostly working ok but it could really do with some artist feedback to polish how these functions should be implemented. If you are able to build Blender, please try out the patch. If you have some ideas on how you would use SDF functions that would be great too.

Patch: Blender Archive -

Based on the work of Inigo Quilez. Please see Inigo’s website for further information.


I think it should be at least explained in some more clear way, other than reference to unexplained code.

1 Like

I’ve added a link to the first post that will help explain how SDF functions work.

1 Like

Can you explain in more practical terms what such a node will be useful for? With an example node setup?

SDF functions like this are quite useful in the demo scene, but it’s not as obvious they are useful in Blender shader nodes. If we supported rendering signed distance fields as surfaces directly, by using the signed distance for ray marching, then it would make a bit more sense. Right now it feels like a math function made for a use case we don’t have yet?


is this like vdb but in shader ?

1 Like

The current nodes are somewhat difficult to control, and lack some basic functionality like csg and shape blending (you can still do it, but you have to know the math behind it: not very artist friendly) so best i could do on short notice is this shoddy rivet looking shader

I’d love to upload a .blend but the forum software won’t let me.

I admit, its somewhat of a lack luster example, so let me drag in an alternative

Not based on this patch (earlier attempt for an substance like offline texture synthesizer) but based on the same math

for 3D the case is hard to make currently , but given the right amount of spit’n’shine so artists can easily use it, 2D be wonderful to have!


Using SDF for ray marching is outside the scope of this patch but having SDF functions available in shader nodes provide a wide range of use cases. It also expands the artists toolset.

  • 2D for texture generation
  • 3D functions for manipulating volume and displacement

Here are some more examples from other software.


Found this on Twitter for SDF. No other information.

1 Like

Patch updated with SDF Ops node.


Slowly making progress!


This looks really interesting. Will look into it in March when my current work is finished.

1 Like

Is it possible to implement shapes with curves of degree higher than 2? Like, cubic bezier.

It seems like for degree 3 it’s +2 for distance, and it ends up with polinom of power 5, which is not quite trivial to solve or optimize.

This is my current plan which includes quadratic bezier. The challenge is getting this into the nodes UI.


I’m not sure, but I think that quadratic bezier is just scaled/rotated parabola, isn’t it?

1 Like

Quadratic is a bezier with a start, end and a single control point.

1 Like

Had another whirl at this branch last night, it’s still remarkably hard to control things here’s some suggestions (they are just that, they could be bad ideas, use your own judgment there)

  1. options that do nothing be removed, i tested with a 2d circle and i’m still unsure if any of the parameters actually do anything.

  2. coordinate system, most sdfs work in the -1 … 1 range, most UV’s are in 0…1 range…solved it with a mapping node, but that may not be obvious to every user. perhaps a dedicated node would help? uv -> sdf coords?

  3. most SDF shaders on shadertoy use a visualizer to easily visualize the field, we should have one.

  4. The textures should just be the base properties, ie circle should just have one property: size if you want to make it annular that’s the job of a different node, conflating too many options into a single node just makes it harder to work with than it should .


I’m in process of working through the patch to make it easier to use. I’ll update d.b.o with working changes as I go.

  1. options: Options for each primitive vary a lot. I’m also adding extra primitives too. This will be simplified but feedback will be useful after the next patch or two!.
  2. coordinates: This could be done with the mapping node, I’ve got a patch so it works with vectors. see: There is also the possibility of the trebuchet patch to be extended with my grid script which incorporates your whirl texture from brick tricks see: and
  3. visualizer: In the test blend on d.b.o there is a shader that can be used. This is probably best left out of the patch as it stands.
  4. annular/thickness: Having these options on the primitive node is really useful as they will be used a lot and adding extra nodes all the time will be annoying! At least I’ll keep them in until it’s closer to being finished.

Patch updated, see:



This looks awesome! I really like how much effort you’re putting into getting the node interface right. Maybe “K” and “Radius2” could still change? I’m guessing “Radius and Radius2” are the inner and outer radii.

Also, I briefly looked around the internet and I haven’t found what SDF actually stands for. Shadertoy distance functions? I’ve noticed some acronyms being added to Blender recently which can make it harder for new people to learn. Could it make sense to expand the name and not use the acronym? I understand there are probably lots of reasons why it wouldn’t.


briefly looked around the internet and I haven’t found what SDF actually stands for

Signed Distance Function