Register index exceeded for texture samplers

Node-based Shader Editor

Register index exceeded for texture samplers

Postby jurassic_queer » Thu Aug 10, 2017 5:45 pm

I'm creating a shader that uses LERPs and masks to add multiple textures to objects and I keep running into the "maximum ps_4_0 sampler register index (16) exceeded)" error because there's too many texture inputs going on. To pare down on those, I want to create an option to toggle between any of the existing mask inputs to use for the metallic mask instead of having a separate texture sample for this, since anything that's metallic will use the same mask between metallic, albedo, and normal anyway. The current setup works fine for sharing a mask between albedo and normal since it's grabbing from a chain of LERPs that add everything together, but the metallic is separate since I don't want everything to have metallic info on it. I've also got some grunge happening using some world normals that plugs into smoothness.

Image

It's a little messy looking at the moment, still putting all this together and organizing things in a way that makes sense. When it's applied to a material, we basically plug in a bunch of maps and we're good to go. There's a few sliders for things like smoothness, metallic amount, grunge height, etc.

Image

It says I can have up to 16 maps, and I only have 14. So why am I getting this error? Line 81 is the texture sampler for my metallic mask, and if I disconnect this mask the error goes away. Sometimes, however, I can plug in this mask input and don't get the error, things look perfect and the shader works great on my end, but once I pull the changes to a different machine it breaks and I get the register index error again.

Image

To me, the solution would be to have my 3 mask inputs and the ability to toggle my metallic mask between one of those existing texture samplers. I have no idea how to make this work in Amplify.

It won't allow me to attach the shader file itself (it says file extension .shader is not allowed) or a .txt file, so I can't actually add the shader itself. Which is... weird. So I guess I'll need to add the shader text here? Weird that I can't attach this as a file.

Code: Select all
// Made with Amplify Shader Editor
// Available at the Unity Asset Store - http://u3d.as/y3X
Shader "Amplify/LERP Mask"
{
   Properties
   {
      [HideInInspector] __dirty( "", Int ) = 1
      MAT_Grunge_basecolor("MAT_Grunge_basecolor", 2D) = "white"{}
      MAT_Grunge_Mask("MAT_Grunge_Mask", 2D) = "white"{}
      _Mask1("Mask 1", 2D) = "white" {}
      _Mask2("Mask 2", 2D) = "white" {}
      _Mask3("Mask 3", 2D) = "white" {}
      _Albedo1("Albedo 1", 2D) = "white" {}
      _Albedo2("Albedo 2", 2D) = "white" {}
      _Albedo3("Albedo 3", 2D) = "white" {}
      _Albedo4("Albedo 4", 2D) = "white" {}
      _Normal1("Normal 1", 2D) = "white" {}
      _Normal4("Normal 4", 2D) = "white" {}
      _Normal2("Normal 2", 2D) = "white" {}
      _Normal3("Normal 3", 2D) = "white" {}
      _Smoothness("Smoothness", Range( -1 , 1)) = 0.5
      _Metallic("Metallic", Range( 0 , 1)) = 0.5
      _MetallicMask("Metallic Mask", 2D) = "white" {}
      _GrungeSmoothness("Grunge Smoothness", Range( 0 , 1)) = 0.3
      _GradientHeight("Gradient Height", Range( 0 , 20)) = 20
      [HideInInspector] _texcoord( "", 2D ) = "white" {}
   }

   SubShader
   {
      Tags{ "RenderType" = "Opaque"  "Queue" = "Geometry+0" }
      Cull Back
      CGINCLUDE
      #include "UnityPBSLighting.cginc"
      #include "Lighting.cginc"
      #pragma target 3.5
      #ifdef UNITY_PASS_SHADOWCASTER
         #undef INTERNAL_DATA
         #undef WorldReflectionVector
         #undef WorldNormalVector
         #define INTERNAL_DATA half3 internalSurfaceTtoW0; half3 internalSurfaceTtoW1; half3 internalSurfaceTtoW2;
         #define WorldReflectionVector(data,normal) reflect (data.worldRefl, half3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal)))
         #define WorldNormalVector(data,normal) fixed3(dot(data.internalSurfaceTtoW0,normal), dot(data.internalSurfaceTtoW1,normal), dot(data.internalSurfaceTtoW2,normal))
      #endif
      struct Input
      {
         float2 uv_texcoord;
         float3 worldNormal;
         INTERNAL_DATA
         float3 worldPos;
      };

      uniform sampler2D _Normal1;
      uniform float4 _Normal1_ST;
      uniform sampler2D _Normal2;
      uniform float4 _Normal2_ST;
      uniform sampler2D _Normal3;
      uniform float4 _Normal3_ST;
      uniform sampler2D _Mask2;
      uniform float4 _Mask2_ST;
      uniform sampler2D _Mask1;
      uniform float4 _Mask1_ST;
      uniform sampler2D _Mask3;
      uniform float4 _Mask3_ST;
      uniform sampler2D _Normal4;
      uniform float4 _Normal4_ST;
      uniform sampler2D MAT_Grunge_basecolor;
      uniform float4 MAT_Grunge_basecolor_ST;
      uniform sampler2D MAT_Grunge_Mask;
      uniform float _GradientHeight;
      uniform sampler2D _Albedo1;
      uniform float4 _Albedo1_ST;
      uniform sampler2D _Albedo2;
      uniform float4 _Albedo2_ST;
      uniform sampler2D _Albedo3;
      uniform float4 _Albedo3_ST;
      uniform sampler2D _Albedo4;
      uniform float4 _Albedo4_ST;
      uniform float _Metallic;
      uniform sampler2D _MetallicMask;
      uniform float4 _MetallicMask_ST;
      uniform float _GrungeSmoothness;
      uniform float _Smoothness;

      void surf( Input i , inout SurfaceOutputStandard o )
      {
         float2 uv_Normal1 = i.uv_texcoord * _Normal1_ST.xy + _Normal1_ST.zw;
         float3 tex2DNode6 = UnpackNormal( tex2D( _Normal1, uv_Normal1 ) );
         float2 uv_Normal2 = i.uv_texcoord * _Normal2_ST.xy + _Normal2_ST.zw;
         float4 _Color0 = float4(1,1,1,0);
         float2 uv_Normal3 = i.uv_texcoord * _Normal3_ST.xy + _Normal3_ST.zw;
         float2 uv_Mask2 = i.uv_texcoord * _Mask2_ST.xy + _Mask2_ST.zw;
         float4 tex2DNode3 = tex2D( _Mask2, uv_Mask2 );
         float2 uv_Mask1 = i.uv_texcoord * _Mask1_ST.xy + _Mask1_ST.zw;
         float2 uv_Mask3 = i.uv_texcoord * _Mask3_ST.xy + _Mask3_ST.zw;
         float4 tex2DNode4 = tex2D( _Mask3, uv_Mask3 );
         float2 uv_Normal4 = i.uv_texcoord * _Normal4_ST.xy + _Normal4_ST.zw;
         o.Normal = lerp( lerp( lerp( lerp( tex2DNode6 , UnpackNormal( tex2D( _Normal2, uv_Normal2 ) ) , _Color0.r ) , UnpackNormal( tex2D( _Normal3, uv_Normal3 ) ) , ( tex2DNode3 + tex2D( _Mask1, uv_Mask1 ) + tex2DNode4 ).x ) , UnpackNormal( tex2D( _Normal4, uv_Normal4 ) ) , tex2DNode3.x ) , tex2DNode6 , tex2D( _Mask3, uv_Mask3 ).x );
         float2 uvMAT_Grunge_basecolor = i.uv_texcoord * MAT_Grunge_basecolor_ST.xy + MAT_Grunge_basecolor_ST.zw;
         float4 MAT_Grunge_basecolor128 = tex2D( MAT_Grunge_basecolor, uvMAT_Grunge_basecolor);
         float4 MAT_Grunge_Mask128 = tex2D( MAT_Grunge_Mask, uvMAT_Grunge_basecolor);
         float3 ase_worldNormal = WorldNormalVector( i, float3( 0, 0, 1 ) );
         float componentMask101 = ( abs( ase_worldNormal ) * abs( ase_worldNormal ) ).y;
         float3 temp_cast_5 = (componentMask101).xxx;
         float3 desaturateVar110 = lerp( temp_cast_5,dot(temp_cast_5,float3(0.299,0.587,0.114)),0.0);
         float3 ase_worldPos = i.worldPos;
         float2 uv_Albedo1 = i.uv_texcoord * _Albedo1_ST.xy + _Albedo1_ST.zw;
         float4 tex2DNode5 = tex2D( _Albedo1, uv_Albedo1 );
         float2 uv_Albedo2 = i.uv_texcoord * _Albedo2_ST.xy + _Albedo2_ST.zw;
         float2 uv_Albedo3 = i.uv_texcoord * _Albedo3_ST.xy + _Albedo3_ST.zw;
         float2 uv_Albedo4 = i.uv_texcoord * _Albedo4_ST.xy + _Albedo4_ST.zw;
         o.Albedo = lerp( lerp( ( lerp( MAT_Grunge_basecolor128 , MAT_Grunge_basecolor128 , MAT_Grunge_Mask128.r ) * MAT_Grunge_Mask128 ) , ( lerp( MAT_Grunge_basecolor128 , MAT_Grunge_basecolor128 , desaturateVar110.x ) * MAT_Grunge_Mask128 ) , ( MAT_Grunge_Mask128 * clamp( ( ase_worldPos.y / _GradientHeight ) , 0.0 , 1.0 ) ).r ) , lerp( lerp( lerp( lerp( tex2DNode5 , tex2DNode5 , _Color0.r ) , tex2D( _Albedo2, uv_Albedo2 ) , ( tex2DNode3 + tex2D( _Mask1, uv_Mask1 ) + tex2DNode4 ).x ) , tex2D( _Albedo3, uv_Albedo3 ) , tex2DNode3.x ) , tex2D( _Albedo4, uv_Albedo4 ) , tex2DNode4.x ) , clamp( ( ase_worldPos.y / _GradientHeight ) , 0.0 , 1.0 ) ).xyz;
         float2 uv_MetallicMask = i.uv_texcoord * _MetallicMask_ST.xy + _MetallicMask_ST.zw;
         o.Metallic = ( _Metallic * tex2D( _MetallicMask, uv_MetallicMask ) ).r;
         o.Smoothness = lerp( lerp( 0.0 , _GrungeSmoothness , ( MAT_Grunge_Mask128 * clamp( ( ase_worldPos.y / _GradientHeight ) , 0.0 , 1.0 ) ).r ) , _Smoothness , ( MAT_Grunge_Mask128 * clamp( ( ase_worldPos.y / _GradientHeight ) , 0.0 , 1.0 ) ).r );
         o.Alpha = 1;
      }

      ENDCG
      CGPROGRAM
      #pragma surface surf Standard keepalpha fullforwardshadows

      ENDCG
      Pass
      {
         Name "ShadowCaster"
         Tags{ "LightMode" = "ShadowCaster" }
         ZWrite On
         CGPROGRAM
         #pragma vertex vert
         #pragma fragment frag
         #pragma target 3.0
         #pragma multi_compile_shadowcaster
         #pragma multi_compile UNITY_PASS_SHADOWCASTER
         #pragma skip_variants FOG_LINEAR FOG_EXP FOG_EXP2
         # include "HLSLSupport.cginc"
         #if ( SHADER_API_D3D11 || SHADER_API_GLCORE || SHADER_API_GLES3 || SHADER_API_METAL || SHADER_API_VULKAN )
            #define CAN_SKIP_VPOS
         #endif
         #include "UnityCG.cginc"
         #include "Lighting.cginc"
         #include "UnityPBSLighting.cginc"
         sampler3D _DitherMaskLOD;
         struct v2f
         {
            V2F_SHADOW_CASTER;
            float3 worldPos : TEXCOORD6;
            float4 tSpace0 : TEXCOORD1;
            float4 tSpace1 : TEXCOORD2;
            float4 tSpace2 : TEXCOORD3;
            float4 texcoords01 : TEXCOORD4;
            UNITY_VERTEX_INPUT_INSTANCE_ID
         };
         v2f vert( appdata_full v )
         {
            v2f o;
            UNITY_SETUP_INSTANCE_ID( v );
            UNITY_INITIALIZE_OUTPUT( v2f, o );
            UNITY_TRANSFER_INSTANCE_ID( v, o );
            float3 worldPos = mul( unity_ObjectToWorld, v.vertex ).xyz;
            half3 worldNormal = UnityObjectToWorldNormal( v.normal );
            fixed3 worldTangent = UnityObjectToWorldDir( v.tangent.xyz );
            fixed tangentSign = v.tangent.w * unity_WorldTransformParams.w;
            fixed3 worldBinormal = cross( worldNormal, worldTangent ) * tangentSign;
            o.tSpace0 = float4( worldTangent.x, worldBinormal.x, worldNormal.x, worldPos.x );
            o.tSpace1 = float4( worldTangent.y, worldBinormal.y, worldNormal.y, worldPos.y );
            o.tSpace2 = float4( worldTangent.z, worldBinormal.z, worldNormal.z, worldPos.z );
            o.texcoords01 = float4( v.texcoord.xy, v.texcoord1.xy );
            o.worldPos = worldPos;
            TRANSFER_SHADOW_CASTER_NORMALOFFSET( o )
            return o;
         }
         fixed4 frag( v2f IN
         #if !defined( CAN_SKIP_VPOS )
         , UNITY_VPOS_TYPE vpos : VPOS
         #endif
         ) : SV_Target
         {
            UNITY_SETUP_INSTANCE_ID( IN );
            Input surfIN;
            UNITY_INITIALIZE_OUTPUT( Input, surfIN );
            surfIN.uv_texcoord.xy = IN.texcoords01.xy;
            float3 worldPos = float3( IN.tSpace0.w, IN.tSpace1.w, IN.tSpace2.w );
            fixed3 worldViewDir = normalize( UnityWorldSpaceViewDir( worldPos ) );
            surfIN.worldPos = worldPos;
            surfIN.worldNormal = float3( IN.tSpace0.z, IN.tSpace1.z, IN.tSpace2.z );
            surfIN.internalSurfaceTtoW0 = IN.tSpace0.xyz;
            surfIN.internalSurfaceTtoW1 = IN.tSpace1.xyz;
            surfIN.internalSurfaceTtoW2 = IN.tSpace2.xyz;
            SurfaceOutputStandard o;
            UNITY_INITIALIZE_OUTPUT( SurfaceOutputStandard, o )
            surf( surfIN, o );
            #if defined( CAN_SKIP_VPOS )
            float2 vpos = IN.pos;
            #endif
            SHADOW_CASTER_FRAGMENT( IN )
         }
         ENDCG
      }
   }
   Fallback "Standard"
   Fallback "Diffuse"
   CustomEditor "ASEMaterialInspector"
}
/*ASEBEGIN
Version=11001
1927;29;1906;1004;1597.374;342.3948;1.3;True;True
Node;AmplifyShaderEditor.CommentaryNode;80;-2940.927,-1764.01;Float;False;1006.66;294.19;Get World Y Vector Mask;5;110;101;98;97;99;;0;0
Node;AmplifyShaderEditor.WorldNormalVector;99;-2921.248,-1697.798;Float;False;1;0;FLOAT3;0,0,0;False;4;FLOAT3;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.AbsOpNode;97;-2730.805,-1680.904;Float;False;1;0;FLOAT3;0.0,0,0;False;1;FLOAT3
Node;AmplifyShaderEditor.CommentaryNode;81;-1906.896,-1961.803;Float;False;730.3268;510.8144;Create the world gradient;6;90;89;88;87;86;85;;0;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;98;-2569.405,-1698.303;Float;False;2;2;0;FLOAT3;0.0,0,0;False;1;FLOAT3;0.0,0,0;False;1;FLOAT3
Node;AmplifyShaderEditor.ColorNode;35;-2655.054,-317.0729;Float;False;Constant;_Color0;Color 0;12;0;1,1,1,0;0;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.SamplerNode;2;-2279.325,-263.6511;Float;True;Property;_Mask1;Mask 1;0;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.SamplerNode;5;-2676.097,-510.002;Float;True;Property;_Albedo1;Albedo 1;3;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.CommentaryNode;138;-2915.776,-12.39359;Float;False;550.8003;900.8;Comment;4;12;10;8;6;;0;0
Node;AmplifyShaderEditor.CommentaryNode;82;-2810.323,-1412.81;Float;False;1190.279;652.7703;Lerp the 2 Gradient Bottom Colors according to the above normals y vector;5;128;104;103;95;94;;0;0
Node;AmplifyShaderEditor.ComponentMaskNode;101;-2397.709,-1715.003;Float;True;False;True;False;True;1;0;FLOAT3;0,0,0;False;1;FLOAT
Node;AmplifyShaderEditor.RangedFloatNode;88;-1856.895,-1744.499;Float;False;Property;_GradientHeight;Gradient Height;15;0;20;0;20;0;1;FLOAT
Node;AmplifyShaderEditor.SamplerNode;3;-1960.005,-220.8992;Float;True;Property;_Mask2;Mask 2;1;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.WorldPosInputsNode;85;-1795.096,-1911.803;Float;False;0;4;FLOAT3;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.SamplerNode;4;-1638.599,-270.4998;Float;True;Property;_Mask3;Mask 3;2;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.SamplerNode;8;-2793.226,236.3508;Float;True;Property;_Normal2;Normal 2;9;0;None;True;0;False;white;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT3;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.DesaturateOpNode;110;-2144.576,-1659.884;Float;False;2;0;FLOAT3;0,0,0;False;1;FLOAT;0.0;False;1;FLOAT3
Node;AmplifyShaderEditor.SimpleAddOpNode;36;-1909.657,100.0259;Float;False;3;3;0;FLOAT4;0,0,0,0;False;1;FLOAT4;0,0,0,0;False;2;FLOAT4;0,0,0,0;False;1;FLOAT4
Node;AmplifyShaderEditor.SamplerNode;6;-2812.193,46.39771;Float;True;Property;_Normal1;Normal 1;7;0;None;True;0;False;white;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT3;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.SubstanceSamplerNode;128;-2651.676,-1167.297;Float;True;Property;_SubstanceSample0;Substance Sample 0;17;0;9d7a2f960af3df34180d69781aa00371;0;True;1;0;FLOAT2;0,0;False;5;COLOR;FLOAT3;COLOR;COLOR;COLOR
Node;AmplifyShaderEditor.SimpleDivideOpNode;86;-1502.16,-1807.891;Float;False;2;0;FLOAT;0.0;False;1;FLOAT;0.0;False;1;FLOAT
Node;AmplifyShaderEditor.RangedFloatNode;90;-1544.49,-1545.388;Float;False;Constant;_Float18;Float 18;-1;0;1;0;0;0;1;FLOAT
Node;AmplifyShaderEditor.LerpOp;14;-2356.59,-467.1975;Float;False;3;0;FLOAT4;0.0;False;1;FLOAT4;0,0,0,0;False;2;COLOR;0,0,0,0;False;1;FLOAT4
Node;AmplifyShaderEditor.SamplerNode;7;-2203.926,-508.3499;Float;True;Property;_Albedo2;Albedo 2;4;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.RangedFloatNode;89;-1577.926,-1665.189;Float;False;Constant;_Float16;Float 16;-1;0;0;0;0;0;1;FLOAT
Node;AmplifyShaderEditor.SamplerNode;10;-2795.101,435.1999;Float;True;Property;_Normal3;Normal 3;10;0;None;True;0;False;white;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT3;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.LerpOp;15;-1799.589,-439.0997;Float;False;3;0;FLOAT4;0,0,0,0;False;1;FLOAT4;0,0,0,0;False;2;FLOAT4;0,0,0,0;False;1;FLOAT4
Node;AmplifyShaderEditor.SamplerNode;9;-1836.202,-647.8004;Float;True;Property;_Albedo3;Albedo 3;5;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.ClampOpNode;87;-1327.767,-1810.415;Float;True;3;0;FLOAT;0.0;False;1;FLOAT;0.0;False;2;FLOAT;0.0;False;1;FLOAT
Node;AmplifyShaderEditor.LerpOp;94;-2139.606,-1305.805;Float;True;3;0;COLOR;0.0,0,0,0;False;1;COLOR;0.0,0,0,0;False;2;COLOR;0,0,0,0;False;1;COLOR
Node;AmplifyShaderEditor.LerpOp;95;-2137.308,-1087.01;Float;True;3;0;COLOR;0.0,0,0,0;False;1;COLOR;0.0,0,0,0;False;2;FLOAT3;0,0,0;False;1;COLOR
Node;AmplifyShaderEditor.LerpOp;18;-2317.517,315.5995;Float;False;3;0;FLOAT3;0,0,0,0;False;1;FLOAT3;0,0,0;False;2;COLOR;0,0,0,0;False;1;FLOAT3
Node;AmplifyShaderEditor.SamplerNode;11;-1479.802,95.39973;Float;True;Property;_Albedo4;Albedo 4;6;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT4;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;104;-1847.317,-1309.82;Float;True;2;2;0;COLOR;0,0,0,0;False;1;COLOR;0,0,0,0;False;1;COLOR
Node;AmplifyShaderEditor.LerpOp;16;-1318.595,-433.3004;Float;False;3;0;FLOAT4;0,0,0,0;False;1;FLOAT4;0,0,0,0;False;2;FLOAT4;0,0,0,0;False;1;FLOAT4
Node;AmplifyShaderEditor.CommentaryNode;84;-1560.129,-1234.811;Float;False;574.3599;190.4;Lerp the Bottom and Top Colors according to the world gradient;1;96;;0;0
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;103;-1852.277,-1030.771;Float;True;2;2;0;COLOR;0.0;False;1;COLOR;0,0,0,0;False;1;COLOR
Node;AmplifyShaderEditor.RangedFloatNode;112;-911.677,163.3115;Float;False;Constant;_Float15;Float 15;20;0;0;0;1;0;1;FLOAT
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;105;-921.9808,-1281.384;Float;True;2;2;0;COLOR;0,0,0,0;False;1;FLOAT;0,0,0,0;False;1;COLOR
Node;AmplifyShaderEditor.RangedFloatNode;121;-902.3761,253.81;Float;False;Property;_GrungeSmoothness;Grunge Smoothness;14;0;0.3;0;1;0;1;FLOAT
Node;AmplifyShaderEditor.LerpOp;19;-2141.719,377.901;Float;False;3;0;FLOAT3;0,0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT4;0,0,0,0;False;1;FLOAT3
Node;AmplifyShaderEditor.SamplerNode;12;-2786.604,642.1992;Float;True;Property;_Normal4;Normal 4;8;0;None;True;0;False;white;Auto;True;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;FLOAT3;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.LerpOp;96;-1446.439,-1155.861;Float;False;3;0;COLOR;0.0,0,0,0;False;1;COLOR;0,0,0,0;False;2;COLOR;0.0;False;1;COLOR
Node;AmplifyShaderEditor.RangedFloatNode;46;-563.7569,519.9283;Float;False;Property;_Metallic;Metallic;12;0;0.5;0;1;0;1;FLOAT
Node;AmplifyShaderEditor.SamplerNode;47;-572.0581,610.5273;Float;True;Property;_MetallicMask;Metallic Mask;13;0;None;True;0;False;white;Auto;False;Object;-1;Auto;Texture2D;6;0;SAMPLER2D;;False;1;FLOAT2;0,0;False;2;FLOAT;1.0;False;3;FLOAT2;0,0;False;4;FLOAT2;0,0;False;5;FLOAT;1.0;False;5;COLOR;FLOAT;FLOAT;FLOAT;FLOAT
Node;AmplifyShaderEditor.LerpOp;111;-591.5782,137.3115;Float;True;3;0;FLOAT;0.0;False;1;FLOAT;0,0,0,0;False;2;COLOR;0,0,0,0;False;1;FLOAT
Node;AmplifyShaderEditor.RangedFloatNode;13;-589.9933,372.9004;Float;False;Property;_Smoothness;Smoothness;11;0;0.5;-1;1;0;1;FLOAT
Node;AmplifyShaderEditor.LerpOp;20;-1952.82,444.1995;Float;False;3;0;FLOAT3;0,0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT4;0,0,0,0;False;1;FLOAT3
Node;AmplifyShaderEditor.LerpOp;17;-1076.393,-243.9997;Float;False;3;0;FLOAT4;0,0,0,0;False;1;FLOAT4;0,0,0,0;False;2;FLOAT4;0,0,0,0;False;1;FLOAT4
Node;AmplifyShaderEditor.LerpOp;76;-837.4583,-269.9713;Float;True;3;0;COLOR;0,0,0,0;False;1;FLOAT4;0,0,0,0;False;2;FLOAT;0,0,0,0;False;1;FLOAT4
Node;AmplifyShaderEditor.LerpOp;21;-1105.418,49.89931;Float;False;3;0;FLOAT3;0,0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT4;0,0,0,0;False;1;FLOAT3
Node;AmplifyShaderEditor.SimpleMultiplyOpNode;48;-232.1585,499.2276;Float;False;2;2;0;FLOAT;0.0;False;1;COLOR;0.0;False;1;COLOR
Node;AmplifyShaderEditor.LerpOp;122;-283.7758,227.21;Float;True;3;0;FLOAT;0.0;False;1;FLOAT;0,0,0,0;False;2;COLOR;0,0,0,0;False;1;FLOAT
Node;AmplifyShaderEditor.StandardSurfaceOutputNode;0;31.09991,141.0995;Float;False;True;3;Float;ASEMaterialInspector;0;Standard;Amplify/LERP Mask;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;False;Back;0;0;False;0;0;Opaque;0.5;True;True;0;False;Opaque;Geometry;All;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;True;False;0;255;255;0;0;0;0;False;0;4;10;25;False;0.5;True;0;Zero;Zero;0;Zero;Zero;Add;Add;0;False;0;0,0,0,0;VertexOffset;False;Cylindrical;Relative;0;Standard;-1;-1;-1;-1;0;15;0;FLOAT3;0,0,0;False;1;FLOAT3;0,0,0;False;2;FLOAT3;0,0,0;False;3;FLOAT;0.0;False;4;FLOAT;0.0;False;5;FLOAT;0.0;False;6;FLOAT3;0,0,0;False;7;FLOAT3;0,0,0;False;8;FLOAT;0.0;False;9;FLOAT;0.0;False;10;OBJECT;0.0;False;11;FLOAT3;0,0,0;False;12;FLOAT3;0,0,0;False;14;FLOAT4;0,0,0,0;False;15;FLOAT3;0,0,0;False;0
WireConnection;97;0;99;0
WireConnection;98;0;97;0
WireConnection;98;1;97;0
WireConnection;101;0;98;0
WireConnection;110;0;101;0
WireConnection;36;0;3;0
WireConnection;36;1;2;0
WireConnection;36;2;4;0
WireConnection;86;0;85;2
WireConnection;86;1;88;0
WireConnection;14;0;5;0
WireConnection;14;1;5;0
WireConnection;14;2;35;0
WireConnection;15;0;14;0
WireConnection;15;1;7;0
WireConnection;15;2;36;0
WireConnection;87;0;86;0
WireConnection;87;1;89;0
WireConnection;87;2;90;0
WireConnection;94;0;128;0
WireConnection;94;1;128;0
WireConnection;94;2;128;4
WireConnection;95;0;128;0
WireConnection;95;1;128;0
WireConnection;95;2;110;0
WireConnection;18;0;6;0
WireConnection;18;1;8;0
WireConnection;18;2;35;0
WireConnection;104;0;94;0
WireConnection;104;1;128;4
WireConnection;16;0;15;0
WireConnection;16;1;9;0
WireConnection;16;2;3;0
WireConnection;103;0;95;0
WireConnection;103;1;128;4
WireConnection;105;0;128;4
WireConnection;105;1;87;0
WireConnection;19;0;18;0
WireConnection;19;1;10;0
WireConnection;19;2;36;0
WireConnection;96;0;104;0
WireConnection;96;1;103;0
WireConnection;96;2;105;0
WireConnection;111;0;112;0
WireConnection;111;1;121;0
WireConnection;111;2;105;0
WireConnection;20;0;19;0
WireConnection;20;1;12;0
WireConnection;20;2;3;0
WireConnection;17;0;16;0
WireConnection;17;1;11;0
WireConnection;17;2;4;0
WireConnection;76;0;96;0
WireConnection;76;1;17;0
WireConnection;76;2;87;0
WireConnection;21;0;20;0
WireConnection;21;1;6;0
WireConnection;21;2;4;0
WireConnection;48;0;46;0
WireConnection;48;1;47;0
WireConnection;122;0;111;0
WireConnection;122;1;13;0
WireConnection;122;2;105;0
WireConnection;0;0;76;0
WireConnection;0;1;21;0
WireConnection;0;3;48;0
WireConnection;0;4;122;0
ASEEND*/
//CHKSM=2DC250D87FF45DF76A4D3CE6E0CA8A511C43DFB2
jurassic_queer
 
Posts: 11
Joined: Thu Jul 20, 2017 4:40 pm

Re: Register index exceeded for texture samplers

Postby Ricardo Teixeira » Fri Aug 11, 2017 10:16 am

Hello,

Thank you for using ASE, we really appreciate your support.

Although the error states that you can use up to 16 samplers, the max number you can really use is lower than that and may vary according to your project settings. This is because a Unity Surface Shader may internally use some samplers for itself( e.g. if you are using light maps ). The only way around this limitation without reducing the amount of samplers is to use a higher shader model.

Is it possible for you to combine/merge some textures in order to reduce the sample count? For example, if you have 4 masks textures, you could merge them on a single texture placing each mask on a separate color channel.

Be sure to let us know if you have any follow up questions, we would be happy to help.

Thanks!
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: Register index exceeded for texture samplers

Postby jurassic_queer » Fri Aug 11, 2017 4:18 pm

I hadn't thought of packing masks per channel like that, actually! I'm already doing that with metallic, gloss, and AO for other shaders I've built. This definitely would give me more flexibility with the amount of masks being used, since in theory I can get 4 masks out of a single texture.

It's good to know that lightmaps are part of the sampler count. I'll keep that in mind.

Thanks!
jurassic_queer
 
Posts: 11
Joined: Thu Jul 20, 2017 4:40 pm

Re: Register index exceeded for texture samplers

Postby Amplify_Borba » Fri Aug 11, 2017 6:02 pm

Glad we were able to help, we're looking forward to see the end results if you would like to share!

Don't hesitate to get back in touch if anything comes up!
Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Amplify_Borba
 
Posts: 1239
Joined: Mon Jul 24, 2017 9:50 am

Re: Register index exceeded for texture samplers

Postby nelsonCiofi » Mon Aug 14, 2017 4:49 pm

Sorry to reply to your topic, but my issue is exactly the same.
I'm creating a shader with splat map features using vertex color and height map as masks.
And yet more strange, the shader works great on the project where I use Amplify Shader Editor.
As soon as I export the files to use in the game project, the error appears.
And I'm already at SM4.6 and the error is this: maximum ps_5_0 sampler register index (16) exceeded at line 93 (on d3d11).

Thanks in advance.
nelsonCiofi
 
Posts: 10
Joined: Fri Jul 07, 2017 4:01 pm

Re: Register index exceeded for texture samplers

Postby Ricardo Teixeira » Mon Aug 14, 2017 5:28 pm

nelsonCiofi wrote:Sorry to reply to your topic, but my issue is exactly the same.
I'm creating a shader with splat map features using vertex color and height map as masks.
And yet more strange, the shader works great on the project where I use Amplify Shader Editor.
As soon as I export the files to use in the game project, the error appears.
And I'm already at SM4.6 and the error is this: maximum ps_5_0 sampler register index (16) exceeded at line 93 (on d3d11).

Thanks in advance.


Hello,

It's likely the same issue, Unity is probably using a few additional samplers on your game project. Please keep in mind that this is an actual Engine/Hardware limitation, you can usually mitigate it by reducing the amount of textures used or increasing the Shader Model version.

Can you pack your textures or are you using all the channels individually? We would be happy to examine a sample.

Thanks!
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: Register index exceeded for texture samplers

Postby nelsonCiofi » Mon Aug 14, 2017 6:22 pm

I am using channels individually for now. If the only solution is to pack then, I will do it.
Changing to SM5.0 also returns the same error, with 16 sampler limit. So I don't think it's a shader model issue.
Strange is that it only shows that error on one project. As I'm the only one in the team responsible for the shaders, I was using a temporary project where I'm using ASE. There the shader works perfectly. I even tried to look on unity configurations, but both projects are matching.
Right now I'm using triplanar samplers for diffuse, normals, roughness, height and AO three times. Once for the base, others are for red and green vertex colors masks. I can exclude AO, and pack rough and height, reducing to two samplers for a texture pack.
I tried to use the TextureObject node, but it was not helpful.
I thought if I could have a TextureObject node with float output instead of sampler, so I could do all calculations and masking before sending to the triplanar sampler. Worth try?

EDIT:
The image of shader nodes.
Image

Here it's working on sample project. Bone wall is the base material. Dirt ground is painted with red channel vertex color and rocks are on green channel. As soon as it is loaded on another project the error appears.
Image

Thanks a lot!
nelsonCiofi
 
Posts: 10
Joined: Fri Jul 07, 2017 4:01 pm

Re: Register index exceeded for texture samplers

Postby Ricardo Teixeira » Mon Aug 14, 2017 7:21 pm

nelsonCiofi wrote:I am using channels individually for now. If the only solution is to pack then, I will do it.
Changing to SM5.0 also returns the same error, with 16 sampler limit. So I don't think it's a shader model issue.
Strange is that it only shows that error on one project. As I'm the only one in the team responsible for the shaders, I was using a temporary project where I'm using ASE. There the shader works perfectly. I even tried to look on unity configurations, but both projects are matching.
Right now I'm using triplanar samplers for diffuse, normals, roughness, height and AO three times. Once for the base, others are for red and green vertex colors masks. I can exclude AO, and pack rough and height, reducing to two samplers for a texture pack.
I tried to use the TextureObject node, but it was not helpful.
I thought if I could have a TextureObject node with float output instead of sampler, so I could do all calculations and masking before sending to the triplanar sampler. Worth try?

EDIT:
The image of shader nodes.
Image

Here it's working on sample project. Bone wall is the base material. Dirt ground is painted with red channel vertex color and rocks are on green channel. As soon as it is loaded on another project the error appears.
Image

Thanks a lot!


Hello,

Thank you for the additional information. As we mentioned earlier, although it states that you can use up to 16 samplers, the max number you can really use is lower than that and may vary according to your project. This is because a Unity Surface Shader may internally use some samplers for itself( e.g. if you are using light maps ). The only way around this limitation without reducing the amount of samplers is to use a higher shader model. For your particular case, you will likely have to reduce the number of samplers by packing your textures.

Thanks!
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm

Re: Register index exceeded for texture samplers

Postby francois85 » Fri Nov 02, 2018 8:19 am

Quick question, if i use Mode set to Reference on the sampler node does that count towards the total ?
francois85
 
Posts: 32
Joined: Thu Oct 04, 2018 2:20 pm

Re: Register index exceeded for texture samplers

Postby Ricardo Teixeira » Fri Nov 02, 2018 12:07 pm

francois85 wrote:Quick question, if i use Mode set to Reference on the sampler node does that count towards the total ?


Hey there!

It does not, it's similar to using a Texture Asset node.

Thanks!
Sales & Customer Relations at Amplify Creations
Learn more about our offering: Amplify Creations Products
Amplify Shader Editor won the Asset Store Best Tool Award - Thank you for your support!
User avatar
Ricardo Teixeira
 
Posts: 954
Joined: Fri Aug 09, 2013 2:26 pm


Return to Amplify Shader Editor

Who is online

Users browsing this forum: No registered users and 20 guests