๐ผ๏ธ Lesson 5.1: The URP Frame & the Frame Debugger
In Intermediate you authored materials with Shader Graph and never had to think about how a frame is drawn. This module goes below that line โ HLSL, custom passes, compute. But before you change the rendering, you have to see it. This lesson maps the anatomy of a single URP frame and hands you the tool that lets you step through it draw by draw: the Frame Debugger.
๐ฏ Learning Objectives
By the end of this lesson, you will be able to:
- Explain what the Scriptable Render Pipeline is and how URP renders per camera
- Name the major render passes of a URP frame and their order
- Identify the
RenderPassEventinjection points where custom work can hook in - Use the Frame Debugger to step through every draw call in a frame
- Read a frame to diagnose overdraw, batching, and pass ordering
Estimated Time: 60 minutes ยท Prerequisite: Intermediate Shader Graph & URP lighting; Module 2 Lesson 2.4 (batching)
In This Lesson
The Scriptable Render Pipeline
Unity's rendering is a Scriptable Render Pipeline (SRP) โ the whole "how to draw a frame" process is written in C# rather than baked into the engine. The Universal Render Pipeline (URP) is one such pipeline, tuned for a wide range of platforms; HDRP is another, tuned for high fidelity. Because it's code, you can read it, hook into it, and extend it โ which is exactly what this module does.
Each frame, for each active camera, URP does a culling pass (which objects and lights are visible?) and then executes an ordered list of render passes that fill in the final image. Understanding that ordered list is the key that unlocks everything else โ a custom shader runs inside one of those passes, and a custom Renderer Feature adds one.
๐ Definition
A render pass is one self-contained step that reads and writes render textures โ "draw all opaque objects," "draw the skybox," "apply post-processing." A frame is the ordered sequence of passes that turns a culled scene into the pixels on screen.
The Passes of a URP Frame
A typical URP frame runs these passes in order. The exact set depends on your renderer settings (a depth prepass, SSAO, decals, etc. may be added), but the backbone is consistent:
Two ordering facts matter constantly. Opaque geometry is drawn roughly front-to-back so the depth test rejects hidden pixels before they're shaded (cheap). Transparent geometry must be drawn back-to-front and can't rely on the depth buffer the same way, which is why transparency is more expensive and why overdraw hurts most there.
RenderPassEvent Injection Points
The gaps between those passes are named, and a custom pass declares where it runs by setting a RenderPassEvent. You'll use these constantly in Lesson 5.3:
| RenderPassEvent | Runsโฆ | Good for |
|---|---|---|
BeforeRenderingOpaques | before opaque geometry | clearing/preparing custom buffers |
AfterRenderingOpaques | after opaques, before skybox | effects on solid geometry (outlines) |
BeforeRenderingTransparents | before transparent geometry | refraction grabs, distortion setup |
BeforeRenderingPostProcessing | after transparents, before post | full-screen effects (blur, grade) |
AfterRenderingPostProcessing | after post, near the end | UI-space or final overlays |
Picking the right event is half of writing a Renderer Feature correctly โ inject a full-screen colour effect at BeforeRenderingPostProcessing, not before the objects it's supposed to affect have even been drawn.
The Frame Debugger
The Frame Debugger (Window โธ Analysis โธ Frame Debugger) freezes a frame and lets you step through every draw event in order, showing the screen build up one call at a time. It's the single best tool for understanding โ and diagnosing โ what your renderer is actually doing.
Reading a Frame
Step through a frame and you can answer questions that are otherwise guesswork:
- Is my batching working? If 500 opaque objects show up as 500 separate draws instead of a few SRP Batches, something is breaking the batch (a material keyword, an incompatible shader) โ the diagnosis you set up in Lesson 2.4.
- What's the draw order? Watch the screen fill in; if a custom effect appears before the objects it should modify, your
RenderPassEventis wrong. - Where's my overdraw? Transparent objects stacking up (particles, foliage) each add a full-screen-ish draw โ the Frame Debugger makes the pile visible.
- Which render target? Each event names the texture it writes (
_CameraColorAttachmentA, a shadow map, a temp RT) โ essential when you start creating your own targets in Lesson 5.3.
๐ก Habit worth forming. Whenever a rendering result looks wrong, open the Frame Debugger first. Nine times in ten the ordered event list shows you exactly which pass misbehaved, before you touch a line of shader code.
What's Ahead
You now have the map. The rest of Module 5 fills it in:
- Lesson 5.2 โ write the code that runs inside the opaque/transparent passes: HLSL shaders.
- Lesson 5.3 โ add your own passes at those
RenderPassEventinjection points: Scriptable Renderer Features. - Lesson 5.4 โ do general-purpose GPU work outside the draw passes entirely: compute shaders.
- Lesson 5.5 โ combine features and shaders into a custom full-screen post-process effect.
Every one of them lives somewhere on Figure 1. Keep that diagram in mind and the module stays concrete.
Hands-on Challenge
๐๏ธ Exercise 1: Dissect a real frame
Objective: Get fluent with the Frame Debugger.
- Open a scene with a handful of lit objects, some transparent particles, and post-processing (bloom).
- Open Window โธ Analysis โธ Frame Debugger and press Enable.
- Step from the first event to the last with the arrow keys. Note where shadows are drawn, where opaques finish and the skybox appears, and where post-processing kicks in.
- Find one opaque draw and read its shader/pass/output; find how many objects batched together.
๐ก What to look for
The event tree mirrors Figure 1: RenderShadows โ DrawOpaqueObjects โ DrawSkybox โ DrawTransparentObjects โ post โ FinalBlit. If your opaques are one or two SRP Batches, batching is healthy; if they're dozens of individual draws, note which material/shader is breaking it.
๐ฏ Quick Quiz
Question 1: Why are opaque objects drawn front-to-back?
Question 2: You want a full-screen colour effect applied after all geometry but before bloom/tonemapping. Which RenderPassEvent?
Question 3: The Frame Debugger shows 500 opaque objects as 500 separate draws. What does that indicate?
Summary
๐ Key Takeaways
- URP is a Scriptable Render Pipeline โ the frame is C# you can read and extend, run per camera after culling.
- A frame's backbone: shadows โ (depth) โ opaque โ skybox โ transparent โ post โ final blit.
- Opaques draw front-to-back (early-Z); transparents draw back-to-front (correct blending, more overdraw).
RenderPassEventnames the injection points where custom passes hook in โ choosing the right one is half the battle.- The Frame Debugger steps through every draw call โ your first stop for batching, ordering, overdraw, and render-target questions.
๐ What's Next?
You can see the frame; now you'll write the code that runs inside it. In Lesson 5.2: Writing Shaders in HLSL we leave Shader Graph behind and author a real URP shader by hand โ vertex and fragment stages, the URP shader library, and a genuine render of the result.
๐ผ๏ธ You can read a frame now
Passes in order, injection points between them, and a debugger to step through it all. Everything else in this module is a variation on that one picture.