Fractional Matte Objects
Fractional Matte Objects
July, 1999
Contents:
- Introduction
- How Matte Objects Worked Previously
- The Problem With Transparency
- The Solution: Fractional Mattes
- Appendix: The Mathematical Details
Introduction
Matte objects are typically used to divide a rendered frame into a number of elements which can be processed separately and recombined later, perhaps with other live action elements interspersed.Beginning with the 3.9 Release, PhotoRealistic RenderMan support the concept of fractional mattes. Matte objects no longer necessarilly cull all of the objects which appear behind them. The opacity of the matte object is allowed to decide how much of the objects behind are visible. This allows mattes to be created of scenes with semi transparent objects in a way which is a consistent generalization of the old behavior. This note helps describe this new semantics in detail, and illustrates how it might be useful.
How Matte Objects Used to Work
To help illustrate how matte objects previously worked, we will use a simple scene consisting of two squares, with the red square in front of the green square.We can generate two more images, one of the red object with the green matted out, and the other of the green image with the red object matted out.
We can regenerate the original image from the two sub images by simply adding the colors at every pixel. This is very similar to what actually happens with compositing which is done with conventional film processes.
The Problem With Transparency
The problem with the original implementation of matte objects is that they don't generalize to the case where one of the objects is transparent. Imagine now that the foreground object has a pattern which is partially transparent.The Solution: Fractional Matte Objects
Beginning with 3.9, we properly account for foreground objects with transparency. Now, when you generate the background object with the semitransparent foreground object matted out, you get the parts of the background object which would normally be visible through the foreground object.Appendix: The Mathematical Details
If you aren't familiar or don't care about the mathematical details, you can skip this section with merely the knowledge that it is okay to use transparency in matte objects. If you like to understand precisely how the new fractional matte objects work, then read on.We begin by thinking of precisely what we wish to have happen. We have several constraints in mind:
Opaque matte objects should behave as previously defined, namely by hiding all objects which occur behind them.Normally at each pixel we resolve the visibility of transparent objects by using the over compositing rule. The rule says that to compute the color of A over B, we apply the following rules:
Completely transparent matte objects should behave as if they weren't there at all, causing no modification to any pixel values.
In any case where we have two objects A and B, the sum of (A matte B) and (B matte A) should equal the image with A and B.
Color(A) over Color(B) = Color (A) + (1 - Alpha(A)) * Color(B)If A was a matte object previously though, we had a different rule. The color of a matte object was always defined as transparent black, no matter what it's actual color or alpha values were, or whatever objects you had behind it. If A was a matte object, you might have written this rule as
Alpha(A) over Alpha(B) = Alpha(A) + (1 - Alpha(A)) * Alpha(B)
Color(Amatte) over Color(B) = blackWhat we really desire is to allow some of the background object to show through when A is a transparent matte object. In fact, when A is perfectly transparent, it should act as if A was not there at all. Some head scratching will eventually lead you to the following formulas:
Alpha(Amatte) over Alpha(B) = 0
Color(Amatte) over Color(B) = LERP(Color(B), Black, Alpha(Amatte))where LERP(a, b, t) = (1 - t) * a + t * b, the conventional linear interpolation function.
Alpha(Amatte) over Alpha(B) = LERP(Alpha(B), 0, Alpha(Amatte))
Pixar
Animation Studios
|