Blender 3D SDF Node Pack
These can also be used in 2D by excluding the Z axis input, though calculations are still in 3D (2D SDFs coming soon).
Append the SDF_Nodes Material to your .blend file to use.
All formulas are taken from iq's distance function page, check them here for more info:
https://www.iquilezles.org/www/articles/distfunctions/distfunctions.htmTips:
- Translation is done by subtracting the Position vector before the SDF.
- Rotation is done using the Vector Rotate node.
- Rounding can be done by subtracting an amount from the resulting distance value, this will also thicken/expand the shape by the same amount.
- Scaling is usually not advised, as it increases the amount of steps to converge to the shape, but it is done by dividing the Position by an amount, then multiplying the resulting distance with the same amount.
Notes:
- The Pyramid, Triangle, and Quad SDF are very thin and may view improperly, adding a bit of thickness to the shape will mitigate this.
- Some SDFs are pretty complex and will cause to hit the node limit early.
Resources:
The Book of Shaders:
https://thebookofshaders.com/
The Art of Code's Raymarching for Dummies video:
https://www.youtube.com/watch?v=PGtv-dBi2wE
Inigo Quilez's Site:
https://www.iquilezles.org/www/index.htm
Wannes Malfait's Blender Raymarching Tutorial:
https://www.youtube.com/watch?v=aBf3FV97rJY
SDF Node Pack Blend file