Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Efficiency & Workflow: Multiple shaders or a God shader?

Discussion in 'General Graphics' started by IntoTheSoul, Feb 22, 2022.

  1. IntoTheSoul

    IntoTheSoul

    Joined:
    Oct 31, 2018
    Posts:
    30
    Should I create multiple shaders that accomodate different material behaviours or should I just simply create a god shader that can be capable of all things that I need?
     
  2. mabulous

    mabulous

    Joined:
    Jan 4, 2013
    Posts:
    198
    depends on what you want to optimize for. If you want to optimize for performance, make multiple shaders. If you want to optimize for maintainability and ease of content creation, create a god shader.
     
    IntoTheSoul likes this.
  3. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    843
    On the other hand, if you are using SRP batching, a god shader can have better performance due to the smaller bandwidth of passing information to the GPU when prepping for rendering, thus significantly reducing the CPU cost of draw calls.
     
    IntoTheSoul likes this.
  4. IntoTheSoul

    IntoTheSoul

    Joined:
    Oct 31, 2018
    Posts:
    30
    Thanks for the info, do you guys have any recommended readings on the topic? I'd love to take a look at them!
     
    Gasimo likes this.