RenderMan Artist Tools

PhotoRealistic RenderMan
Application Note #6

Simulating Reflections In A Flat Surface

May, 1990

To make a realistic computer-generated picture of a shiny surface it is usually necessary to simulate the reflections in the surface. Ray tracing can provide accurate reflections, but requires a great deal of CPU time. There are a number of less time-consuming ways to simulate reflections using PhotoRealistic RenderMan. None of these methods are effective and efficient in all situations. For good results, it's important that you choose the most appropriate method for your application.

This application note describes a method to simulate reflections in flat surfaces. The method uses a texture map and requires an additional rendering step to create the texture map from the scene description.

There are less expensive methods of simulating reflections with a lower degree of realism. In outdoor scenes, the sky is usually the dominant source of reflections. A simple shader which selects sky and ground colors based on the “up” component of the reflected vector gives an inexpensive impression of reflections without any additional rendering steps or texture files. This method works well for curved surfaces, but may give unconvincing results for large flat surfaces.

If the reflective surfaces are not flat, the technique described in this application note will not work. In this case, reflections can be simulated using environment textures. Additional rendering steps are needed to create the environment texture, and it takes longer to render the final image. Reflections in curved surfaces may be simulated quite accurately using environment maps, particularly if the reflected objects are not too close to the reflecting object. The environment map technique is far more realistic than the simple “sky and ground” reflection technique, but is far more expensive.

The criteria for selecting an appropriate method of simulating reflections are summarized in the table below.


Simulating reflections is particularly easy when the reflecting surface is flat (planar).

Imagine that you point a camera at a mirror and take a picture of the image reflected in the mirror (Figure 1a). Now imagine that the mirror is replaced with a clear glass window, and the camera is moved to an exactly opposite position on the other side of the window (Figure 1b). Take a second picture from the new vantage point with the camera looking into the room through the window. Remarkably enough, when you compare the two pictures, one is the “mirror image” of the other, that is, the same image with left and right reversed. This thought experiment suggests a technique for simulating reflections in a mirror or other flat surfaces in a computer-generated picture.

Surface TypeLevel of Realism RequiredBest MethodCost
All types LowSky and ground shaderLow
A single flat surfaceHighMethod described hereModerate
Curved, complexHighEnvironment mapsHigh

In the mathematical world of computer graphics, we can simulate a reflection exactly (including the left-right reversal) by reflecting the camera through the mirror, instead of simply moving it to the other side of the mirror.

Let's consider a particular example. The C program in the Appendix generates a RenderMan image of a simple room consisting of a floor and two adjacent walls. A mirror hangs on one wall and there is a teapot in front of the mirror. This scene is deliberately simplified to make the program easier to understand.

If the program is compiled and executed, it generates RenderMan calls that produce a picture of the room (called the “scene image”). Unfortunately, the mirror will not contain a reflection unless we do a little more work.

A reflected image is placed on the mirror by first rendering the reflection image using a reflected camera on the other side of the mirror, and then combining the reflection image with the scene image.

The steps of this procedure are as follows:

  1. Reflect the camera to the other side of the mirror surface.
  2. Modify the scene model by removing the reflecting surface and other surfaces that block the view of the reflected camera.
  3. Render the reflection image.
  4. Convert the reflection image into a reflection texture map.
  5. Apply a suitable shader to the reflecting surface; this shader uses the reflection texture to simulate the reflections.

Each of these steps is described in detail in the remainder of this application note.


The camera used to render the reflection image is simply the scene camera reflected through the reflection plane. In our example program, this is quite easy, since the mirror lies in the plane z=-0.05. (Figure 2 shows the example scene rendered without a reflection in the mirror.) If the reflection plane were z=0 in world space, the camera could be reflected by adding the command:

     RiScale(1., 1., -1.);

This scale operation does nothing except negate all of the z coordinates of the camera coordinate system. If the camera was positioned at (x, y, z) before the scale operation, it will be positioned at (x, y, -z) after the scale; this is, of course, the reflection of the original position with respect to the z=0 plane.

The case of reflection in the z=-0.05 plane is only slightly more difficult. First we translate the z=0 plane to the position of the actual reflection plane using an RiTranslate call, then do the scale operation, which reflects through z=0, and then translate the z=0 plane back to its original position.

RiTranslate(0., 0., -0.05);
RiScale(1., 1., -1.);
RiTranslate(0., 0., 0.05);

Notice that points which lie on the z=-0.05 plane in world space are unaffected by this sequence of transformations. In the example program, this sequence of transformations is performed in the SetupCamera routine when the preprocessor symbol REFLECTION is defined.

There is nothing special about z in the above procedure. The reflection through an x=k or y=k plane (for some number k) is very similar, simply negating the x or y coordinates using an appropriate RiScale call.

If the reflection plane is not aligned with the coordinate system axes, it's a little harder to reflect the camera through the reflection plane. Instead of using just an RiTranslate call to move the z=0 (or x=0 or y=0) plane to coincide with the reflection plane, it is necessary to use both an RiRotate and an RiTranslate. The axis of rotation is the cross product of the normal vectors of the reflection plane and the z=0 plane. The direction of translation is along the normal vector of the reflection plane. The inverse RiTranslate and RiRotate must be used to transform the reflection plane back to z=0 after the RiScale is applied. If you prefer, all of the rotations, translations, and scales can be combined into a single transformation matrix that can be applied using the RiConcatTransform call.


In order to render the reflection image, the model must be modified to eliminate surfaces that would lie between the reflected camera and the interesting part of the scene. This must be done by the programmer based on an examination of the model. In the example, both the mirror itself and the wall on which it hangs would block the view of the reflected camera, and so both surfaces are removed from the model in the SetupModel routine when REFLECTION is defined.

Since the reflection camera will be “looking out of the mirror,” it is safe to remove all surfaces from the scene that are at or behind the plane of the mirror (including the mirror itself). This will guarantee an unobstructed view for the reflection camera, and will increase the efficiency of rendering the reflection image.


If the example program is compiled with the preprocessor symbol REFLECTION defined, it will contain the RenderMan calls needed to render the reflection image that will appear reflected in the mirror when the final scene image is rendered. The reflection image is rendered into a TIFF file called refl.tif and then used to make a texture file (as described in the next section). It is most efficient to make the texture from a square image whose resolution is an integer power of 2. The scene image might not be square, so the pixel aspect ratio of the reflection image must be adjusted so that the reflection image covers the same screen window as the scene image. The screen window determines how much of the scene is visible in the image; since we will be combining the reflection image with the scene image later, the two images must cover the same screen window. In the example program, the calculation of the parameters for the RiFormat calls takes this effect into account.

Figure 3 shows the reflection texture rendered by the example program.


Having rendered the reflection image, we can make it into a texture file called refl.tex using the RiMakeTexture call as follows:

RiMakeTexture("refl.tif", "refl.tex",
         RI_BLACK, RI_BLACK,
         RiBoxFilter, 1., 1., RI_NULL);

The RI_BLACK parameters specify that the texture values outside the 0:1 texture coordinate range of the reflection map should be zero. If the reflection texture is used properly, values outside the 0:1 texture coordinate range should never be accessed, but the RiMakeTexture call requires the specification of a wrap mode and RI_BLACK is a reasonable choice. The filtering parameters RiBoxFilter, 1., 1. are the default values for RiMakeTexture. Currently RiMakeTexture requires these parameters, but PhotoRealistic RenderMan ignores them.

The equivalent txmake command is simply:

txmake refl.tif refl.tex


The mirror or other reflecting surface must have a surface shader that uses the texture map created in the preceding step. Each pixel on the mirror is shaded using the texture map that was created from the reflection image. The pixel position in the scene image is used to look up the correct pixels from the texture map. In effect, the two images are being composited, but only at the pixels where the mirror is visible in the scene image. The shader below (Listing 1) shows what is required.

Each point P on the mirror is shaded with a color from the texture map, multiplied by the surface color and opacity so that colored and partially transparent mirrors are possible. The texture coordinates used to access the texture map are simply the x and y components of PNDC. PNDC is the point P expressed in the NDC (normalized device coordinate) system, in which the x and y coordinates range from 0 to 1 across and down the image. (Important note: the NDC coordinate system is an extension provided by PhotoRealistic RenderMan; it is not described in the RenderMan Interface specification version 3.1.)

The simple shader shown here can be made more sophisticated by combining the reflection with a plastic shading model or a wood shading model. This would be appropriate to add reflections to a shiny floor or tabletop that is not a pure reflector like a mirror.

Figure 4 shows the example scene rendered with the reflection texture mapped onto the mirror.

Listing 1: A Reflection Shader

refl(string reflname = "refl.tex")
    point PNDC;

    PNDC = transform("NDC", P);
    Ci = Os * Cs * color texture(reflname, xcomp(PNDC), ycomp(PNDC));
    Oi = Os;

Appendix A: A C Program that Generates a Scene


Pixar Animation Studios
(510) 752-3000 (voice)   (510) 752-3151 (fax)
Copyright © 1996- Pixar. All rights reserved.
RenderMan® is a registered trademark of Pixar.