Compositing Particles and Matte Geometry

Introduction

This topic 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 C4D: Enable “Save Occluded Particles Pass” under the “Output” tab of the KRAKATOA Settings dialog.
  • KRAKATOA SR: Use KRAKATOA_renderer::enable_occluded_rgba_render(true).

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.
  • While the example uses KRAKATOA MY, the same approach applies to all implementations of KRAKATOA.
  • The following image shows the KRAKATOA rendering of 43,590,568 particles generated by the PRT Volume from a Sphere polygon mesh.
../../_images/kmy_matte_buddha_in_sphere_v001.png

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:

../../_images/KMY_Matte_Buddha_KRA_ZOOM4_v001.png

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:

../../_images/kmy_matte_buddha_in_sphere_BG_v001.png

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

../../_images/KMY_Matte_Buddha_GEO_MayaSoftware_v001.png

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:

../../_images/KMY_Matte_Buddha_FGCOMP_v001.png

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

../../_images/KMY_Matte_Buddha_FGCOMP_ZOOM4_v001.png

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

../../_images/KMY_Matte_Buddha_FULLCOMP_v001.png

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:

../../_images/KMY_Matte_Buddha_FULLCOMP_ZOOM4_v001.png

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:
../../_images/KMY_Matte_Buddha_PRTCOMP_v001.png