Smooth Boolean Nodes and Material Blending
Contact Info
-
Name: Giorgio De Magistris
-
Blender Chat: giorgiodema
-
GitHub: github.com/giorgiodema
-
ShaderToy: shadertoy.com/user/dema
Synopsis
This project has two parallel goals: on the one hand it introduces new features to the Volume Nodes and in particular Smooth Booleans and Rounding, and on the other hand it brings Smooth Boolean operations directly to meshes (although they are implicitly converted to volume grids) with the additional feature of smoothly blending materials.
These operation can be implemented without much effort when the objects in the scene are represented implicitly as Signed Distance Fields (SDF), as shown in the [Inigo Quilezâs website (Inigo Quilez :: computer graphics, mathematics, shaders, fractals, demoscene and more).
The recently added Volume Nodes allow to convert a mesh to a SDF and vice versa, and the pull request Geometry Nodes: Add SDF grid boolean nodes #118879 introduced Boolean Nodes for SDF, but at the moment the Smooth versions of these operations are not available.
To validate the approach, I implemented a demo that shows how Smooth Booleans and Rounding can be applied to meshes by converting them into Volume grids and converting the result of the operation back to a mesh. The figure below shows an example of smooth union, with increasing degree of smoothness from left to right:
While the figure below shows an example of Rounding, with roundness increasing from left to right:
I also implemented a shader that shows how the materials can be smoothly blended by following the transition between the two geometries. The figure below compares the smooth boolean with material blending (first row) with the standard boolean operations (second row), where a diffuse material (plane) is joined with a tinted metallic object (sphere):
Benefits
The new Volume Nodes allowed to work with SDF in the geometry editor, but the number of operations that can be performed on the SDF grids is still limited. The pull request Geometry Nodes: Add SDF grid boolean nodes #118879 introduced boolean nodes, but the true power of the SDF modeling is the ability to compute smooth versions of these primitives. These new functionalities are introduced in the new SDF nodes.
The Mesh Smooth Boolean nodes allow to smoothly fuse objects and their materials. This cannot be accomplished with existing tools in Blender.
Smooth blending of shapes can be achieved with Metaballs, but with some important limitations:
- A limited set of primitives (Ball, Capsule, Plane, Ellipsoid, Cube)
- They do not allow to blend materials, since the same material is associated to the metaballs interacting together (controlled by the base metaball)
The Blender âMesh Booleanâ node maintains the material properties of the input shapes for their corresponding sections in the resultant shape, but it does not allow to smoothly blend shapes (like metaballs).
Moreover, in Blender, applying boolean operations on non-watertight meshes often leads to unpredictable results, as also stated in the official documentation. On the other hand, the method introduced here demonstrates resilience against such inputs.
The figure shows from left to right: the non watertight mesh (there are visible holes on the bottom), union and difference with smoothness set to zero.
Project Details
The Volume Nodes expose the OpenVDB grid in the Geometry Nodes editor. OpenVDB represents efficiently a SDF using a sparse data structure also decoupling the actual data from the geometrical transformations. It also provides functions to convert between Mesh and Volume Grid and the other way around. These functionalities are already exposed by the existing Volume Nodes. OpenVDB also implements standard CSG operations (Union, Intersection and Difference) and though these functionalities are not yet available in the Geometry Node Editor they have been already exposed in Blender in the already mentioned pull request Geometry Nodes: Add SDF grid boolean nodes #118879.
However the smooth boolean operations and rounding, that are the focus of this project are not yet available in openVDB. Hence this project aims at implementing these functionalities using the OpenVDB API and exposing them as new Volume Nodes.
These operations can be parallelized since they operate independently on each element of the grid (for the rounding operation) or on grid pairs (for the boolean operators).
The implementation of the Mesh Smooth Boolean nodes relies on the OpenVDB conversion methods and extends the previously defined functions (that compute the smooth booleans on volume grids) with the blend_factor. In this way, the result is a new grid with the SDF values of the resulting geometry and the blend factors (computed for each grid element). When the mesh is reconstructed from the resulting SDF grid, the blend factor can be attached to the vertices as a new attribute.
Deliverables
Similarly to the SDF Boolean Nodes introduced in Geometry Nodes: Add SDF grid boolean nodes #118879 this project introduces a new node Called SDF Smooth Boolean. This node has a dropdown menu that allows to select one operation between Union, Difference and Intersection and updates the socket accordingly. The mockup of the user interface is shown below:
The second SDF node is the SDF Rounding node, that allows to smooth corners and edges, the user interface is shown here:
As for the meshes, this project introduces the Mesh Smooth Boolean node, that allows to select an operation between Union, Difference and Intersection. Its interface is shown below:
The output mesh will have a vertex attribute called blend_factor with values in range [0,1] as shown in the figure below:
The blend_factor can be used in the Shader Editor to blend the two materials as shown below:
Project Schedule
I am currently a PhD student in Computer Science. During the whole period of the summer of code, I will be finishing my thesis and I will have no other commitments, hence I will be able to work to the project almost full time.
Period | Details |
---|---|
Community Bonding Period |
|
Week 1 - 6 | I will implement the operations (smooth booleans and rounding) using the OpenVDB API. In this phase I will not deal with the UI yet, but I will implement the core functions using the OpenVDB API and no other external dependency. This phase can be further subdivided into the following steps:
|
Week 7 - 8 | Implementation of the UI. In this phase I will implement the new nodes (Smooth Boolean and Rounding) and integrate them in the Blender UI. |
Week 9 | Integration tests |
Week 10-11 | I will produce the documentation and tutorials |
Week 12 | Buffer |
Bio
I am a third year PhD student in Engineering in Computer Science at Sapienza University of Rome. I am mainly interested in Computer Graphics and Machine Learning, and actually I am working on differentiable rendering and image based surface reconstruction. I am new to Blender development but I have experience in Computer Graphics and I am proficient in C/C++, shader programming (OpenGL/GLSL), Python and CUDA.
In the past I mainly used Blender for research purposes, but its great number of features sparked my interest and I started to learn more about its use for content creation. It would be a great pleasure for me to contribute to this awesome software by having the opportunity to learn from experienced programmers.
Blender Contributions
To get familiar with the Blender codebase I implemented a feature requested by the community: the introduction of the Focus on Collection
field in the Depth of Field
setting in the camera properties. The pull request can be accessed here.
During the implementation of this feature I came up with a possible improvement of the Depth of Field settings and I created a post in the forum to discuss it.