unity-graphics
Unity 6 graphics and rendering guide. Use when working with render pipelines (URP, HDRP, Built-in), shaders, Shader Graph, materials, textures, cameras, post-processing, or rendering optimization. Covers Render Graph, batching, draw call optimization, and GPU instancing. Based on Unity 6.3 LTS documentation.
Nice-Wolf-Studio · 已有静态检查记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add Nice-Wolf-Studio/unity-claude-skills --skill unity-graphics技能说明
name: unity-graphics description: > Unity 6 graphics and rendering guide. Use when working with render pipelines (URP, HDRP, Built-in), shaders, Shader Graph, materials, textures, cameras, post-processing, or rendering optimization. Covers Render Graph, batching, draw call optimization, and GPU instancing. Based on Unity 6.3 LTS documentation. globs:
- "**/*.shader"
- "**/*.hlsl"
- "**/*.shadergraph"
- "**/*.shadersubgraph"
- "**/*.mat"
Unity Graphics and Rendering
Render Pipeline Selection Guide
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:
- Need ray tracing, volumetric clouds, or physically-based sky? --> HDRP
- Need to target mobile, WebGL, or widest platform range? --> URP
- Maintaining a legacy project with no migration budget? --> Built-in
- Starting a new project? --> URP (most projects) or HDRP (high fidelity)
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 (Universal Render Pipeline)
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:
- Forward, Forward+, and Deferred rendering paths
- Anti-aliasing: FXAA, SMAA, TAA, MSAA
- 2D Renderer for 2D games
- Renderer Features for custom rendering injection
- SRP Batcher for draw call optimization
- Built-in post-processing via Volume system
See: references/urp-guide.md Source: URP
HDRP (High Definition Render Pipeline)
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:
- Physically-based lighting with Physical Light Units
- Material types: Lit, StackLit, Layered Lit, Hair, Fabric, Eye, AxF, Terrain
- Ray tracing: reflections, GI, shadows, AO, subsurface scattering
- Volumetric fog and volumetric clouds
- Physically Based Sky, HDRI Sky, Gradient Sky
- Path tracing with denoising (Optix, Intel Open Image Denoise)
- Water system with caustics and underwater rendering
- Dynamic resolution with DLSS, FSR 1.0, TAA Upscaling
See: references/hdrp-guide.md Source: HDRP
Shader Graph
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:
- String mode: Write HLSL directly; use
$precisiontoken for half/float - File mode: Reference external
.hlslfiles 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:
- Built-in:
BUILTIN_PIPELINE_CORE_INCLUDED - URP:
UNIVERSAL_PIPELINE_CORE_INCLUDED - HDRP:
UNITY_HEADER_HD_INCLUDED - Preview window:
SHADERGRAPH_PREVIEW
See: references/shader-graph.md Source: Shader Graph
Shaders
A shader is a program that runs on the GPU. Unity categorizes shaders into three types:
- Graphics Pipeline Shaders -- Most common; work with Shader objects to determine scene appearance
- Compute Shaders -- Perform GPU calculations outside the regular graphics pipeline
- Ray Tracing Shaders -- Handle ray tracing calculations (HDRP only)
Key terminology:
- Shader Object -- Instance of the
Shaderclass wrapping shad