Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by fistfulofrain42 · Oct 05, 2015 at 11:58 PM · terrainshaderstransparency

Terrain Transparency - Too many text interpolators

I've been following the steps in this wiki to create a section of transparent terrain. When I paste the code into a new Standard Surface Shader, I received this error:

Shader error in 'Nature/Terrain/Diffuse': Too many texture interpolators would be used for ForwardBase pass (11 out of max 10) at line 24 (on )

I've looked at other questions here, but none of them have a solution to this compiling error. Here is the code from the wiki:

 Shader "Nature/Terrain/Diffuse"
 {
     Properties
     {
         [HideInInspector] _Control ("Control (RGBA)", 2D) = "red" {}
         [HideInInspector] _Splat3 ("Layer 3 (A)", 2D) = "white" {}
         [HideInInspector] _Splat2 ("Layer 2 (B)", 2D) = "white" {}
         [HideInInspector] _Splat1 ("Layer 1 (G)", 2D) = "white" {}
         [HideInInspector] _Splat0 ("Layer 0 (R)", 2D) = "white" {}
         //Used in fallback on old cards & base map
         [HideInInspector] _MainTex ("BaseMap (RGB)", 2D) = "white" {}
         [HideInInspector] _Color ("Main Color", Color) = (1,1,1,1)
     }
  
     SubShader
     {
         Tags
         {
             "SplatCount" = "4"
             "Queue" = "Geometry-100"
             "RenderType" = "Opaque"
         }
         Blend SrcAlpha OneMinusSrcAlpha
         CGPROGRAM
         #pragma surface surf Lambert
         struct Input
         {
             float2 uv_Control : TEXCOORD0;
             float2 uv_Splat0 : TEXCOORD1;
             float2 uv_Splat1 : TEXCOORD2;
             float2 uv_Splat2 : TEXCOORD3;
             float2 uv_Splat3 : TEXCOORD4;
         };
  
         sampler2D _Control;
         sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
  
         void surf (Input IN, inout SurfaceOutput o)
         {
             fixed4 splat_control = tex2D (_Control, IN.uv_Control);
             fixed4 firstSplat = tex2D (_Splat0, IN.uv_Splat0);
             fixed3 col;
             col = splat_control.r * tex2D (_Splat0, IN.uv_Splat0).rgb;
             col += splat_control.g * tex2D (_Splat1, IN.uv_Splat1).rgb;
             col += splat_control.b * tex2D (_Splat2, IN.uv_Splat2).rgb;
             col += splat_control.a * tex2D (_Splat3, IN.uv_Splat3).rgb;
             o.Albedo = col;
             o.Alpha = 1;
             if(tex2D(_Splat0, IN.uv_Splat0).a == 0)
                 o.Alpha = 1 - splat_control.r;
             else if(tex2D(_Splat1, IN.uv_Splat1).a == 0)
                 o.Alpha = 1 - splat_control.g;
             else if(tex2D(_Splat2, IN.uv_Splat2).a == 0)
                 o.Alpha = 1 - splat_control.b;
             else if(tex2D(_Splat3, IN.uv_Splat3).a == 0)
                 o.Alpha = 1 - splat_control.a;
         }
         ENDCG
     }
  
     Dependency "AddPassShader" = "Hidden/TerrainEngine/Splatmap/Lightmap-AddPass"
     Dependency "BaseMapShader" = "Diffuse"
  
     //Fallback to Diffuse
     Fallback "Diffuse"
 }

I'm using Unity 5.2.1f1 Personal. How can I fix this error? I'm new to coding shaders.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Statement · Oct 10, 2015 at 03:15 PM

Your shaders model target does not support that many texture interpolators. You can specify a higher shader model target using #pragma target <shader model>, for example #pragma target 4.0, or you could try to simplify your shader so it fits in target 2.0 or 3.0.

  • Manual: Shader Targets


By default, Unity compiles shaders into roughly shader model 2.0 equivalent.


#pragma target 4.0 - compile to DX10 shader model 4.0.
This target is currently only supported by DirectX 11 and XboxOne/PS4 platforms.


Note that all OpenGL-like platforms (including mobile) are treated as “capable of shader model 3.0”. WP8/WinRT platforms (DX11 feature level 9.x) are treated as only capable of shader model 2.0.

 Shader "Nature/Terrain/Diffuse"
 {
     Properties
     {
         [HideInInspector] _Control("Control (RGBA)", 2D) = "red" {}
         [HideInInspector] _Splat3("Layer 3 (A)", 2D) = "white" {}
         [HideInInspector] _Splat2("Layer 2 (B)", 2D) = "white" {}
         [HideInInspector] _Splat1("Layer 1 (G)", 2D) = "white" {}
         [HideInInspector] _Splat0("Layer 0 (R)", 2D) = "white" {}
         //Used in fallback on old cards & base map
         [HideInInspector] _MainTex("BaseMap (RGB)", 2D) = "white" {}
         [HideInInspector] _Color("Main Color", Color) = (1,1,1,1)
     }
 
     SubShader
     {
         Tags
         {
             "SplatCount" = "4"
             "Queue" = "Geometry-100"
             "RenderType" = "Opaque"
         }
 
         Blend SrcAlpha OneMinusSrcAlpha
 
         CGPROGRAM
 
         #pragma surface surf Lambert
         #pragma target 4.0
 
         struct Input
         {
             float2 uv_Control : TEXCOORD0;
             float2 uv_Splat0 : TEXCOORD1;
             float2 uv_Splat1 : TEXCOORD2;
             float2 uv_Splat2 : TEXCOORD3;
             float2 uv_Splat3 : TEXCOORD4;
         };
 
         sampler2D _Control;
         sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
 
         void surf(Input IN, inout SurfaceOutput o)
         {
             fixed4 splat_control = tex2D(_Control, IN.uv_Control);
             fixed4 firstSplat = tex2D(_Splat0, IN.uv_Splat0);
             fixed3 col;
             col = splat_control.r * tex2D(_Splat0, IN.uv_Splat0).rgb;
             col += splat_control.g * tex2D(_Splat1, IN.uv_Splat1).rgb;
             col += splat_control.b * tex2D(_Splat2, IN.uv_Splat2).rgb;
             col += splat_control.a * tex2D(_Splat3, IN.uv_Splat3).rgb;
             o.Albedo = col;
             o.Alpha = 1;
             if (tex2D(_Splat0, IN.uv_Splat0).a == 0)
                 o.Alpha = 1 - splat_control.r;
             else if (tex2D(_Splat1, IN.uv_Splat1).a == 0)
                 o.Alpha = 1 - splat_control.g;
             else if (tex2D(_Splat2, IN.uv_Splat2).a == 0)
                 o.Alpha = 1 - splat_control.b;
             else if (tex2D(_Splat3, IN.uv_Splat3).a == 0)
                 o.Alpha = 1 - splat_control.a;
         }
         ENDCG
     }
 
     Dependency "AddPassShader" = "Hidden/TerrainEngine/Splatmap/Lightmap-AddPass"
     Dependency "BaseMapShader" = "Diffuse"
 
     //Fallback to Diffuse
     Fallback "Diffuse"
 }

  

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fistfulofrain42 · Oct 12, 2015 at 12:23 AM 0
Share

Thank you! No more complier issue.

Now, the terrain is still not transparent, but that's a question for another thread. Again, thanks for your help and clear explanation.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

32 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to show transparent PNG on a plane - without backfaces? 0 Answers

Transperent Side of a Texture becomes black in Shader PBR Graph 1 Answer

Transparent shaders make my custom plane completly invisible 1 Answer

Custom opaque shader looks transparent 0 Answers

Recieve shadows on transparent material 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges