Render-time perfect booleans with VRayDistanceTex

vray_booleans_distance_texture

I don’t like to use booleans at all, but I came across this video where the guys from chaosgroup show how they used the VRayDistanceTex to make render-time booleans, similar to the renderman feature. There is no cutting or “bad” geometry tesselation, this is render-time raytracing. In this post I will show you how to do this in maya, but if you are using 3ds max you can do it as well using the same aproach.

The 3D scene

maya geometry vray

The scene setup is really simple, position your geometry like the example image, intersecting each other like if you would do a geometry boolean. Next you will need to duplicate the “cutting” object (red one) and hide it (ctrl+h).

VrayDistanceTex

vraydistancetex maya 3dsmax

Create a VrayMtl and assign it to the sphere(your object). Next create a vrayDistanceTex and connect it to the “opacity map” of your material. Notice that the vrayDistanceTex created a selection set called “distTex_set1″. In 3ds max you have an option to add objects, in maya you have to use selection sets. Now drag your hidden duplicated object into the set1 in the outliner.

vraydistancetex settings

Change your settings in the vrayDistanceTex like the above image. Set an high distance like ’99999′, both far and near color to 100% white. and the inside color to black. Remember that we are sending this values to an opacity map, so the inside color set to black means that where the sphere is “inside” the cutting object it should be completlty transparent.

vray material maya

Now we will create the material for the visible cutting object. Connect a new vrayDistanceTex to the opacity map of this new shader. In the outliner drag the main object, in my scene is the sphere, to the new set created by the vrayDistanceTex. Copy the settings from your first vrayDistanceTex but invert the colors like you see in the above image.

boolean example

I made a simple example to follow along this tutorial, as you can see, “perfect” raytrace booleans. It’s easy to make small mistakes in this setup, so make sure:

- Don’t forget to assign the correct materials to the geometry, the hidden object can have just the default shader lambert1

- Change the diffuse colors of the materials so you can see the contrast/difference, like I did in the image above

-Be carefull if your are moving around the objects, make sure the hidden object is also moving, so better create a group or parent the cutting objects

-Don’t forget to set the same high distance in both textures

That’s it, not very complicated but you have to follow the steps to get the correct result. You will not be using this everyday but may come in handy in some situations. Use the comments below to let me know if you have any issues and if this was usefull.

  • omer

    Hi, Thank you very much for your youtube notice. This is also exactly how I did it by trying out a bit, but then my render time was like 10 min.+ for one frame. My scene had only one vary camera, vary sun and sky with indirect lighting and lowest sampling levels. I must admit I had a really dense mesh, about 700,000-1,000,000 polygons but still mental ray option was a bit faster. (puppet shaders for mental ray p_CSG shader) So did you had similar problems? What was the render times you had?

    • therenderblog

      Hi, my scene was really simple. This does add some render time, but it was less than a 2min render for the main image of the post. Probably it’s your dense mesh that is causing it. Did you try in some other test scenes?

  • Pingback: Maya | Creating Booleans at Render Time with V-Ray Using VRayDistanceTex

  • Pingback: Rendering | JokerMartini

  • Felipe

    Very usefull! Thanks.
    Vj Felipe @ Brazil

  • Pingback: inspired by growth » Maya | Creating Booleans at Render Time with V-Ray Using VRayDistanceTex

  • Burçe

    Very nice tip but i wonder if i can use this with a textured object?

    • therenderblog

      Why not? :)

  • Janna

    Is there a way to bake these booleans on the model itself? I’ve tried using Maya 2014 built in boolean tool but it cakes out at higher/complex models.

    • therenderblog

      I dont think so Janna, maya 2015 has some updates on booleans operations. You also need to consider the mesh you are using to cut the object, try add some resolution to it maybe.

      • Janna

        Hmmm.. okay. Thanks for the tip! I’ve tried that. The mesh I’m using as the boolean has its points right on top of the original mesh. So the topology on the edges match.. I figured if that happened, it would be easier to boolean but the meshes just disappear when I do the operation. I’ll try it on the 2015 though. Thanks!