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"
}