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 zagony · Jan 23, 2014 at 10:53 AM · shadertexturematerialproperty

Shader returning lots of ambiguous errors

I have the following code:

 Shader "VXR/Car" {
 Properties {
     _MainCol ("Colour", Color) = (1,1,1,1)
     _PaintTex ("Paint Texture", 2D) = "" {}
     _PaintCol ("Secondary Colour", Color) = (1,1,1,1)
     _AO ("Baked Ambient Occlusion", 2D) = "white" {}
     _Cube ("Cubemap", CUBE) = "" {}
     _RimPower ("Reflection Strength", Range(0.5,8.0)) = 3.0
     _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
     _Shininess ("Shininess", Range (0.01, 1)) = 0.078125
     _BadgeTex ("Badge Texture", 2D) = "" {}
 }
 SubShader {
     Tags { "RenderType" = "Opaque" }
 
 CGPROGRAM
 #pragma surface surf BlinnPhong
 
 fixed4 _MainCol;
 sampler2D _PaintTex;
 fixed4 _PaintCol;
 sampler2D _AO;
 samplerCUBE _Cube;
 float _RimPower;
 half _Shininess;
 sampler2D _BadgeTex;
 
 struct Input {
     fixed4 uv_MainCol;
     float2 uv_PaintTex;
     fixed4 uv_PaintCol;
     float2 uv_AO;
     float3 worldRefl;
     float3 viewDir;
     float2 uv_BadgeTex;
 };
 
 void surf (Input IN, inout SurfaceOutput o) {
     o.Albedo = 1.0 - tex2D (_PaintTex, IN.uv_PaintTex).a;
     o.Albedo *= _MainCol;
     o.Albedo += _PaintCol * tex2D(_PaintTex, IN.uv_PaintTex).a;
     o.Albedo *= -tex2D (_BadgeTex, uv_BadgeTex).a;
     o.Albedo += tex2D (_BadgeTex, uv_BadgeTex).a * tex2D (_BadgeTex, uv_BadgeTex).rgb;
     o.Albedo *= tex2D (_AO, IN.uv_AO).rgb;
     half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
     o.Emission = texCUBE (_Cube, IN.worldRefl) * pow (rim, _RimPower);
     o.Gloss = _SpecColor.a;
     o.Specular = _Shininess;
     o.Alpha = 1.0;
 }
 ENDCG
 }
 
 FallBack "Specular"
 }

It was all working until I added _BadgeTex, and then it returned 33 similar errors; Material doesn't have a --- property '---'

Any Help would be great, thanks in advance.

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
0

Answer by Owen-Reynolds · Jan 23, 2014 at 04:12 PM

There's probably a single real error in the shader, hopefully near the top of the error list. "Missing property" are just Unity pile-on errors, sprayed each frame by the Editor when the shader is broken in a particular way.

I don't see the error off-hand. Typing a line at a time can help. You might be running into too many texture lookups. Tex2D is expensive, but a real graphics card can handle at least 16. Even so, might be faster and cleaner to get badgeTexture just once: half4 bCol = tex2D(_BadgeTex...); and then o.Albedo+=bCol.a * bCol.rgb; and so on.

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

19 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

Related Questions

Material doesn't have a color property '_Color' 4 Answers

Multiple materials on same object 0 Answers

How to apply different textures to one model? 1 Answer

Texture2D to Texture3D 2 Answers

Tracing in Unity3D 2 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