Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 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 JohnWatson · Mar 06, 2014 at 01:41 PM · shadermaterialcolorproperty

Material doesn't have a color property '_Color'

I have been following a tutorial on how to code shaders and I have run into an odd problem which the Tutorial poster does not have, even though I checked for typos about 10 times and m eyes are starting to hurt. Could anyone look at my code and check if they can find what i did wrong ?

 Shader "Shaders/2 - Lambert" { //Shader Path
     Properties { //Define any changeable properties here
         _Color ("color", Color) = (1.0,1.0,1.0,1.0) //Color property 
     }
     SubShader { //Main Shader
         Pass {
             Tags { "LighMode" = "ForwardBase" }
             CGPROGRAM
             //pragmas
             #pragma vertex vert
             #pragma fragment frag
             
             //User defined variables
             uniform float4 _Color;
             
             //Unity defined variables
             uniform float4 _LightColor0;
             
             //Base input structs
             struct vertexInput{
                 float4 vertex : POSITION;
                 float3 normal : NORMAL;
             };
             struct vertexOutput{
                 float4 pos : SV_POSITION;
                 float4 col : COLOR;
             };
             
             //vertex function
             vertexOutput vert(vertexInput v){
                 vertexOutput o;
                 
                     float3 normalDirection = normalize( mul( float4( v.normal, 0.0 ), _World2Object ).xyz );
                     float3 lightDirection;
                     float atten = 1.0;
                     
                     lightDirection = normalize( _WorldSpaceLightPos0.xyz );
                     
                     float3 diffuseReflection = atten * _LightColor0.xyz * max( 0.0, dot(normalDirection, lightDirection) );
                     
                     o.col = float4(diffuseReflection, 1.0);
                     o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
                 return o;
             }
             
             //fragment function
             float4 frag(vertexOutput i) : COLOR
             {
                 return i.col;
             }
                 
             ENDCG
         }
     }
     //loads Diffuse in case the Shader doesn't get loaded
     //Fallback "Diffuse"
 }

Thanks in advance

Edit: exact error message: Material doesn't have a color property '_Color' UnityEditor.HostView:OnGUI()

Edit: for some reason getting another error message now: rc.right != m_GfxWindow->GetWidth() || rc.bottom != m_GfxWindow->GetHeight()

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 slippdouglas · Sep 18, 2014 at 09:49 PM 0
Share

Please do not edit your question to include the solution.  This site is designed around cataloging questions multiple users may have, and possible answers including the specific one that worked for you.  The intent is to keep the same questions from being asked over and over, even if it's a solved problem for you.  TL;DR: this is not your problem, it's the community's; so please leave your question in its near-original form for the benefit of others.

avatar image slippdouglas · Sep 18, 2014 at 09:50 PM 0
Share

Further discussion re. this error message on the forums: http://forum.unity3d.com/threads/solved-material-doesnt-have-a-color-property-_color.31326/

4 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by nesis · Mar 06, 2014 at 01:50 PM

I think your "color" needs to be "_Color" on line 3? The _Color property name is used internally in the shader, whereas the bit in quotes is used for accessing that property via Material.GetColor("_Color") or Material.SetColor("_Color",someColor).

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 JohnWatson · Mar 06, 2014 at 01:53 PM 0
Share

Gave it a shot. Did not work. :/

avatar image
0

Answer by JohnWatson · Mar 06, 2014 at 03:15 PM

So I restarted my computer and both my error messages are gone but the lighting still doesn't update here's a link to the video I'm referencing off: 12:49

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 xanat0s · Jan 08, 2016 at 08:04 PM 1
Share

This area is reserved for answers. If you have something to add, edit your question. Don't submit it as an answer.

avatar image
0

Answer by DaleJulian · Jan 14, 2015 at 06:11 AM

 Tags { "LighMode" = "ForwardBase" }


Should be LightMode.

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
avatar image
0

Answer by sri106 · Feb 15, 2015 at 04:53 PM

Actually material have not any colour property,but it has tendency to absorb or reflect the colour of light we can see the colour of the material which light is reflected by material.if a material is in white colour that means the all colour is reflecting by the material

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

24 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

Related Questions

Changing two different objects renderer colour 1 Answer

how to change material color for player customization. 2 Answers

Shader to partially ignore lighting (Specific colors) 0 Answers

Reduce Skid Mark Alpha Gradually 0 Answers

Mobile\Vertex Colored shader 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