When rendering refractive objects, it's important to pay attention to the interface (where objects meet). Poor settings may show artifacts like air gaps, incorrect coloring, or have wrong results when using caustics. Times to consider this workflow are when you are rendering things like liquids in glass, air bubbles in champagne or ice, or complex fluid simulations.
Typically users model such things by creating a boolean operation so that these surfaces never really touch one another, it's either/or and not both at the same time. This can be complicated to setup and nearly impossible when trying to use a simulation like flowing water to do this effect. So in RenderMan you can add an attribute to the shape called Intersection Priority. It's a simple number to specify priority where lower numbers are higher priority.
You can find the paper for this topic here:
- Charles M Schmidt, Brian Budge. Simple Nested Dielectrics in Ray Traced Images, 2002
We cache the IOR set in the material to determine the bending of rays, you can override this with an attribute or let the material set it itself.
Below are a few examples of different solutions.
To better understand the liquid placement, below are the possible options shown in a cross section of the glass.
- Coincident - This is where the surfaces perfectly meet. Notice the noisy artifacts where shading points fight one another in the same position.
- Shrink - This example slightly shrinks the liquid inside the glass but creates air gaps.
- Intersecting/Overlapping - This is the best placement to avoid problems but needs a better hint to the renderer that they have different priority.
RenderMan intersection priority and IOR assumes models are built volumetrically (no two-dimensional objects) with outward facing normals.
In the above examples, the overlapping liquid and glass is most similar to the correct method which uses overlapping but adds the Intersection Priority to the glass and liquid shapes. Notice the change in color for the liquid and how much better it captures the light and refractions. The glass has an Intersection Priority of 1 while the liquid is 2. If we were to add ice cubes those would be 3.
In some cases you may experience a small dark line where the geometry overlaps. To solve this you can create a Trace Bias attribute on the glass shape. By default this value is 0.0001 but can be increased in very small increments until the artifact is gone. Note that the attribute for Trace Auto Bias must be added to the object and turned off for manual trace bias settings to work unless the global setting for Trace Auto Bias is already off.
The glass scene is courtesy of Julien Duval.