From unity
A render pipeline performs a series of operations that take the contents of a scene and displays them on a screen. Unity provides three render pipelines:
npx claudepluginhub cdata/aria-skills --plugin unityThis skill uses the workspace's default tool permissions.
A render pipeline performs a series of operations that take the contents of a scene and displays them on a screen. Unity provides three render pipelines:
Provides Unity rendering reference for shaders (Shader Graph, HLSL, ShaderLab), pipelines (Built-in, URP, HDRP), lighting/GI, VFX Graph, post-processing, and effects like dissolve, outlines, toon shading.
Guides selection and operation of Unity URP/HDRP render pipelines based on platform targets, visual goals, shaders, and team capabilities. Documents constraints, migration risks, and performance expectations.
3D graphics, shaders, VFX, lighting, rendering optimization. Create stunning visuals with production-ready techniques.
Share bugs, ideas, or general feedback.
A render pipeline performs a series of operations that take the contents of a scene and displays them on a screen. Unity provides three render pipelines:
| Criteria | Built-in Render Pipeline | Universal Render Pipeline (URP) | High Definition Render Pipeline (HDRP) |
|---|---|---|---|
| Target | Legacy projects | Mobile to high-end consoles/PCs | AAA, automotive, architectural |
| Customization | Limited | Scriptable, extensible via Renderer Features | Scriptable, Custom Passes, Full Frame Settings |
| Rendering Paths | Forward, Deferred | Forward, Forward+, Deferred | Forward, Deferred (hybrid tile/cluster) |
| Shader Authoring | ShaderLab + Surface Shaders | Shader Graph (recommended), HLSL | Shader Graph (recommended), HLSL |
| SRP Batcher | No | Yes | Yes |
| Ray Tracing | No | No | Yes (DXR) |
| Volumetrics | No | No | Yes (fog, clouds) |
| Anti-Aliasing | MSAA | FXAA, SMAA, TAA, MSAA | FXAA, SMAA, TAA, MSAA |
| Platforms | All | All (scalable) | High-end (DX11/12, Metal, Vulkan) |
| GPU Requirement | Standard | Standard | Compute shader capable |
Decision flow:
Warning: Render pipelines are NOT interchangeable. Materials, shaders, and post-processing from one pipeline do not work in another without conversion. Upgrading Built-in materials to URP/HDRP requires the pipeline's material upgrader; objects render bright pink if their shader is incompatible.
Source: Render Pipelines
URP is a prebuilt Scriptable Render Pipeline made by Unity for creating optimized graphics across a range of platforms, from mobile to high-end consoles and PCs.
Key features:
See: references/urp-guide.md Source: URP
HDRP is a prebuilt Scriptable Render Pipeline targeting AAA-quality games, automotive demos, and architectural visualization on high-end hardware. It requires compute shader-capable GPUs (DirectX 11/12, Metal, Vulkan).
Key features:
See: references/hdrp-guide.md Source: HDRP
Shader Graph enables building shaders visually by creating and connecting nodes in a graph framework instead of writing code. Changes are reflected with instant feedback.
Render pipeline compatibility:
| Pipeline | Supported |
|---|---|
| URP | Yes |
| HDRP | Yes |
| Built-in Render Pipeline | Yes |
| Custom SRP | No |
Shader Graph is included automatically when you install URP or HDRP.
Custom Function Node -- Inject custom HLSL code into Shader Graphs:
$precision token for half/float.hlsl files with include guards// File mode example with include guards
//UNITY_SHADER_NO_UPGRADE
#ifndef MYHLSLINCLUDE_INCLUDED
#define MYHLSLINCLUDE_INCLUDED
void MyFunction_float(float3 A, float B, out float3 Out)
{
Out = A + B;
}
#endif //MYHLSLINCLUDE_INCLUDED
Pipeline detection in Custom Function nodes:
#ifdef SHADERGRAPH_PREVIEW
half3 color = half3(0,0,0);
#else
#if defined(UNIVERSAL_PIPELINE_CORE_INCLUDED)
half4 shadowCoord = TransformWorldToShadowCoord(WorldPosition);
Light mainLight = GetMainLight(shadowCoord);
half3 color = mainLight.color;
#else
half3 color = half3(0, 0, 0);
#endif
#endif
Conditional keywords by pipeline:
BUILTIN_PIPELINE_CORE_INCLUDEDUNIVERSAL_PIPELINE_CORE_INCLUDEDUNITY_HEADER_HD_INCLUDEDSHADERGRAPH_PREVIEWSee: references/shader-graph.md Source: Shader Graph
A shader is a program that runs on the GPU. Unity categorizes shaders into three types:
Key terminology:
Shader class wrapping shader programs and GPU instructions.shader file defining a Shader objectSurface Shaders (Built-in pipeline ONLY):
HLSL in ShaderLab:
HLSLPROGRAM directive to add shader code to Pass blocks#pragma directives to control compilationSource: Shaders Introduction
Materials and shaders work together to define the appearance of a scene.
Key workflows:
Material API -- Key properties and methods:
| Property/Method | Purpose |
|---|---|
color | Main color of the material |
mainTexture | Primary texture |
shader | Assigned shader reference |
renderQueue | Render order override |
enableInstancing | GPU instancing toggle |
SetColor(name, color) | Change a color property |
SetFloat(name, value) | Set a float property |
SetTexture(name, texture) | Assign a texture |
SetVector(name, vector) | Set a vector property |
SetMatrix(name, matrix) | Set a matrix property |
HasProperty(name) | Check if property exists |
EnableKeyword(keyword) | Enable a shader keyword |
CopyPropertiesFromMaterial(mat) | Copy from another material |
Lerp(start, end, t) | Interpolate between materials |
Important: Set your desired shader BEFORE modifying properties. Property assignments have no effect if the current shader does not support them.
Textures are bitmap images applied to mesh surfaces. Key concepts:
See: references/materials-textures.md Source: Materials, Textures
Cameras create an image of a particular viewpoint in a scene, with output displayed on-screen or captured as a texture.
Projection modes:
Key details:
Common camera setups:
Source: Cameras
Post-processing effects simulate physical camera/film properties or enable stylized visuals.
| Pipeline | Post-Processing Solution |
|---|---|
| URP | Built-in (installed with URP template) |
| HDRP | Built-in (installed with HDRP template) |
| Built-in | Post-Processing Version 2 package (separate) |
Warning: Post-processing solutions are NOT interchangeable across render pipelines. Each pipeline's effects and implementation methods differ.
HDRP anti-aliasing options:
HDRP exposure: Histogram-based with percentile selection, metering modes, and pre-exposure for precision with Physical Light Units.
Source: Post-Processing
The Render Graph system provides a high-level representation of custom SRP render passes, explicitly stating how passes use resources. Both URP and HDRP use Render Graph.
TextureHandle, BufferHandle, RendererListHandle instead of direct referencesusing UnityEngine.Rendering;
using UnityEngine.Rendering.RenderGraphModule;
// 1. Define pass data
class MyPassData { public TextureHandle input, output; public float param; }
// 2. Create and configure pass
using (var builder = renderGraph.AddRenderPass<MyPassData>("MyPass", out var passData))
{
passData.input = builder.ReadTexture(inputTexture);
passData.output = builder.UseColorBuffer(
renderGraph.CreateTexture(new TextureDesc(Vector2.one, true, true)
{ colorFormat = GraphicsFormat.R8G8B8A8_UNorm, name = "Output" }), 0);
passData.param = 2.5f;
builder.SetRenderFunc((MyPassData data, RenderGraphContext ctx) =>
{
var mpb = ctx.renderGraphPool.GetTempMaterialPropertyBlock();
mpb.SetTexture("_MainTexture", data.input);
mpb.SetFloat("_FloatParam", data.param);
CoreUtils.DrawFullScreen(ctx.cmd, material, mpb);
});
}
// 3. Lifecycle: new RenderGraph() -> BeginRecording() -> AddPasses -> EndRecordingAndExecute() -> Cleanup()
| Method | Purpose |
|---|---|
ReadTexture / WriteTexture | Declare texture read/write dependency |
UseColorBuffer / UseDepthBuffer | Write + auto-bind as render/depth target |
CreateTransientTexture | Temporary texture scoped to pass |
ReadComputeBuffer / WriteComputeBuffer | Declare buffer read/write |
UseRendererList | Declare renderer list usage |
SetRenderFunc | Set rendering callback |
EnableAsyncCompute / AllowPassCulling | Control pass behavior |
Resource creation: CreateTexture(), CreateComputeBuffer(), CreateRendererList()
Import external: ImportTexture(), ImportBackbuffer(), ImportBuffer()
Source: Render Graph
Batching combines meshes using the same material so Unity renders them with fewer render state updates.
SRP Batcher (URP/HDRP only):
Static Batching:
Dynamic Batching:
GPU Instancing:
Material.enableInstancingPrevents rendering of GameObjects hidden behind others. Works with frustum culling.
Source: Draw Call Batching, SRP Batcher
// Set shader before modifying properties
material.SetColor("_BaseColor", Color.red);
material.SetFloat("_Smoothness", 0.8f);
material.SetTexture("_BaseMap", myTexture);
if (material.HasProperty("_Metallic"))
material.SetFloat("_Metallic", 1.0f);
material.EnableKeyword("_EMISSION");
Renderer rend = GetComponent<Renderer>();
rend.material.color = Color.blue; // SAFE: creates per-object instance
// rend.sharedMaterial.color = Color.blue; // DANGEROUS: modifies asset for ALL objects
// WARNING: MaterialPropertyBlock BREAKS SRP Batcher compatibility.
// Use only when SRP Batcher is not critical (e.g., Built-in pipeline, few unique objects).
// For SRP Batcher-compatible per-object variation, use GPU Instancing with instance properties
// or create material instances via renderer.material.
private static readonly int BaseColorID = Shader.PropertyToID("_BaseColor");
private MaterialPropertyBlock _propBlock = new MaterialPropertyBlock();
void SetColor(Color color)
{
Renderer rend = GetComponent<Renderer>();
rend.GetPropertyBlock(_propBlock);
_propBlock.SetColor(BaseColorID, color);
rend.SetPropertyBlock(_propBlock);
}
| Anti-Pattern | Problem | Solution |
|---|---|---|
Modifying renderer.sharedMaterial at runtime | Changes the material asset; affects ALL objects using it | Use renderer.material (creates instance) or MaterialPropertyBlock |
| Creating new Material instances every frame | Memory leak; unbounded allocations | Cache material instances; use MaterialPropertyBlock for per-object variation |
| Using Surface Shaders in URP/HDRP | Not supported; will fail or render pink | Use Shader Graph or write HLSL shaders |
| Mixing render pipeline assets | Shaders/materials from wrong pipeline render pink | Use pipeline-specific shaders; run material upgrader when switching |
| Non-power-of-two texture dimensions | Compression fails; higher memory usage | Use 32, 64, 128, 256, 512, 1024, 2048, 4096 |
| Enabling dynamic batching by default | CPU overhead often exceeds draw call savings | Prefer SRP Batcher (URP/HDRP) or static batching |
| Too many shader variants | Increased build time, memory, and load time | Strip unused variants; minimize keyword usage |
Using Shader.Find() at runtime | Slow; may fail if shader not included in build | Cache shader references; assign in Inspector |
Forgetting to call m_RenderGraph.Cleanup() | GPU resource leak | Always cleanup in pipeline Dispose() |
| Ignoring render queue for transparent objects | Z-fighting, incorrect sort order | Set appropriate renderQueue; sort transparent back-to-front |
| Class/Struct | Namespace | Purpose |
|---|---|---|
Material | UnityEngine | Controls shader properties on a renderer |
Shader | UnityEngine | References compiled shader programs |
Texture2D | UnityEngine | 2D texture asset |
RenderTexture | UnityEngine | GPU-rendered texture target |
Camera | UnityEngine | Scene viewpoint and rendering control |
Renderer | UnityEngine | Base class for all renderers |
MaterialPropertyBlock | UnityEngine | Per-object shader properties without instancing |
CommandBuffer | UnityEngine.Rendering | GPU command list |
RenderGraph | UnityEngine.Rendering.RenderGraphModule | Frame render pass management |
TextureHandle | UnityEngine.Rendering.RenderGraphModule | Render Graph texture reference |
BufferHandle | UnityEngine.Rendering.RenderGraphModule | Render Graph buffer reference |
RenderGraphBuilder | UnityEngine.Rendering.RenderGraphModule | Configures individual render passes |
CoreUtils | UnityEngine.Rendering | Utility methods (DrawFullScreen, etc.) |
Volume | UnityEngine.Rendering | Post-processing/environment effect container |
VolumeProfile | UnityEngine.Rendering | Collection of volume effect overrides |