All my ShaderForge generated shaders broke after upgrading to 2018.1. The reason, it turns out, is the change from the LIGHT_ATTENUATION() macro (back in Unity 5) to now UNITY_LIGHT_ATTENUATION(), which was made final in 2018.1. So just rename all your instances and the shaders should work again.

2 thoughts to “LIGHT_ATTENUATION becomes UNITY_LIGHT_ATTENUATION in 2018.1”

  1. It appears the new UNITY_LIGHT_ATTENUATION macro takes extra arguments. Having trouble converting…

    1. These are the macro definitions I found in the unity built-in shaders, so it seems like yes, the definition and parameter count has changed.


      #define LIGHT_ATTENUATION(a)    (tex2D(_LightTexture0, dot(a._LightCoord,a._LightCoord).rr).UNITY_ATTEN_CHANNEL * SHADOW_ATTENUATION(a))


      #   define UNITY_LIGHT_ATTENUATION(destName, input, worldPos) \
              DECLARE_LIGHT_COORD(input, worldPos); \
              fixed shadow = UNITY_SHADOW_ATTENUATION(input, worldPos); \
              fixed destName = (lightCoord.z > 0) * UnitySpotCookie(lightCoord) * UnitySpotAttenuate( * shadow;

      destName is the target variable the attenuation will be written into. input should be your v2f struct. worldPos is the world position which is something you should have in your v2f struct as a variable.

Leave a Reply

Your email address will not be published.