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 benbenben · Aug 14, 2013 at 01:53 PM · errorshadercgglsl

CG shader is treated as GLSL and doesn't compile

Hi, I need a shader to support vertex colors, so I followed this tutorial here: http://en.wikibooks.org/wiki/Cg_Programming/Unity/Smooth_Specular_Highlights and made the modifications so it showed the vertex color. I also added Texture sampling.

The shader was created and tested in a different project/scene I need it in, just to have a clean work environment. There it works as I want it to.

Creating a new shader in my real project and copypasting the shader's code into the newly created shader, results in errors during shader compilation, such as:

"Material doesn't have a texture property '_MainTex'" "GLSL vertex shader: 73: ERROR: '' unsupported construction at line 13" (that's where "CGPROGRAM" is written in the shader's code)

The second error message suggests that the shader is being compiled by a GLSL-compiler and not a CG-compiler.

Is there a way to set the type of shader explicitly to CG so Unity does not try to compile it as GLSL?

I have also tried to copypaste the unmodified tutorial code above into the shader, but the GLSL error persists.

Comment
Add comment · Show 5
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 robertbu · Aug 14, 2013 at 02:10 PM 0
Share

If you post the shader code, we can perhaps spot the issue.

avatar image Peter G · Aug 14, 2013 at 02:16 PM 0
Share

If you go to any shader and hit "Open Compiled" you'll see that Unity actually compiles your shader multiple times into different formats so yes, it probably was compiling it into GLSL when it threw the error.

Having said that. Rarely do I get an error writing a shader that actually has anything to do with the line the mistake is on. You probably have an error somewhere in your CG thats stopping it from compiling.

avatar image CHPedersen · Aug 14, 2013 at 02:16 PM 0
Share

For what it's worth, the line numbers reported by shader compilation are often totally worthless. Confusingly, I think they refer to lines in the lower level code which is generated by the compiler, and not the user-level code we write.

avatar image benbenben · Aug 14, 2013 at 03:00 PM 0
Share

Ok... the way I created the new shader was the problem. I copypasted the shader code from the tutorial above into the newly created shader and then replaced the properties section and the two passes. However, there was an invisible character added when pasting. This character was invisible in the Visual Studio editor. The compiler errors are gone.

Now I have the problem that it doesn't look like it did when I tested it in a separate environment. Should I create a new thread/question here for this or just append it to this one?

Thank you for your help so far.

avatar image robertbu · Aug 14, 2013 at 03:51 PM 0
Share

Post a new question.

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

17 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

Related Questions

Cg Language incompatibility Desktop VS GLSL Android 0 Answers

Grabpass refraction masking 0 Answers

How to prevent shader optimizations? 1 Answer

CG compiled to GLSL: hyperbolic functions not found. 0 Answers

Shader error in ... : Syntax error at line 30 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