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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Too many texture interpolators would be used for ForwardBase pass (11 out of max 10)

Discussion in 'Shaders' started by rakeshparihar, Dec 10, 2015.

?

Too many texture interpoltors would be used for ForwardBase pass

  1. Find an error on line 18

    1 vote(s)
    100.0%
  2. Any solution

    0 vote(s)
    0.0%
Multiple votes are allowed.
  1. rakeshparihar

    rakeshparihar

    Joined:
    Oct 1, 2015
    Posts:
    4
    Please guys suggest me some solution ....Here is my code .....

    Shader "Custom/PackingandBlending" {
    Properties
    {
    _MainTint ("Diffuse Tint", Color) = (1,1,1,1)

    _ColorA("Terrain Color A", Color) = (1,1,1,1)
    _ColorB("Terrain Color B", Color) = (1,1,1,1)

    _RTexture ("Red Channel Texture", 2D) = ""{}
    _GTexture ("Green Channel Texture", 2D) = ""{}
    _BTexture ("Blue Channel Texture", 2D) = ""{}
    _ATexture ("Alpha Channel Texture", 2D) = ""{}

    _BlendTex ("Blend Texture", 2D) = ""{}
    }
    SubShader {
    Tags { "RenderType"="Opaque" }
    CGPROGRAM

    #pragma surface surf Lambert

    #pragma target 3.0
    #pragma debug

    float4 _MainTint;
    float4 _ColorA;
    float4 _ColorB;
    sampler2D _RTexture;
    sampler2D _GTexture;
    sampler2D _BTexture;
    sampler2D _ATexture;

    sampler2D _BlendTex;

    struct Input
    {
    float2 uv_RTexture;
    float2 uv_GTexture;
    float2 uv_BTexture;
    float2 uv_ATexture;
    float2 uv_BlendTex;
    };



    void surf (Input IN, inout SurfaceOutput o) {
    // Albedo comes from a texture tinted by color
    float4 blendData = tex2D(_BlendTex, IN.uv_BlendTex);

    float4 rTexData = tex2D(_RTexture, IN.uv_RTexture);
    float4 gTexData = tex2D(_GTexture, IN.uv_GTexture);
    float4 bTexData = tex2D(_BTexture, IN.uv_BTexture);
    float4 aTexData = tex2D(_ATexture, IN.uv_ATexture);


    float4 finalColor;
    finalColor = lerp(rTexData, gTexData, blendData.g);
    finalColor = lerp(finalColor, bTexData, blendData.b);
    finalColor = lerp(finalColor, aTexData, blendData.a);
    finalColor.a = 1.0;


    float4 terrainLayers = lerp(_ColorA, _ColorB, blendData.r);
    finalColor *= terrainLayers;
    finalColor = saturate(finalColor);

    o.Albedo = finalColor.rgb *_MainTint.rgb;
    o.Alpha = finalColor.a;
    }
    ENDCG
    }
    FallBack "Diffuse"
    }
     
  2. Flailer

    Flailer

    Joined:
    Apr 1, 2014
    Posts:
    66
    As it says you have too many.. You're gonna need to strip it back or upgrade your shader to Shader Model 4.0
     
    rakeshparihar likes this.
  3. brownboot67

    brownboot67

    Joined:
    Jan 5, 2013
    Posts:
    375
    Packing your UV's might get you under. Your texture property makes it unclear as to what you're trying to do. Are you really using all 4 channels of those?
     
    rakeshparihar likes this.
  4. Flailer

    Flailer

    Joined:
    Apr 1, 2014
    Posts:
    66
    Packing UVs and swizzling has a performance hit though doesn't it? Especially as it leads to dependant texture reads.
     
  5. rakeshparihar

    rakeshparihar

    Joined:
    Oct 1, 2015
    Posts:
    4
    Flailer thk u so much
     
  6. rakeshparihar

    rakeshparihar

    Joined:
    Oct 1, 2015
    Posts:
    4
    brownboot67
    Yes i wann make a terrain type texture effect for a simple plane..
     
  7. brownboot67

    brownboot67

    Joined:
    Jan 5, 2013
    Posts:
    375
    Can you use vert color instead of your blend texture?
     
  8. ElChileVengador

    ElChileVengador

    Joined:
    Feb 4, 2013
    Posts:
    27
    I got it to work by deleting one of the UV float2 in the Input Struct and then substituting it in the surf function for another one of the UVs. It works, but to be honest, I'm not exactly sure why. I thought the texture interpolators only referred to the lerp functions. Can anyone please help explain where this error originates from?