• 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 Hoeloe · Feb 03, 2014 at 05:47 PM · androidshaderopengl

Shader on Android - Custom .cginc not loading

So, I'm developing a shader, hoping to put it up on the asset store. It's pretty much done, but I thought I'd try it out on Android first, just to make sure it was compatible, and I tried it out. Unfortunately, it came out looking like this:

Lighted area appears solid black

Now, there are a few things that are particularly odd about this. First off, it shows the outline, but not the main body. All of the lighting calculations are in a separate, cginc file, which I'm #including. This is exactly the effect I get when there are compile errors in that file, and having changed it to only display solid white (to check it was an error loading it rather than a calculation error), I still got this effect. What is particularly odd about this, though, is that the left image is running with OpenGL ES 2.0 compatibility active, which means it SHOULD run fine on Android. (Turning on OpenGL ES 1.x does not render correctly, but gives a black object with no outline - not the same effect). The thing is, there isn't anything too odd about the cginc file. It contains one #include itself (specifically #include "UnityCG.glslinc"), and a number of variable declarations (all named with the format: half _Name). It also contains a few inline functions for the lighting calculations.

I cannot understand for the life of me why it seems to fail to load this file correctly. I have tried both relative (`#include ../CG.cginc`) and absolute (`#include Assets/CG.cginc`), but both have given the same result. Some help here would be appreciated.

IMPORTANT EDIT:

I tried removing the function from the .cginc file and putting it straight in the shader, and it didn't fix the issue. Does anyone know what might be causing this?

EDIT AGAIN:

Well, it looks, from the testing I've done, like it's something to do with the instruction count. I have a lot of separate instructions going on here, and cutting out a couple seems to fix it. I'm working on cutting it down now.

anicelerror.png (358.5 kB)
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
Best Answer

Answer by Hoeloe · Feb 03, 2014 at 07:57 PM

I've sorted this. There was too much calculation, so I've made a slightly trimmed down "Lite" version that will run on mobile.

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

18 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

Related Questions

Uniform variable fails on the android 0 Answers

Cubemap on Android 1 Answer

How to use shader depth buffer offset in android on unity 5 0 Answers

Android development build opengl 1 Answer

Mobile Bumped Specular: Point Lights Only 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