Page 12: Multi-Pass Rendering

Spring 2026 Sample Solution

On this page, we’ll focus on a particular kind of multi-pass rendering: where we draw the scene from some other viewpoint other than the camera’s that is ultimately making the picture, store that picture somewhere, and use it (often as a texture) when we make the final picture.

The other kind of multi-pass rendering (optional)

An optional digression…

This page talks about “a particular kind of multi-pass rendering: where we draw the scene from some other viewpoint other than the camera’s”. You might wonder about the other kind: where we simply draw things multiple times.

Redrawing an object multiple times is a trick that is used to create advanced visual effects, to work around the limitations of the hardware, or as an efficiency trick (yes, in some cases, it is faster to draw twice with simple appearances than once with complex ones).

The problem with teaching these (redrawing) methods is that they change very quickly: they depend a lot on the hardware. The tricks become obsolete when the hardware changes. Most of the tricks we used to teach can now be accomplished in a single pass by writing a shader.

For example, in the old days, we used redraw multi-pass to combine multiple textures - but now we can do it in the shaders. Similarly, hardware used to be limited to a small number of lights. To simulate more lights we would draw the object multiple times, each time with different lights.

The limitations of the rendering pipeline

Remember that each triangle must be independent. Therefore, the color of a triangle cannot depend on another triangle. The triangles can’t “see” the other triangles in a scene.

Imagine that we want to put a picture on the wall of what the scene looks like. We want to determine the colors of that picture from the other objects of the scene (so it’s a picture of what is in the scene).

Here’s a simple example (thanks to Co-Pilot/Codex):

The trick: the picture can’t see the other objects. It has a texture map. But how do we get a texture map that is a picture of the other objects?

The answer is relatively simple: we draw the picture, but rather than putting the resulting pixels on the screen, we put them into a texture map that can be used by other objects. This is called render to texture. Notice that this requires two “passes” (we draw the scene twice). We draw once to draw into the texture. Then we draw a second time to draw to the screen (using that texture we just made). If you look carefully, you’ll notice that the picture on the wall in the scene is blank because that picture was made before there was a texture to paint the picture with.

This example uses the main camera to take a picture of a still-life scene exactly once, then places that frozen image into a picture frame on the wall behind the table. If you orbit or pan the camera after startup, the wall picture does not update. The render-to-texture pass runs on the first frame only.

Why draw twice?

In this special case, we used the same camera to make both pictures. So, in theory we could have drawn once and just copied the pixels into both places.

For a number of practical reasons, this is tricky to implement. A simple reason: the screen image and the texture image may be different sizes.

In practice, we usually don’t use the same camera for both the “main” pass and the render-to-texture pass. So, making the special case where we might be able to copy the image rather than drawing twice isn’t worthwhile.

Dynamic Texture Maps

A problem in that first example is that the texture is static. We compute it at the beginning and use it over and over. We don’t need to do this: we could recompute the texture every frame. Yes, that means we draw the frame twice each time (once for each pass), but we generally have enough graphics performance to do this.

Here’s the same still-life setup, but with the wall picture updated every frame from the main camera:

Now if you move the camera, the wall picture changes as well, because the render-to-texture pass runs every frame.

If you notice, the picture on the wall in the scene is still black. We are avoiding the “recursive” drawing (this is called a “feedback loop”).

This idea of updating the texture map to match the action in the scene is called a dynamic texture map.

Dynamic texture maps are useful for many things, for example:

  • Reflections (we take a picture of what the mirror sees and put that on the mirror, this is kind of a simple form of Environment Map)
  • Shadows (we take a picture of what the light sees, and only light those parts)
  • Environments (rather than pre-painting an environment map, we render a picture of the world so the correct things show up)
  • Picture in Picture effects - you could put a television showing what a camera elsewhere in the scene is pointing at

From an implementation perspective, these things involve:

  1. Setting up an additional camera
  2. Rendering a picture from that camera’s viewpoint and storing the picture in a texture. This is called render to texture.
  3. Using that rendered texture when we ultimately draw the scene.

Another Example

In this example, we have a camera that flies around in the scene. We use the picture that camera takes as a texture. We show the texture on a big plane - so it’s like showing the camera footage on a big TV (or projector screen).

AI Notes

I had Co-Pilot with Codex make this example. It was able to do it in the class framework. Notice, however, that it forgot that the camera sights down the negative Z axis, so the black cone (which I assume is meant to be the lens) points the wrong way. Or maybe it meant that the cone is an arrow pointing in the camera line of sight direction. Either may, the three.js CameraHelper points the right way.

Co-Pilot also drafted the documentation.

This demo shows the classic “camera to texture” multi-pass workflow.

First, we create a second camera that is attached to a visible moving object in the scene (a camera rig). That camera is not the main viewer camera. Instead, it is a capture camera whose job is to make an image we can reuse.

Second, we create a WebGLRenderTarget, which is an off-screen image buffer. On each frame, we ask the renderer to draw the scene from the capture camera into that render target.

Third, we use renderTarget.texture as the map of a material on a large square “monitor” in the world. Because the texture is updated every frame, the monitor becomes a live video feed of what the moving camera sees.

In pseudocode, the key per-frame operations are:

1
2
3
renderer.setRenderTarget(renderTarget);      // draw off-screen
renderer.render(scene, captureCamera);       // make the camera image
renderer.setRenderTarget(previousTarget);    // restore normal drawing

The most important practical detail is preventing feedback loops. If the capture camera can see the monitor surface that is displaying its own render target, it is effectively taking a picture of itself. That can cause recursive artifacts or WebGL warnings.

To avoid this, the demo places the monitor (and helper visuals) on a different rendering layer from the one the capture camera sees. The main world camera sees both layers, but the capture camera is restricted to the layer without the monitor.

You can use the same pattern for security-camera effects, mirrors, mini-maps, and other picture-in-picture interfaces.

Summary: Dynamic Texture Maps

Dynamic textures give us a “hack” that lets our objects “see” each other (have their appearance affected by other objects). The mechanism is simple - we make an extra drawing pass to make a picture of the world in a texture. This has a cost (we need to draw multiple times), but it allows us to use the mechanisms of the rasterization pipeline (drawing, textures) to achieve complicated effects.

On the next few pages, we’ll use it for some useful things.

Next: Page  13 - Dynamic Environment Maps