I’m working on a project that has a pretty intricate shader which was working well in previous versions of Unity. However, while trying to upgrade to Unity 4.6.4, I found that the shader suddenly stopped working on device, though it still works fine in the Unity Editor. It seems to dislike a specific line, though I’m not totally sure if it is the source of the issue.
In my shaderlab code, I’ve got this line in my fragment shader:
half4 normVals[2] = { half4(0,0,0,0), half4(0,0,0,0) };
Which seems to translate into this compiled code on device:
constant float4 _xlat_mtl_const1[2] = {float4(0.0, 0.0, 0.0, 0.0), float4(0.0, 0.0, 0.0, 0.0)};
//LOTS OF CODE OMITTED
normVals_1 = half4[2](_xlat_mtl_const1);
When I run on device, I get this in the log at startup:
So that’s a bit strange to me…Unfortunately, I can’t share the full shader code without jumping through a bunch of red tape with our client, but I was wondering if someone could shed some light on why this error would occur in this scenario. Am I using some syntax that isn’t allowed in ShaderLab? When I look at the compiled shader in 4.6.2 vs 4.6.4, the 4.6.2 shader code does appear to be a lot simpler/shorter, and doesn’t have the offending line that is causing the shader to fail on device.