Skip to content

Optimizing shaders

↑

Shaders execute for many vertices or pixels, so tiny per-pixel costs can accumulate. Common cost drivers include expensive texture sampling, overdraw, dynamic branches, high variant counts, large interpolators and complex lighting. Which issue dominates depends on the target GPU, screen resolution and render pipeline.

Measure first with the Unity Profiler, Frame Debugger and target-device GPU tools. A faster mathematical expression will not help if you are bound by fill rate or bandwidth. Prefer profiling in a player build, especially on mobile devices.

OptimizationChecklist.txt
1. Record a baseline on the target device.
2. Identify the costly pass, shader or material.
3. Reduce unnecessary texture samples or overdraw.
4. Inspect shader variants and keywords.
5. Rebuild and measure again; keep only proven improvements.

Pitfall: Transparent geometry can cause significant overdraw. Stripping shader variants too aggressively can cause missing effects in player builds. Try it: Compare opaque and transparent overlapping quads using Frame Debugger.

Further reading: Official optimization guidance.