RSS< Twitter< etc

Compositing Particles and Matte Geometry

Last Edited on 2013/04/05 @4:30 pm PST


This document explains why Krakatoa renders don't have visible "anti-aliasing" around mesh holdouts, and how to properly composite a Krakatoa render with a geometry render.

Compositing volumetric data with geometry renders presents a unique set of issues. Krakatoa is a dedicated volumetric renderer. It renders only particles, either as points, or as voxels. Scene geometry is only rendered as Mattes (Holdouts).


The Problem

There are three cases for mixing geometry and particle renders:

Case 1: The particles are all behind the geometry

  • Easy. Render Krakatoa without Holdouts and composite the geometry over the particles.

Case 2: The particles are all in front of the geometry

  • Easy. Render Krakatoa without Holdouts and composite the particles over the geometry.

Case 3: The particles are both behind and in front of geometry.

  • This case is more complex. 
  • Some of the particles are "over" the geometry, and some are "under" the geometry.
  • Normally, the under particles are removed by the cutout, however this presents a concern where the geometry is semi-transparent like around antialiased edges. So the compositing can no longer be done as a simple "over" operator.
  • Krakatoa can't draw a particle that is semi-occluded by a holdout at a lesser opacity. The reason it can't is because the resulting image cannot then be composited using an "over" operator. If they were composited with "over", the result would be incorrect and the alpha would be wrong.
  • This is the reason that cutout edges apear to not have anti-aliasing.

The Solution

  • Krakatoa gets around this by rendering two particle layers:
    • A "foreground" rbga image (with all particles in front of occlusion samples), and 
    • a "background" rgba image (with all the particles behind either fully or semi-occluded samples). 
  • The compositing is then done using three layers - Krakatoa Foreground (over) Geometry render (over) Krakatoa Background.

Enabling "Background" particle render:

  • Krakatoa MY: Enable "Save Occluded Particles Pass" under the "Render Output and Passes" renderer rollout.
  • Krakatoa MX: Enable "Save Multiple Layers" under the "Matte Objects" renderer rollout. Doing so will enable a special render-element.
  • Krakatoa SR: Use krakatoa_renderer::enable_occluded_rgba_render(true) (C++), or ri.Display( "+occluded_particle_output.exr", "file", "occluded" ) (Python).

Case 3 Example

In the following example, we will render a PRT Volume in the shape of a Sphere, occluded by the mesh of the Stanford Buddha Statue set as Matte geometry.

The following image shows the Krakatoa rendering of 43,590,568 particles generated by the PRT Volume from a Sphere polygon mesh. 

Below is a portion of the image, magnified 4x - as you can see, the edges of the Matte object are aliased, because any particle that is even slightly behind the mesh has been skipped:


By activating the "Occluded Particles" layer in the OpenEXR output, we are not simply skipping the occluded particles, but we are sending them to the background layer:

We can now render the Buddha Statue mesh using the Maya Software renderer and try to composite the result with the Krakatoa particles:

Attempting to composite only the Krakatoa foreground rendering over the Maya Software rendering output will produce jagged edges due to the lack of Anti-Aliasing information in the Krakatoa pass:

Here is the 4x magnification of a portion of the above image - notice the black spots at the edges:

The correct way to handle this situation is to composite all three layers: foreground particles over geometry over background particles:

As you can see from the following 4x magnification, the edges are now clean, because the geometry image's anti-aliased Alpha reveals particles from the Krakatoa background layer:

Remaining Issues

The above image shows one problem that this approach cannot solve:  At the edge of the head overlaying the arm, we have two geometry objects with particles between them. Since all particles are sent to the background layer when they are even partially occluded by ANY geometry, the particles between the head and the arm at the Anti-Aliased edge have been lost. This produces a rough edge in that particular area.

The only solution for this problem would be Deep Compositing which is not available in Krakatoa yet.

Casting Shadows Only

Compositing only the two particles passes without the geometry pass between them can produce a Ghost effect where an invisible object casts shadows in the particle volume: