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 MarushiaDark · May 28, 2014 at 09:14 PM · shaderunity4.3#pragma

CGProgram Shader Broken in Unity 4?

Am learning how to make custom shaders in Unity 4.3.4. free version. I've been following the tutorials by Unity Cookie and they are fairly simple and straightforward. My code is exactly the same as his (for the part I'm at in the video - 8:00), except I changed "v" to "input" and "o" to "output." In his video, it shows the shader working just fine, but I keep getting bizarre and unexplainable errors. I've checked this code over several times, even using Reimport and still nothing.

Some of the errors I keep getting are:

  • Material doesn't have a color property '_Color'

  • Shader error in 'Marushia Dark/Beginner/ 2 - Lambert': Shader program had errors at line 9

  • Shader error in 'Marushia Dark/Beginner/ 2 - Lambert': Program 'frag', struct "vertexInput" previously defined at (23) at line 27

  • Shader error in 'Marushia Dark/Beginner/ 2 - Lambert': Program 'vert', syntax error, unexpected '(' at token "(" at line 31

In a previous version, with the exact same code, I didn't get all these errors, but I did get an error at Line 8, which is the CGProgram line. I've heard that it should be placed outside the Pass, but this makes no sense to me, since I have other working shaders that put it INSIDE the Pass.

Again, not sure what the problem is. I've formatted it almost the exact same way as another shader that IS working, so I'm not understanding these errors.

 Shader "Marushia Dark/Beginner/ 2 - Lambert" {
     Properties {
         _Color ("Base", Color) = (1.0, 1.0, 1.0, 1.0)
     }
     
     SubShader {
         Pass {
             CGPROGRAM
             #pragma vertex vert    //Line 9
             #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 vertexInput{
                 float4 vertex : SV_POSITION;
                 float4 col : COLOR;
             };                              // Line 27
             
             
             // Vertex Function
             vertexOutput vert(vertexInput input){       // Line 31
                 vertexOutput output;
                 
                 output.col = float4(input.normal, 1.0);
                 output.pos = mul(UNITY_MATRIX_MVP, input.vertex);
                 return output;
             }
             
             
             // Fragment Function - This part still not finished, but should at least work.
             float4 frag(vertexOutput i) : COLOR
             
             {
                 return i.col;
             }
             
             ENDCG
         }
     } 
     // Fallbacks
     // FallBack "Diffuse"
 }
 


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 meat5000 ♦ · May 28, 2014 at 09:21 PM 0
Share
  1. release claims to have improved shader compiler.

avatar image MarushiaDark · May 29, 2014 at 10:02 PM 0
Share

Thank you. This seems to have helped ... for now. :)

0 Replies

· Add your reply
  • Sort: 

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

21 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

Related Questions

Parse error: Syntax Error in compiled shader, Unity 4.3.1 [free] 1 Answer

Shaders #pragma exclude 1 Answer

Shaders: Constant register limit exceeded - what does it mean? 2 Answers

Additional blending when using properties rather than hard-coded values for colors 0 Answers

Apply shader to a sprite. 3 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