Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Point ligths, attenuation and range

Discussion in 'Shaders' started by jsr184, Jun 3, 2013.

  1. jsr184

    jsr184

    Joined:
    Mar 27, 2013
    Posts:
    1
    Hi,

    I'm trying to use unity_LightAtten[0].z to calculate attenuation ( it's ForwardAdd pass )

    Code (csharp):
    1.  
    2. float atten = 1.0 / ( 1.0 + lengthSq * unity_LightAtten[0].z );
    3.  
    It looks like unity_LightAtten[0].z is always 0 for point lights. Can't get it working. I can't read the light range either. Changing light range in the editor doesn't affect the way the light works with my model. Are the attenuation and range exposed to the shader? I know there are variables declared in cginc files but values they take don't seem to be correct. I use ForwardBase and ForwardAdd passes to render my model.

    Thanks,
    Jsr