Search Unity

Reserved samplers in Surface Shaders

Discussion in 'Shaders' started by Deleted User, Jun 26, 2014.

  1. Deleted User

    Deleted User

    Guest

    Okay, I've examined the debug output of my surface shaders, and have found that as many as four samplers can be reserved by Unity 4.5 if doing HDR on the Xbox 360 with lightmaps in deferred mode. However, I have a custom terrain shader that compiles on the PC just fine even though it is set up for deferred HDR with directional lightmaps with 14 custom samplers.

    Questions:
    1. Officially, how many samplers does Unity reserve for the Surface shader passes?
    2. Any thoughts on why it is okay with my terrain? Is this just a consequences of 4.5 not compiling all platforms anymore?
    3. Any thoughts on how I can trick Unity into giving up more? Or am I just going to have to pack down my sampler usage?
    Thanks.
     
    Last edited by a moderator: Jun 26, 2014
  2. WhiskyJoe

    WhiskyJoe

    Joined:
    Aug 21, 2012
    Posts:
    143
    I'm not sure on how many the surface shaders reserve, though your assumption of the better compiling in 4.5 might be a valid point that unity doesn't throw everything possible at you.

    From the top of my head, Xbox 360 uses SM 3.0 which has a texture limit of 16, so I doubt you can trick Unity into giving you more than what the shader model restricts you with.
     
  3. RC-1290

    RC-1290

    Joined:
    Jul 2, 2012
    Posts:
    639
    You can see what happens when compiling for other platforms, by pressing the "Show All" button on the shader.

    You could use surface shader keywords like 'nolightmap' ;)
     
    Deleted User likes this.
  4. Deleted User

    Deleted User

    Guest

    @RC-1290
    Yeah, I keep forgetting that button is there now in 4.5, and it could indeed be useful. As for the "nolightmap" option, that isn't an option for me. What I learn here is going into the Alloy Physical Shader framework, and full lightmap support is a major selling point for it.