# 1. URP Decals Mental Model and Setup Part of [[Decals and Environment Detail]]. Next: [[2. Environment Detail and Set Dressing]]. ## 1.1 How a URP decal works A Decal Projector is an **oriented box**. Every opaque pixel inside the box gets the decal material applied on top, using the box's local X/Y as UVs. The projection runs along the box's **local Z**, which is the white arrow in the Scene view. The decal wraps around anything in the box: a wall corner, a crate, a character's leg. That's why decals feel "stuck on" rather than floating. Two ways to apply it: | Technique | How | Good at | Cost | |---|---|---|---| | **DBuffer** | Decals render into extra decal buffers *before* opaques. Lit shaders read them while shading | Blends base colour, normal, metallic, AO and smoothness separately. The decal is properly lit | Needs a **depth-normals prepass** plus extra render targets. URP's own tooltip says that's not viable on tile-based mobile GPUs | | **Screen Space** | Decals render *after* opaques, as meshes over the scene, with normals reconstructed from depth | Cheap, no prepass | Can't blend each surface property separately. Normal reconstruction quality is a setting (Low = 1 sample, Medium = 5, High = 9) | **Automatic** (the default) picks **DBuffer** on desktop and console shader APIs, and **Screen Space** on mobile and OpenGL. In the Deferred path it uses **GBuffer** decals instead of Screen Space. This was read from the URP 17.5.0 source. **Limit:** decals don't project onto **transparent** surfaces (glass, water). Use a texture on the transparent material, or a mesh, instead. ## 1.2 Add the feature 1. Select your **Universal Renderer Data** asset (for example `PC_Renderer`). Each quality tier may have its own; see [[Scalability and Quality Tiers]]. 2. **Add Renderer Feature → Decal.** 3. Leave **Technique** on *Automatic* for now. Set **Max Draw Distance** to something sane for your game, for example 100. Decals farther than that are skipped regardless of the projector setting. 4. Leave **Use Rendering Layers** off until part 2. ## 1.3 Your first decal 1. **GameObject → Rendering → URP Decal Projector.** A box appears with an arrow. 2. In the projector's **Material** field, use **New → URP Decal**. That creates a material using `Shader Graphs/Decal`. Give it any texture with alpha, for example a stencilled arrow. 3. Rotate the projector so the arrow points **into** a wall, and move it so the wall surface sits inside the box. 4. Change **Width/Height** to size the decal, and **Projection Depth** so the box only reaches what it should paint. A deep box on a thin wall also paints the other side. ### Projector properties to know | Inspector | Script | Default | Use | |---|---|---|---| | Width / Height / Projection Depth | `size` | (1, 1, 1) | Box size in metres. Z is the depth | | Pivot | `pivot` | (0, 0, 0.5) | Box centre relative to the transform. The default puts the box *in front of* the transform along Z | | Tiling / Offset | `uvScale` / `uvBias` | (1, 1) / (0, 0) | Pick one cell of an atlas (part 3) | | Opacity | `fadeFactor` | 1 | Fade a decal in or out at runtime | | Draw Distance / Start Fade | `drawDistance` / `fadeScale` | 1000 / 0.9 | Per-projector culling and distance fade | | Angle Fade | `startAngleFade` / `endAngleFade` | 180 / 180 | Fade on surfaces turned away from the projection, which stops "stretched" smears on side faces | | Rendering Layers | `renderingLayerMask` | Default | Which renderers receive it (part 2) | | Scale Mode | `scaleMode` | Scale Invariant | Ignore or inherit the hierarchy scale | > [!important] 6000.2+ API change > The old decal layer mask is gone. The projector now uses `renderingLayerMask` (type `RenderingLayerMask`). The URP 17.5 source keeps the old serialized field only for migration (`#from(6000.2)`). Scripts that set `decalLayerMask` from older tutorials won't compile. ## 1.4 Check which technique you got Open the **Frame Debugger** (**Window → Analysis → Frame Debugger**) in Play Mode: - **DBuffer:** you'll see a depth-normals prepass and a DBuffer render pass before the opaques. - **Screen Space:** a decal draw after the opaques, and no extra prepass. On a PC build you'll usually see DBuffer, and on a Quest build Screen Space. If you need both platforms to look the same, set the technique explicitly per renderer asset instead of relying on Automatic (part 6).