Table of Contents
Tutorial
Overview
Merging
Intersecting
Differencing
Blobbing
Functions
Sometimes when making a complex isosurface, one wishes he/she could merge functions together or difference them in the same function. In this tutorial I will explain just how to do those things! We will learn how to merge, intersect and even difference functions.
Isosurface threshold, sign and contained_by box will be the same as in the beginning tutorial.
Let's make an isosurface cylinder with a radius of .5 units, a good shape to begin our exercise with. Will will encase it inside parenthesis as shown:
function{ ( sqrt(x^2+z^2)+.5 ) }
Next, we combine another function to it using | (it's the shift+backslash key on windows keyboards). We will use a diamond-shaped shaft for the second function:
function{ ( sqrt(x^2+z^2)+.5 ) | ( abs(x)+abs(y) +.5 ) }
![]() |
Pretty simple, huh? |
We could do the same exact thing by changing the function to this:
function{ min( ( sqrt(x^2+z^2)+.5 ), ( abs(x)+abs(y)+.5 ) ) }
We will do the same thing as before, but instead of using |, we we use an & sign:
function{ ( sqrt(x^2+z^2)+.5 ) & ( abs(x)+abs(y) +.5 ) }
![]() |
An expected result, wouldn't you say? The cylinder intersected with the shaft to create a 'chip off the old block.' |
The same thing could be achieved by typing:
function{ max( ( sqrt(x^2+z^2)+.5 ), ( abs(x)+abs(y)+.5 ) ) }
For differencing we will have to alter the intersection code:
function{ ( sqrt(x^2+z^2)+.5 ) & -( abs(x)+abs(y) +.5 -2 )}
![]() |
Pay close attention to what was changed. A minus sign was placed in front of the second function and a -2 was a placed inside the same function. |
Again, we could get the same effect by typing:
function{ max( ( sqrt(x^2+z^2)+.5 ), -( abs(x)+abs(y)+.5 -2) ) }
Getting the idea? min and max allow you to do the same CSG operations as | and &. Why use min and max? I don't know. I think | and & are much more versatile, in that you can have more than 2 objects performing a CSG operation, and without making the code more messy.
By structuring your functions with logical placement of parenthesis, you can perform any complex CSG operation.
Blobbing functions requires setting up a system for arranging your functions. First, we will make a threshold variable to preserve simplicity. Make sure you have this placed before the isosurface:
#declare Thr=.0001;
Next, inside our isosurface statement, we will set up our function using the cylinder and shaft from the above excercises:
function{
( 1+Thr )
-Thr^( sqrt( x^2+z^2 )+.5 )
-Thr^( abs(x)+abs(y)+.5 )
}
![]() |
As you can see, it treated both functions as blob components. By changing Thr to other [decimal] numbers, you can get different blob thresholds, which means tighter transitions from one object to another, or more stretched, taffy-like transitions. Experiment! |
What the heck! Let's try adding another cylinder to our blob:
function{
(1+Thr)
-Thr^( sqrt( x^2+z^2 )+.5 )
-Thr^( abs(x)+abs(y)+.5 )
-Thr^( sqrt( y^2+z^2 )+.5 )
}
![]() |
You will see, no matter how many functions you add using this method, the threshold will always reamain constant. |
Negative component blobbing has not been worked out completely using this method yet... sorry!