Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

LIGHT_ATTENUATION randomly broken >_<

Discussion in 'Shaders' started by Alesk, Mar 11, 2016.

  1. Alesk

    Alesk

    Joined:
    Jul 15, 2010
    Posts:
    339
    Hi,

    Playing with this shader : http://wiki.unity3d.com/index.php?title=TransparentShadowReceiver

    I'm facing a weir bug with Unity 5.3.3f1 : while tweaking the shader code and switching between the editor and monodevelop to see the result, suddenly the value returned by LIGHT_ATTENUATION(i) is always 0 and I can't get the right values to come back (light and shadow intensity), even if I put back the original shader code which was working at first ...

    I've tried to switch to another shader in my material and then again the problematic one, delete my project Library folder, reinstall unity : nothing helps :(

    Does someone have an idea to fix this problem please ?
     
  2. Farfarer

    Farfarer

    Joined:
    Aug 17, 2010
    Posts:
    2,249
    And you're in forward rendering mode and trying to get shadows from a directional light?
     
  3. Alesk

    Alesk

    Joined:
    Jul 15, 2010
    Posts:
    339
    Yes, and it was perfectly working at the beginning ... then not anymore >__<
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,236
    Technically LIGHT_ATTENUATION is deprecated, isn't it? Try moving over to SHADOW_ATTENUATION?
     
  5. Alesk

    Alesk

    Joined:
    Jul 15, 2010
    Posts:
    339
    I've started a fresh new project, and for now it's working again with both LIGHT_ATTENUATION or SHADOW_ATTENUATION.
    I'll post a new message if I have this problem again and/or find its cause.
     
  6. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    305
    Is it? I can't get correct attenuation from point lights in forward add pass with SHADOW_ATTENUATION, but it works fine with LIGHT_ATTENUATION
     
  7. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,236
    LIGHT_ATTENUATION is a Unity 4.0 that does light distance falloff and shadows. SHADOW_ATTENUATION is just the shadow with no distance falloff. For Unity 5.0 the equivalent for LIGHT_ATTENUATION is UNITY_LIGHT_ATTENUATION. In both 4.0 and 5.0 the LIGHT_ATTENUATION macro just calls SHADOW_ATTENUATION for directional lights, but the differ some for other light types.
     
  8. Alesk

    Alesk

    Joined:
    Jul 15, 2010
    Posts:
    339
    Thanks a lot for this explanation :)
     
  9. Phantom_X

    Phantom_X

    Joined:
    Jul 11, 2013
    Posts:
    305
    I can confirm that UNITY_LIGHT_ATTENUATION works, thanks!