Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Steven-1 · Jul 04, 2012 at 08:21 AM · surface shaderspecular

Shader error: too many "TEXCOORD"

I wrote a surface shader that's an extension to the bumped diffuse shader (ads snow based on world normal). that worked, then I made a variant with specular, but that doesn't compile. I get the error:

Shader error in 'Custom/snowBumpedSpec': Program 'frag_surf', input semantic attribute "TEXCOORD" has too big of a numeric index (8) at line 74 Keywords: DIRECTIONAL, LIGHTMAP_OFF, DIRLIGHTMAP_OFF, SHADOWS_SCREEN

So apparently I use to many texcoord, which doesn't make much sense to me, as I don't use more than in my (snow) bumped diffuse shader.

Also, I looked at the built in Reflective/Bumped Specular shader, and it's just as complex; the same amount of textures, the same amount of parameters, and even 1 more uv-set (1 use the float2 uv_MainTex for both the diffuse and normalmap)

So anyone that can help me ?

Edit: the shader:

 Properties 
     {
  _MainColor ("Color", Color) = (1,1,1,1)
  _MainTex ("Texture", 2D) = "white" {}
  _SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1)
  _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
  _BumpMap ("Bumpmap", 2D) = "bump" {}
  _SnowTex ("Snow", 2D) = "white" {}
  _SnowAmount ("Snow Amount", Range(0.0,5.0)) = 1.0
     }
     
     SubShader 
     {
       Tags { "RenderType" = "Opaque" }
       
       CGPROGRAM
       #pragma surface surf BlinnPhong
       #pragma target 3.0
       
       struct Input 
       {
           float2 uv_MainTex;//:TEXCOORD0;
           //float2 uv_BumpMap;
           float3 worldPos;
           float3 worldNormal;
  INTERNAL_DATA
       };
       
       float4 _MainColor;
       sampler2D _MainTex;
  float _Shininess;
       sampler2D _BumpMap;
       sampler2D _SnowTex;
       float _SnowAmount;
       
  void surf (Input IN, inout SurfaceOutput o) 
  {
         float4 tex = tex2D (_MainTex, IN.uv_MainTex)*_MainColor;
         float4 snow = tex2D (_SnowTex, IN.worldPos.xz);
         o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_MainTex));           

         float snowfactor = 1 - WorldNormalVector(IN, normalize(o.Normal)).y;
         snowfactor = snow.a - snowfactor;
        
         if (_SnowAmount>1)
             snowfactor *= _SnowAmount;
         else
             snowfactor += (_SnowAmount-1)*2;
         snowfactor = saturate(snowfactor);
         tex = snow*snowfactor + tex*(1-snowfactor);
         o.Albedo = tex.rgb;
         o.Specular = _Shininess;
         o.Gloss = tex.a;
         o.Alpha = tex.a;
  }
       ENDCG
     } 
     
     Fallback "snowSpecular"


Edit2: the compiled shader:

 Shader "Custom/snowBumpedSpec" 
 {
     Properties 
     {
  _MainColor ("Color", Color) = (1,1,1,1)
  _MainTex ("Texture", 2D) = "white" {}
  _SpecColor ("Specular Color", Color) = (0.5,0.5,0.5,1)
  _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
  _BumpMap ("Bumpmap", 2D) = "bump" {}
  _SnowTex ("Snow", 2D) = "white" {}
  _SnowAmount ("Snow Amount", Range(0.0,5.0)) = 1.0
     }
     
     SubShader 
     {
       Tags { "RenderType" = "Opaque" }
       
       // surface shader with errors was here
 Pass { }
 /*/* surface debug info:
  needs world normal vector
  needs world space position
  stuff performed in tangent space
  passes tangent-to-world matrix to pixel shader
 */
 /* surface debug info:
  needs world normal vector
  needs world space position
  stuff performed in tangent space
  passes tangent-to-world matrix to pixel shader
 */
 /* surface debug info:
  stuff performed in tangent space
 */
 /* surface debug info:
  needs world normal vector
  needs world space position
  stuff performed in tangent space
  passes tangent-to-world matrix to pixel shader
 */
 */
 #LINE 65
 
     } 
     
     Fallback "snowSpecular"
   }
Comment
Add comment · Show 2
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 Bunny83 · Jul 04, 2012 at 10:20 AM 0
Share

The important thing is what sematics have you assigned to your vertex data. TEXCOORD0, TEXCOORD1, TEXCOORD2, ...? It seems you try to use a uv-channel greater than 7. Can you post the shader? or at least the parameters / vertex data definition.

Feel free to edit your question.

avatar image Steven-1 · Jul 04, 2012 at 12:25 PM 0
Share

nothing, it's a surface shader, you don't need to assign semantics as it doesn't have any effect (at least that's my understanding of it), I tried giving them all a TEXCOORD semantic, but that fixes nothing.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by ScroodgeM · Jul 14, 2012 at 02:04 PM

  1. enable #pragma debug in shader, this will add comments to compiled shader.

    1. open compiled shader and you'll see all semantics that really used in shader - there will be shadows textures and so on

    2. disable unused checks and calculations and shader - this can free some texture coordinates you need

    3. if nothing helps, try to use one mapping (tiling/offset) for many textures, for example, use uv_MainTex in tex2D methods for _MainTex and _BumpMap - this will free 1 texcoord

Comment
Add comment · Show 3 · 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 Steven-1 · Jul 17, 2012 at 08:00 AM 0
Share

thanks for the answer. 1+2. I added the #pragma debug, but it doesn't really help me much, because the shader doesn't compile, I get "// surface shader with errors was here" followed by some info about passes, which doesn't tell me much appart form the fact that it seems to do 4 passes, of which 3 seem to be the same (see my editted post above). 3. I added "nolightmap nodirlightmap"but that doesn't seem to make a difference, I don't what else I can do. 4. I already do that

so I'm still at loss here :s

avatar image ScroodgeM · Jul 17, 2012 at 09:54 AM 0
Share

float4 snow = tex2D (_SnowTex, IN.worldPos.xz);

this row makes error. so first you can avoid this method to get pixel based not on geometry and then your shader will compile. after that repeat 1+2

avatar image Steven-1 · Jul 17, 2012 at 01:26 PM 0
Share

huh, you're right, I guess some extra texturecoordinates are needed for that for some reason. The compiled shader looks like chinese to me though, but I'll try to make sense of it. thanks for the help

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

6 People are following this question.

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

Related Questions

Adding Spheremap reflection and Gloss/Shininess controls to a Sruface Shader 0 Answers

Surface Shader Specular 0 Answers

Specular vs. Emission in Surface Shader? 2 Answers

How can I use a "Specular" property with surface shaders using the Standard lighting model? 0 Answers

Simple Blinn Phong Surface Shader 1 Answer


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