Search Unity

Complex shader vs multiple simpler shaders

Discussion in 'Shaders' started by TimCabbage, Mar 26, 2016.

  1. TimCabbage

    TimCabbage

    Joined:
    Feb 13, 2011
    Posts:
    66
    o/

    I'm using the same textures for all of those shaders for this task and I have a rather complex shader(over 94 vertex and 112 fragment operations) which limits my shader to 3.0 model, but I have found that it's not as big of an issue as I'm targeting the PC market now.
    Now is it really not an issue? Should I try and simplify it?

    The other question is - will such a large shader program not slow down the rendering?
    I could generate submeshes and render each variation of the shader using a different material sharing one texture. Would that be a good idea?

    So multiple shaders, same texture set, multiple submeshes,
    VS
    One, complex shader, same texture set, one submesh.


    This is for this particular problem.
    I will have multiple submeshes with multiple materials anyway as some will be transparent and others will be grass (so a vertex program to transform vertices)
     
  2. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    94/112 is not much for a modern pc; I regularly do that on mid-range mobile. Also, keep in mind that operation count isn't a very good measurement of speed, as what type of operations your doing has a much bigger effect. For instance, a saturate instruction is very fast while sin or pow are much slower. Beyond that, things like dependent texture reads make an even greater difference. Beyond that, things like are you drawing multiple lights in forward rendering are going to make an even greater difference..
     
    Last edited: Apr 2, 2016
    TimCabbage likes this.
  3. TimCabbage

    TimCabbage

    Joined:
    Feb 13, 2011
    Posts:
    66
    ok, makes sense. thanks!