Making a cylindrical mask instead of sphere

I made the cylinder distance field from above into a material network that you can copy. What this does is return a distance field for a the world. This is set up so that “height” also scales worldposition. To scale the cylinder, multiply worldposition by something first. To offset it, add something.

Here is that material applied to a few static mesh planes. You can see how each plane shows a cross section of where it intersections the cylinder function.

I was curious if you need to show the interior surface of the cylinder since that is quite a bit more work. You will have to do some research on detecting when the ray hits the caps vs the sides and then create virtual side coordinates. For those you could look at the “Spline Thicken” material function which does virtual cylinder exterior, making it an interior is just inverting the height variable.

And as you can see, cylinders look like circles from the side so there won’t be much to make this look different from a spheremask, yet this is still a cylinder hole by definition:

43227-cylinder_distancefield_example.jpg

I am actually planning to mess with a ray-marching material function soon which would help in doing all this stuff.

1 Like