• 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 cod · Sep 26, 2014 at 01:40 PM · errorshadercompilercgcompile errors

Shader error in ... : Syntax error at line 30

I created a custom shader in w$$anonymous$$ch I use the command

 #include "../cginc/CustomParallax.cginc"

right after the CGPROGRAM directive, but once I click save and compile the shader, it gives me t$$anonymous$$s weird error, w$$anonymous$$le if I remove that line, it works perfectly and it compiles my shader. Could someone explain me what's wrong with t$$anonymous$$s statement?

Thanks, t$$anonymous$$s error is driving me mad >.<

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 HarshadK · Sep 26, 2014 at 01:50 PM

You might want to provide the full path in your include like:

 #include "Asset/Path/cginc/CustomParallax.cginc"

Since looks like the ../is causing the error.

Comment
Add comment · Show 6 · 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 cod · Sep 30, 2014 at 07:01 AM 0
Share

yea, I tried this method, too, but it still gives me that strange error. I noticed the problem is in the include part, when it has to open the include file. In fact it seems as if the file is somehow corrupted, even if I tried copying and pasting the code in other files and I still get the error. This is really weird...

avatar image HarshadK · Sep 30, 2014 at 07:31 AM 0
Share

What error are you getting?

avatar image cod · Sep 30, 2014 at 01:36 PM 0
Share

It gives me the error "Syntax error at line 30". However, I noticed that I get no error copying the functions present in the cginc file and pasting them into the shader, that's quite strange. Also the error "Syntax error" seems to be quite generic, and it is related to this line of code

 //Include the Custom Parallax helper file
 #include "../cginc/Parallax.cginc"

And I get the same error with both absolute and relative path...

PS I am using monodevelop to edit the code of both shaders and cginc files, saving them with UNICODE(UTF-8) character encoding.

avatar image HarshadK · Sep 30, 2014 at 01:49 PM 0
Share

Try copying and pasting your .cginc file in either Notepad or Notepad++ and then save that file. Looks like some unwanted characters are added into your .cginc file that is causing this error.

avatar image cod · Sep 30, 2014 at 04:03 PM 0
Share

I did so, but the error persists...

Show more comments

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.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

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

Related Questions

CG shader is treated as GLSL and doesn't compile 0 Answers

Shader compiler: internal error compiling shader snippet type=0 platform=0: 1 Answer

How to force the compilation of a shader in Unity? 5 Answers

cross product in cg shader - error "can't find __getVectorIndex" 1 Answer

Problem with custom shaders (surface function error) 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