Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 /
avatar image
0
Question by jamesflowerdew · Apr 24, 2014 at 11:30 AM · errorshaderterrainsurface

Too many texture interpolators would be used for ForwardBase pass (again)

This shader gives me the above error (minus the "(again)") when I uncomment the line that starts "//o.normal". It's for a terrain, and the idea is to use worldspace instead of normal uvs so hills aren't all stretchy. I searched online and most people seemed to be struggling with multiple sets of uvs, but I've got 3 with that line commented and still only 3 commented so why does it break?

Appologies if it's a typo but I've stared at it for hours.

 Shader "gamevial/TerrainWorldMapped" {
 
     Properties {
         _Control("Control",2D)= "grey" {}
         _Splat0("Texture2 (R)", 2D) = "white" {}
          _Normal0 ("Bump2 (R)",2D)="grey"{}
         _Splat1("Texture3 (G)", 2D) = "white" {}
         _Normal1 ("Bump3 (G)",2D)="grey"{}
          _Splat2("Texture4 (B)", 2D) = "white" {}
         _Normal2 ("Bump4 (B)",2D)="grey"{}
         _Splat3 ("Texture1 (A)", 2D) = "white" {}
         _Normal3  ("Bump1 (A)",2D)="grey"{}
         _MainTex ("BaseMap (RGB)", 2D) = "white" {}
         _Detail("Fallback Detail",2D)="white"{}
         _Scale ("Texture Scale", Float) = 0.1
     }
     SubShader {
         Tags { "RenderType"="Opaque" "SplatCount" = "4" "Queue" = "Geometry-100" }
         LOD 200
         
         CGPROGRAM
         #pragma surface surf Lambert
               struct Input {
                   float2 uv_Control;
                   float3 worldNormal;
                 float3 worldPos;
               };
                  sampler2D _Normal3;
               sampler2D _Normal0;
               sampler2D _Normal1;
               sampler2D _Normal2;
               sampler2D _Splat3;
               sampler2D _Splat0;
               sampler2D _Splat1;
               sampler2D _Splat2;
               sampler2D _Control;
               float _Scale;
          void surf (Input IN, inout SurfaceOutput o) {
               float2 UV;
               if(abs(IN.worldNormal.x)>0.5) {
                   UV = IN.worldPos.yz*_Scale; // side
               }else if(abs(IN.worldNormal.z*_Scale)>0.5) {
                   UV=IN.worldPos.xy;//front
               } else {
                 UV = IN.worldPos.xz*_Scale; // top
             }
               half4 vCT=tex2D(_Control, IN.uv_Control).rgba;
              //o.Normal=((tex2D(_Normal0, UV))*vCT.r)+((tex2D(_Normal1, UV))*vCT.g)+((tex2D(_Normal2, UV))*vCT.b)+((tex2D(_Normal3, UV))*vCT.a);
              o.Albedo =((tex2D(_Splat0,UV).rgb)*vCT.r)+((tex2D(_Splat1,UV).rgb)*vCT.g)+((tex2D(_Splat2,UV).rgb)*vCT.b)+((tex2D (_Splat3,UV).rgb)*vCT.a);
             
           }
         ENDCG
     } 
     FallBack "Diffuse"
Comment
Add comment · Show 1
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 jamesflowerdew · Apr 24, 2014 at 02:39 PM 0
Share

as a note, experimenting with another shader suggests that o.Normal freaks out with the above uv mix for bumpmaps without the splat, could this be the problem? can annyone explain?

1 Reply

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

Answer by jamesflowerdew · Jul 13, 2014 at 11:48 AM

Hi All, I figured this out finally. I should mention that I got a clue here, albeit not one that I understood: http://forum.unity3d.com/threads/unity-3-2-update-too-many-texture-interpolators-in-triplanar-projection.78579/

I needed to build my own normal variable and get it through using a vert program and changes to the input struct, using the one that's there already freaks out unity (a fixable bug?). My new normal stuff is ccalled "myNormal".

 Shader "gamevial/TerrainWorldMapped" {
 
     Properties {
         _Control("Control",2D)= "grey" {}
         _Splat0("Texture1 (R)", 2D) = "white" {}
          _Normal0 ("Bump1 (R)",2D)="grey"{}
         _Splat1("Texture2 (G)", 2D) = "white" {}
         _Normal1 ("Bump2 (G)",2D)="grey"{}
          _Splat2("Texture3 (B)", 2D) = "white" {}
         _Normal2 ("Bump3 (B)",2D)="grey"{}
         _Splat3 ("Texture4 (A)", 2D) = "white" {}
         _Normal3  ("Bump4 (A)",2D)="grey"{}
         //_MainTex ("BaseMap (RGB)", 2D) = "white" {}
         //_Detail("Fallback Detail",2D)="white"{}
         _Scale ("Texture Scale", Float) = 0.1
     }
     SubShader {
         Tags { "RenderType"="Opaque" "SplatCount" = "4" "Queue" = "Geometry-100" }
         LOD 200
         
         CGPROGRAM
         #pragma surface surf Lambert vertex:vert
         //#pragma target 3.0
         
           struct Input {
               float2 uv_Control;
               float3 worldNormal;
             float3 worldPos;
             float3 myNormal;
           };
           void vert(inout appdata_full v, out Input o) {
                o.worldPos = mul(_Object2World, v.vertex).xyz;
             o.worldNormal = mul(_Object2World, float4(v.normal, 0.0)).xyz;
             o.myNormal=o.worldNormal;
         }
            sampler2D _Normal0,_Normal1,_Normal2,_Normal3;
         sampler2D _Splat0,_Splat1,_Splat2,_Splat3;
         sampler2D _Control;
         float _Scale;
         void surf (Input IN, inout SurfaceOutput o) {
              half4 vCT=tex2D(_Control, IN.uv_Control).rgba;
              float vBlack=1-vCT.r-vCT.g-vCT.b;
               float2 UV = IN.worldPos.xz*_Scale;
             if(abs(IN.myNormal.x)>0.5) {
                    UV = IN.worldPos.yz*_Scale; // side
              }else if(abs(IN.myNormal.z)>0.5) {
                   UV=IN.worldPos.xy*_Scale;//front
              }
           
               half3 vAlb=(tex2D(_Splat3,UV).rgb*vBlack)+(tex2D(_Splat0,UV).rgb*vCT.r)+(tex2D(_Splat1,UV).rgb*vCT.g)+(tex2D(_Splat2,UV).rgb*vCT.b);
               half4 vNor=(tex2D(_Normal3, UV)*vBlack) + (tex2D(_Normal0, UV)*vCT.r) + (tex2D(_Normal1, UV)*vCT.g) + (tex2D(_Normal2, UV)*vCT.b);
                o.Normal= UnpackNormal(vNor);
              o.Albedo =vAlb;
         }
         ENDCG
     } 
     FallBack "Diffuse"
 }

Comment
Add comment · 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

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

20 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

Related Questions

Unity Terrain - shader for custom post-splat? 0 Answers

CG diffuse shader 1 Answer

Problem with custom shaders (surface function error) 0 Answers

GLSL: Shader cannot be patched for instancing 1 Answer

jungle terrain problem 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