界面已本地化;技能原文保持作者语言。部分长说明页面以英语提供。
探索技能
开发与工程 · SKILL.md

unity-rendering

unity-rendering

【开发与工程】Unity rendering pipelines (Built-in / URP / HDRP), Shader Graph, Renderer Features, Volume framework, post-processing, materials, lighting, and GPU Resident Drawer. USE WHEN: choosing or migrating rendering pipeline, writing/editing shaders (Shader Graph, HLSL, ShaderLab), tuning lighting, debugging draw calls, configuring Volume profiles, custom re…

独立 GitHub 快照 · 自动分类 · 以原作者文档为准

技能说明

GitHub

name: unity-rendering description: | Unity rendering pipelines (Built-in / URP / HDRP), Shader Graph, Renderer Features, Volume framework, post-processing, materials, lighting, and GPU Resident Drawer.

USE WHEN: choosing or migrating rendering pipeline, writing/editing shaders (Shader Graph, HLSL, ShaderLab), tuning lighting, debugging draw calls, configuring Volume profiles, custom render passes.

DO NOT USE FOR: 2D Renderer specifics (use unity-2d-lighting); UI Toolkit rendering (use unity-input-ui); profiling-only questions (use unity-performance). allowed-tools: Read, Grep, Glob, Write, Edit

Unity Rendering

Pipeline selection

PipelineUse whenAvoid when
URPMobile, indie, mid-fidelity, broad platform reach, custom Renderer FeaturesCinematic AAA, volumetrics, screen-space GI
HDRPHigh-end PC/console, photoreal, advanced lightingMobile, WebGL, low-spec hardware
Built-inLegacy projects, very specific shaders not portableNew projects (default to URP)

Switching pipeline mid-project is painful — pick once, upfront.

Shader Graph (URP/HDRP)

Vertex stage  → object-space → world-space transforms, vertex displacement
Fragment      → albedo, normal, metallic, smoothness, emission, AO
Custom Function node → write HLSL inline for branchless ops
Subgraph      → reusable groups; export as .shadersubgraph

Author URP shaders in Shader Graph by default. Drop to handwritten ShaderLab/HLSL only when SG can't express the math (e.g. compute, geometry, custom render textures).

Volume framework (URP/HDRP)

// Per-camera profile override
var volume = camera.GetComponent<Volume>();
if (volume.profile.TryGet<Bloom>(out var bloom)) {
    bloom.intensity.value = 1.5f;
    bloom.threshold.value = 0.9f;
}

Global volume + per-trigger local volumes; use weights for smooth transitions (e.g. entering interior).

Renderer Features (URP)

Add custom passes (outline, fog, decal) by extending ScriptableRendererFeature + ScriptableRenderPass. Inject at BeforeRenderingTransparents, AfterRenderingPostProcessing, etc.

public class OutlineFeature : ScriptableRendererFeature {
    public Material outlineMat;
    OutlinePass _pass;
    public override void Create() => _pass = new OutlinePass(outlineMat);
    public override void AddRenderPasses(ScriptableRenderer r, ref RenderingData d)
        => r.EnqueuePass(_pass);
}

GPU Resident Drawer / BatchRendererGroup (Unity 6)

Big draw-call wins for static + lots of instances. Toggle GPU Resident Drawer in Quality settings; objects must be Static + share materials/meshes; auto-instances them on the GPU.

Lighting

NeedUse
Static scenes (level geo)Baked Global Illumination (Progressive Lightmapper GPU) + Light Probes for dynamic objects
Outdoor day-night cycleMixed lighting (Shadowmask) + dynamic skybox
Stylized cel-shadingCustom Shader Graph with ramp texture
HDRP photorealVolumetric lights + Screen-Space GI + Adaptive Probe Volumes

Reflection Probes: bake on key viewpoints; use box projection for indoors; pure realtime probes only for hero objects.

Anti-patterns

Anti-patternFix
Different shader per material variantMaterial Property Block via Renderer.SetPropertyBlock
Switching shaders at runtimePre-warm with shader variants collection asset
Per-frame material instantiationrenderer.material clones — use sharedMaterial for reads, MaterialPropertyBlock for per-instance overrides
Camera.Render() in UpdateUse Render Texture + Camera.targetTexture once
Mixing pipelines (URP shader on Built-in)Convert via Edit > Render Pipeline > Universal > Convert Selected Materials

Production checklist

  • Pipeline asset set in Graphics + Quality settings
  • Volume profiles configured for global + relevant local triggers
  • Shader variants collection generated and preloaded for the build
  • Static objects flagged Static; lighting baked
  • Light Probes / Reflection Probes placed
  • Frame Debugger inspected — no surprise opaque draws on UI
  • HDRP-only: Adaptive Probe Volumes configured if static GI is critical
我的收藏