How to profile and optimize Unity mobile shaders to cut overdraw, battery use?
#1
I'm developing a stylized 3D mobile game in Unity, and my custom shaders, while visually perfect for the art style, are absolutely destroying my frame rate on target devices, causing severe overheating and battery drain. I've tried simplifying the shader code and reducing texture samples, but I'm clearly missing some fundamental optimization techniques. For developers who have shipped performant mobile titles with custom shaders, what was your process for profiling and optimizing shader performance in Unity? I'm particularly interested in practical strategies for minimizing overdraw, optimizing branching logic and loops within the shader itself, and understanding which built-in Unity functions are most expensive on mobile GPUs, as the documentation isn't always clear about performance costs.
Reply
#2
Start by profiling: use Unity's Profiler (GPU timeline) and the Frame Debugger to see exactly where your shader is spending time. Build a tiny baseline shader (a flat color) and measure frame time, then iteratively reintroduce features (lighting, textures, normals) one at a time to see the impact. This makes it possible to quantify improvements instead of guessing.
Reply
#3
Overdraw and render passes kill mobile perf fast. Keep materials opaque with ZWrite on, minimize transparency, and batch draws with texture atlases to reduce fetches. If you must use transparency, keep the shader simple and consider a single, well-scoped blended pass rather than multiple layers. Also bake lighting where possible (light probes, baked GI) to cut per-pixel cost.
Reply
#4
Branching and loops in shaders burn cycles on mobile. Prefer branchless math when you can—use step, smoothstep, and mix/lerp to approximate conditionals. If you must branch, keep the branches uniform across the fragment shader to avoid divergence. Unroll loops with a fixed, small bound and avoid dynamic loop counts in hot paths.
Reply
#5
Be mindful of mobile-specific costs. Texture sampling and texture lookups are expensive; trig functions (sin/cos/acos), exp/log, and large pow operations can blow framerates. Use half precision where safe, precompute constants, and avoid unnecessary texture fetches by packing data into a small number of textures. Also check whether your hardware recommends a particular API (Vulkan, Metal, OGL ES) and leverage the best path for that device family.
Reply
#6
Practical workflow you can actually follow: 1) enable Development Build and test on target devices; 2) profile with Unity Profiler, Frame Debugger, and platform-specific tools (Android: Android GPU Inspector; iOS: Xcode Metal Frame Debugger); 3) create a minimal, reusable shader baseline and build up in small steps with measured impacts; 4) consider swapping heavy shading for baked lighting or light probes where possible; 5) keep a simple checklist of optimizations and your results so you know what to revert or refine next. If you tell me your target device(s) and shader features, I can sketch a concrete optimization plan.
Reply


[-]
Quick Reply
Message
Type your reply to this message here.

Image Verification
Please enter the text contained within the image into the text box below it. This process is used to prevent automated spam bots.
Image Verification
(case insensitive)

Forum Jump: