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:
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.
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?
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.