Search Unity

Shader error : Too many texture interpolators would be used for ForwardBase pass

Discussion in 'Shaders' started by nikko, Oct 11, 2010.

  1. nikko

    nikko

    Joined:
    Mar 20, 2009
    Posts:
    436
    I get this error all the time: Too many texture interpolators would be used for ForwardBase pass
    Here is the code where the error occurs, and the line where is the error is commented out.

     
  2. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,225
    From an earlier thread
    It's made more difficult because unity 'pads' out the structure with internal data in some passes that get compiled behind the scenes. It you look at that struct you could pack it like this:

    float4 color0lightx;
    float4 color1lighty;
    float4 normallightz;

    and then reconstruct the 4 floats3's. This will give you some breathing room. Pack as much data as you can :D
     
  3. Revoluzifer

    Revoluzifer

    Joined:
    Jun 29, 2010
    Posts:
    10
    I've got exactly the same error here but already repacked my struct as follows:

    struct Input {
    float2 uv_MainTex : TEXCOORD0;
    float4 TtoW0Ix : TEXCOORD1;
    float4 TtoW1Iy : TEXCOORD2;
    float4 TtoW2Iz : TEXCOORD3;
    float4 uv_Bumpvdxy : TEXCOORD4;
    float4 vdzOSN;
    };

    Does anybody know another solution?
     
    avinitzca likes this.
  4. jcabeleira

    jcabeleira

    Joined:
    Jan 3, 2011
    Posts:
    13
    Stupid solution: If you're not targeting ancient hardware, just add "#pragma target 3.0" to make the shader compile to shader model 3.
     
  5. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    Or just don't use surface shaders if you intend to target ancient hardware, its not optimized for stonage (nor really suitable for mobile either just to mention)

    I'm still curious on why it works at all without SM3 enforcement as it goes that close to the specs of SM2 that any hardware that really only supports SM2 will struggle and stutter seriously
     
    Gamba04 likes this.
  6. Revoluzifer

    Revoluzifer

    Joined:
    Jun 29, 2010
    Posts:
    10
    Nice thing, thanks ;)
    But if I do that, 2 new errors appear:
    Program 'frag_surf', assignment of incompatible types at line 136
    and
    Program 'vert_surf', assignment of incompatible types at line 136

    Best thing: There are only 108 lines of code oO

    Edit:
    Didn't see dreamora's post...
    Well, my problem is, I'm customizing an old shader.
    Unity kind of told me to rewrite it into a surface shader.
    Unfortunately i cannot remember the error-message for that...
     
    Last edited: Jan 4, 2011
  7. Revoluzifer

    Revoluzifer

    Joined:
    Jun 29, 2010
    Posts:
    10
    No ideas on that?
    I'm targeting pc only, so surface shader should work just fine I think.

    I just cannot solve the errors mentioned above (assignment of incompatible types at line 136)...
    I do not have a line 136 - or is it the compiled shader's line?
    Getting really confused at the moment...
     
  8. Ravel

    Ravel

    Joined:
    Nov 21, 2010
    Posts:
    605
    sorry to bump such an old thread, but my shader just stopped working. I compared it to an older version of the shader and the code is 1:1 the same. Only problem is that, now I get the same issue. Is there some sort of online checkups in Unity 5.6 ? And if there is, why isn't this fixed instead?
     
  9. JonPQ

    JonPQ

    Joined:
    Aug 10, 2016
    Posts:
    120
    going from 5.6 to 2019.... the number of interpolaters has apparently gone down. some of my shaders no longer compile... :(
     
    andyz likes this.
  10. voxelltech

    voxelltech

    Joined:
    Oct 8, 2019
    Posts:
    44
    i fixed it by changing #pragma target 3.0 to #pragma target 4.0. can someone tell me if this will affect the performance of the game?
     
  11. danielpokladek

    danielpokladek

    Joined:
    Dec 20, 2013
    Posts:
    14
    You can read up more about shader targets in Unity's manual:
    https://docs.unity3d.com/Manual/SL-ShaderCompileTargets.html

    As far as my understanding goes it shouldn't, but the shader can be unavailable on certain (especially old) hardware, and as mentioned before because surface shaders aren't meant to be used on mobile it can cause issues there.
     
    voxelltech likes this.
  12. andyz

    andyz

    Joined:
    Jan 5, 2010
    Posts:
    2,276
    digging up because I had to add #pragma target 3.5 just to add one custom float2 on top of Input with
    float2 uv_MainTex;
    float3 worldRefl;

    Don't understand why a basic surface shader can require 10 texture interpolators!! But I guess it is because it compiles for every possible use case including 4 textures, even I only have 1 defined?! I don't really get it...
    I can add/modify the vertex shader to use appdata_base or appdata_tan instead of appdata_full, which generates warnings about not supporting some use-cases (lightmaps, dynamic GI). But not an issue if I don't use those is it?!

    Unity 2019 LTS