"Input limit (8) exceeded" error on shader

Hey all, I’m trying to create a Fresnel shader that uses a cubemap to mask the Fresnel off from certain sections of the model. I want the Fresnel to not show up on areas that face downwards (so it kind of fakes a directional lighting effect).

Anyway, I’m getting the following errors:

Program ‘frag_surf’, error X4506: ps_4_0_level_9_3 input limit (8) exceeded, shader uses 9 inputs. (compiling for d3d11_9x) at line 16

Program ‘frag_surf’, input semantic attribute “TEXCOORD” has too big of a numeric index (8) at line 58

I know I need to reduce the number of inputs, but I’m a beginner and I don’t know how to do that.

Shader "WMS/Fresnel_Directional" {
    Properties {
      _Color ("Main Color", Color) = (1,1,1,1)
      _SpecColor ("Specular Color", Color) = (1, 1, 1, 1)
      _RimColor ("Fresnel Color", Color) = (0.26,0.19,0.16,0.0)
      _RimPower ("Fresnel Reflections", Range(0.0, 8.0)) = 3.0
      _Shininess ("Polish", Range (0.05, 5)) = 0.5
      _MainTex ("Diffuse", 2D) = "white" {}
      _SpecMap ("Specular (R) Polish (G)", 2D) = "black" {}
      _BumpMap ("Normal", 2D) = "bump" {}
      _Cube ("Cubemap", CUBE) = "" {}
    }
    SubShader {
      Tags { "RenderType" = "Opaque" }

CGPROGRAM
#pragma surface surf BlinnPhong 
#pragma target 3.0

      struct Input {
          float2 uv_MainTex, uv_BumpMap, uv_SpecMap;
          float3 worldRefl;
          float3 viewDir;
          INTERNAL_DATA
      };
      
      samplerCUBE _Cube;
      sampler2D _MainTex;
      sampler2D _BumpMap;
      sampler2D _SpecMap;
      fixed4 _Color;
      half _Shininess;
      float _RimPower;
      float4 _RimColor;
      
      void surf (Input IN, inout SurfaceOutput o) {
          fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
          fixed4 specTex = tex2D(_SpecMap, IN.uv_SpecMap);
          o.Albedo = tex.rgb * _Color;
          o.Gloss = specTex.r;
          o.Specular = _Shininess;
          o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
          half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
		  o.Emission = _RimColor.rgb * texCUBE (_Cube, WorldReflectionVector (IN, o.Normal )) * pow (rim, _RimPower);	

      }
      ENDCG
    } 
    Fallback "Specular"
  }

I guess you could not compile for DX11 - but presuming you want to - you need to have the shader use one less parameter - I can't see you making use of anything in INTERNAL_DATA - getting rid of that might help...

1 Answer

1

I think you need

#pragma exclude_renderers d3d11_9x

right after line 18 to tell unity that it is 9 times

Sorry for reviving an old question, but, WHAT!... this does not tell unity that it's "9 times", whatever "9 times" means, it tells unity to exclude this shader if using d3d11 with d3d9 hardware! it solves the error message but when using d3d11 with d3d9 hardware unity will render with the fallback shader instead.