# 3. ScriptableRendererFeature and AddBlitPass
Part of [[Custom URP Renderer Features]]. Prev: [[2. Full Screen Pass Renderer Feature]]. Next: [[4. RecordRenderGraph and Frame Data]].
When you need to toggle a pass from script, read a gameplay flag, or avoid the built-in Feature's Inspector-only setup, write a Feature. Official blit path (6000.5): `RenderGraphUtils.BlitMaterialParameters` + `renderGraph.AddBlitPass` in namespace `UnityEngine.Rendering.RenderGraphModule.Util`.
## 3.1 Feature + pass (not compiled)
```csharp
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.RenderGraphModule;
using UnityEngine.Rendering.RenderGraphModule.Util;
using UnityEngine.Rendering.Universal;
/// <summary>
/// Enqueues a full-screen blit. Confirm generic Get/CreateTexture overloads in your URP.
/// NOT compiled in Unity.
/// </summary>
public sealed class FullscreenFlashFeature : ScriptableRendererFeature
{
[SerializeField] Material material;
[SerializeField] RenderPassEvent injectionPoint = RenderPassEvent.AfterRenderingPostProcessing;
FlashPass pass;
public override void Create()
{
pass = new FlashPass();
pass.renderPassEvent = injectionPoint;
}
public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
{
if (material == null) return;
if (!pass.IsEnabled) return;
pass.Setup(material);
renderer.EnqueuePass(pass);
}
sealed class FlashPass : ScriptableRenderPass
{
Material material;
public bool IsEnabled { get; set; } = true;
public void Setup(Material mat) => material = mat;
public override void RecordRenderGraph(RenderGraph renderGraph, ContextContainer frameData)
{
if (material == null) return;
UniversalResourceData resources = frameData.Get<UniversalResourceData>();
TextureHandle source = resources.activeColorTexture;
if (!source.IsValid()) return;
// Confirm GetDescriptor / GetTextureDesc on your URP version.
TextureDesc desc = source.GetDescriptor(renderGraph);
desc.name = "_FullscreenFlash";
desc.depthBufferBits = 0;
TextureHandle destination = renderGraph.CreateTexture(desc);
var blitParams = new RenderGraphUtils.BlitMaterialParameters(source, destination, material, 0);
renderGraph.AddBlitPass(blitParams, "Fullscreen Flash");
// Official "avoid blitting back": retarget camera color at the destination.
resources.cameraColor = destination;
}
}
}
```
`Create` is where you construct the pass and set `renderPassEvent`. `AddRenderPasses` runs every frame, once per camera - enqueue or skip; do **not** try to read renderer camera targets here (Unity 6 upgrade notes moved that work out of `AddRenderPasses`). `RecordRenderGraph` is where textures are declared.
`RenderPassEvent.AfterRenderingPostProcessing` matches the built-in Feature's default injection point name. If an enum value is missing in your URP, look it up in the 6000.5 Scripting API rather than guessing.
`source.GetDescriptor(renderGraph)` and `source.IsValid()` should be confirmed in IntelliSense. If `GetDescriptor` is not on `TextureHandle`, the official write-pass sample uses `frameData.cameraDepthTexture.GetDescriptor(renderGraph)` as a size source - adapt from that, or from `renderGraph.GetTextureDesc` if that is what your API exposes.
## 3.2 Material
**Assets > Create > Shader > SRP Blit Shader**, material from that shader, assign it on the Feature. Keep the shader math in Shader Graph / the existing [[URP Shaders and Shader Graph]] note. This Feature only injects it.
A gameplay script can find the Feature on the renderer asset (or keep a static/toggle on the pass) to pulse a `_Flash` property. If you cannot get a clean public toggle without poking serialized renderer-asset lists, drive the **material** property from a singleton and skip enqueue when intensity is 0 - Render Graph can then cull a no-op if you also avoid `AllowPassCulling(false)`.
## 3.3 Exercise
Add the Feature to the renderer, assign the blit material, Play Mode, confirm the pass in the Render Graph Viewer. Disable the Feature on the asset and confirm it disappears. That is the hook the worked example will pulse.
## Sources
- Blit using the render graph system (6000.5): https://docs.unity.com/en-us/engine/6000.5/manual/render-pipelines/universal-render-pipeline/customizing-urp/render-graph/blit
- Write a render pass (6000.5): https://docs.unity.com/en-us/engine/6000.5/manual/render-pipelines/universal-render-pipeline/customizing-urp/render-graph/write-render-pass