0
0
Unityframework~8 mins

Unlit vs lit shaders in Unity - Performance Comparison

Choose your learning style9 modes available
Performance: Unlit vs lit shaders
HIGH IMPACT
This affects the rendering speed and frame rate by changing how much work the GPU does to draw objects on screen.
Rendering simple objects without lighting effects
Unity
Shader "Custom/UnlitShader" {
  SubShader {
    Tags { "RenderType"="Opaque" }
    Pass {
      CGPROGRAM
      #pragma vertex vert
      #pragma fragment frag
      // No lighting calculations
      ENDCG
    }
  }
}
Unlit shaders skip lighting, reducing GPU calculations and speeding up rendering.
📈 Performance GainLowers GPU usage, improves frame rate, especially for static or UI elements.
Rendering simple objects without lighting effects
Unity
Shader "Custom/LitShader" {
  SubShader {
    Tags { "RenderType"="Opaque" }
    Pass {
      CGPROGRAM
      #pragma vertex vert
      #pragma fragment frag
      // Lighting calculations here
      ENDCG
    }
  }
}
Lit shaders perform complex lighting calculations every frame, increasing GPU load.
📉 Performance CostIncreases GPU workload, reducing frame rate especially on low-end devices.
Performance Comparison
PatternGPU LoadFragment Shader ComplexityFrame Rate ImpactVerdict
Lit ShaderHighComplex lighting mathLower frame rate on complex scenes[X] Bad
Unlit ShaderLowSimple color outputHigher frame rate, smoother rendering[OK] Good
Rendering Pipeline
Lit shaders add lighting calculations during the fragment stage, increasing GPU load. Unlit shaders skip these calculations, reducing the workload.
Vertex Processing
Fragment Processing
⚠️ BottleneckFragment Processing due to lighting calculations
Optimization Tips
1Use unlit shaders to improve rendering speed when lighting is unnecessary.
2Lit shaders increase GPU load due to per-pixel lighting calculations.
3Switch to unlit shaders for UI and simple objects to boost frame rates.
Performance Quiz - 3 Questions
Test your performance knowledge
Which shader type generally uses less GPU power?
AUnlit shader
BLit shader
CBoth use the same GPU power
DDepends on CPU speed
DevTools: Unity Profiler
How to check: Open Unity Profiler, select GPU module, run scene with lit and unlit shaders, compare GPU time spent on fragment shaders.
What to look for: Lower GPU time and higher frame rates indicate better performance with unlit shaders.