Upgrade issue: _LightMatrix0 is now unity_WorldToLight

I have a problem with a shader now that I have moved to 5.4 from 5.3. The Unity upgrade docs state that:

_LightMatrix0 is now unity_WorldToLight

Indeed, some upgrade code / parser / compiler keeps upgrading _LightMatrix0 to unity_WorldToLight in my shader*.* Unfortunately, the shader does not compile with the new variable name and I see this error:

Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING
Compiling Vertex program with DIRECTIONAL
undeclared identifier ‘unity_WorldToLight’

However, I cannot work out what I should include to define unity_WorldToLight. I can’t find this in the cginclude files.

Now, I could get round this issue (temporarily) if I could keep using the original variable name, which compiles fine. However, the upgrade code keeps changing it back to use the new name each time I change it. Can this be stopped?

You can disable automatic upgrade. Just put UNITY_SHADER_NO_UPGRADE in a comment somewhere.
It is mentioned in 5.4 changelog:
Shaders: Added ability to exclude shaders from automatic upgrade by having “UNITY_SHADER_NO_UPGRADE” anywhere in shader source file.

The unity_WorldToLight matrix is in AutoLight.cginc, and I’m pretty sure preventing it from updating and continuing to use _LightMatrix0 will fail with the same error as the value really has been removed unless you’re using old copies of the file in your assets folder.

add to the ‘Pass’

#include “Lighting.cginc”
#include “AutoLight.cginc”

1 Like