Unity: rendering and shaders¶
Render pipelines, draw calls, shader keywords and variants, shader warm-up, textures, level of detail and the rendering debug tools. The engine-independent rendering rules are in Graphics and GPU rendering. Profiling, memory and asset loading are in Content and performance, and frame budgets are in Game development.
Entries are sorted by score from 1 to 10 (criteria): 9โ10 start here or strongly recommended, 6โ8 recommended, 1โ5 further reading or conditional.
Adopted references¶
Unity's URP guide and the graphics sections of the Unity Manual are the baseline. The rules below add the choices and settings that are easy to miss.
- 9 Introduction to URP for advanced creators (Unity 6 edition) (Unity e-book): the baseline for URP projects. Setting up or converting a project, quality settings, lighting, URP and custom shaders, post-processing, Renderer Features and the render graph, and performance tools such as the GPU Resident Drawer and GPU occlusion culling.
- 8 Optimize performance for mobile, XR and web games and for consoles and PCs (Unity e-books): texture and mesh import settings, draw calls, lighting, level of detail, shaders and overdraw, for each group of platforms.
- 7 Optimize custom shaders (Unity Manual): reducing texture and buffer reads, arithmetic and overdraw in custom shaders, measured with a GPU profiler on the target platform.
Key rules¶
Render pipeline and draw calls¶
- 9
UNITY-GFX-1Start new projects on the Universal Render Pipeline (URP), and choose HDRP only for a PC or console project that needs its high-end features. Don't start a new title on the Built-in Render Pipeline. Unity deprecated the Built-in Render Pipeline in Unity 6.5 and supports it through the Unity 6.7 LTS lifecycle, plans no new HDRP features, and warns that switching pipelines late in development is very time-consuming, because the pipelines use different shaders. This appliesGFX-1. (Unity, Render pipelines strategy for 2026, Unity Manual, Choose a render pipeline) - 7
UNITY-GFX-2In URP and HDRP, follow Unity's draw-call recommendations: enable the SRP Batcher and the GPU Resident Drawer, turn off static batching and the materials' Enable GPU Instancing checkbox, share materials, and use Material Variants rather thanMaterialPropertyBlockfor objects that differ only in property values. The GPU Resident Drawer needs the Forward+ or Deferred+ rendering path and a graphics API with compute shaders, and it lengthens builds because it keeps all BatchRendererGroup shader variants. This appliesGFX-10. (Unity Manual, Choose a method for optimizing draw calls, Enable the GPU Resident Drawer in URP) - 7
UNITY-GFX-3Write custom shaders in Shader Graph by default, bring in hand-written HLSL through Custom Function nodes, and keep any fully hand-written URP or HDRP shader compatible with the SRP Batcher. Unity's URP guide finds Shader Graph the more convenient route for most custom shaders. A hand-written shader is compatible when it declares all material properties in oneUnityPerMaterialconstant buffer and the built-in engine properties inUnityPerDraw, which the shader's Inspector confirms. (Unity, Introduction to URP for advanced creators, Shader Graph, Introduction to HLSL in Shader Graph, Unity Manual, SRP Batcher compatibility)
Shader variants and warm-up¶
- 7
UNITY-GFX-4Declare keywords that only materials set withshader_feature_local(in Shader Graph, keep the keyword's default Shader Feature definition), keepmulti_compilefor branches that C# switches at run time, and usedynamic_branchfor simple, balanced branches on fast GPUs.multi_compilecompiles every keyword combination whether or not a material uses it, and builds leave outshader_featurecombinations that no material uses, so never switch those at run time. This appliesGFX-6. (Unity Manual, How Unity compiles branching shaders, Toggle shader keywords in a script, Shader Graph, Introduction to keywords) - 7
UNITY-GFX-5Strip the shader variants the build doesn't need, and check the count after every build: turn on Strip Unused Variants and Strip Unused Post Processing Variants in the URP Graphics settings, turn off unused features in every URP asset the build includes, remove keywords in Shader Build Settings (Unity 6.3 LTS and later), and strip the rest withIPreprocessShaders. SearchEditor.logfor Compiling shader to see the counts, and turn on Strict shader variant matching in test builds to catch variants stripped by mistake. This appliesGFX-6. (Unity Manual, Reduce shader variants, Strip shader variants in URP, Check how many shader variants you have, IPreprocessShaders.OnProcessShader) - 7
UNITY-GFX-6On DirectX 12, Vulkan and Metal, record the pipeline state objects (PSOs) the game uses into aGraphicsStateCollectionfrom a development build, one collection per graphics API and platform, ship the collections, and warm them up during loading screens withWarmUporWarmUpProgressively. Don't rely onShaderVariantCollectionwarm-up on those APIs, because it can create the wrong PSOs. From Unity 6.1,GraphicsStateCollectionalso falls back to shader warm-up on DirectX 11, OpenGL and WebGL. This appliesGFX-5. (Unity Manual, Introduction to PSO tracing and warming, Trace and manage PSO data collections, Warm up PSOs, Other methods to warm up shaders)
Textures, level of detail and debugging¶
- 7
UNITY-GFX-7Set texture import settings for each platform in the platform overrides: ASTC on mobile, XR and the web, BC7, DXT or BC6H on desktop, the lowest Max Size that looks acceptable, and Read/Write off. Apply them through presets, so that new imports get them automatically. If you ship on Google Play, Unity recommends texture compression targeting. This appliesGFX-13. (Unity e-book, Optimize performance for mobile, XR and web games, Unity Manual, Choose a GPU texture format by platform, Apply default presets to assets by folder) - 6
UNITY-GFX-8Give meshes that are seen at varying distances levels of detail: generate Mesh LODs on import (Unity 6.2 and later) to cut triangles at little memory cost, and use LOD Groups where a lower level must also cut materials or draw calls, or needs explicit transition sizes. This appliesGFX-14. (Unity Manual, Introduction to level of detail) - 6
UNITY-GFX-9Inspect batching in the Frame Debugger and GPU cost in the Rendering Debugger, both of which can also inspect a built player. The Frame Debugger shows how many draw calls each SRP batch holds and why it wasn't merged with the previous one, and many small batches usually mean too many shader variants. The Rendering Debugger shows CPU and GPU frame times, the current bottleneck and an overdraw view. This appliesGFX-4. (Unity Manual, Troubleshoot the SRP Batcher, Frame Debugger, Rendering Debugger window reference)
How to enforce¶
Tools that check the key rules above automatically, in CI, the IDE or a commit hook. "Partly" means the tool covers only some of what the rule asks.
- 7 Unity Project Auditor, Shaders view: lists each shader's SRP Batcher compatibility, keyword count, and potential and built variant counts, and the Shader Variants view lists the variants in the build and, from a development build's
Player.log, which of them were compiled at run time. Runs from the command line in CI. Partly checksUNITY-GFX-3,UNITY-GFX-4andUNITY-GFX-5. - 7 Unity build log, shader variant counts: after each build,
Editor.logreports for every shader pass the full variant space and the counts left after settings filtering, built-in stripping and scriptable stripping, which a CI step can compare with a budget. Strict shader variant matching makes test builds show the error shader and log any variant that was stripped by mistake. Partly checksUNITY-GFX-5.
Tutorials and further reading¶
- 6 Create popular shaders and visual effects with the Universal Render Pipeline (Unity 6 edition) (Unity e-book): recipes with sample scenes for stencil effects, toon and outline shaders, decals, color grading, reflections, water and clouds, and Renderer Features built on the render graph.