Search Unity

Clarification on light attenuation/radius

Discussion in 'Shaders' started by kiwi, Dec 19, 2010.

  1. kiwi

    kiwi

    Joined:
    Nov 13, 2008
    Posts:
    11
    Hi - sorry if this has been asked before but I couldn't find a definitive answer (despite all my googling efforts). As I understand it lights in Unity (point/spot/directional) use quadratic falloff - all well and good. However, from what I can see this fall off seems to be scaled by the light range i.e. the range is not just setting the maximum distance from a point that we want to calculate the influence of a light, but is actually adjusting the light intensity as well. This is not what I want - I want to set the lights intensity and just have it fall off without being influenced by a "range", the same as I would get if I created a point light in Maya with quadratic falloff.

    So my question is, how do I write a "new" point light (or similar) light component? Do I just have to create my own game object, attach a "light" script to it and then have the surface shaders access those parameters some how? Or do I have to write a new LIGHT_ATTENUATION function?

    I'm just a bit new to writing shaders for Unity, and I'm not quite clear on how I would achieve this. Thanks for any help.
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    you can not create an own light, as you don't have access to the corresponding buffers to feed the pipeline with the data to make it a light
     
  3. kiwi

    kiwi

    Joined:
    Nov 13, 2008
    Posts:
    11
    Thanks - I figured that might be the case. I have also just noticed another thread like this one on the same page (that I somehow missed) so sorry for the spam.
     
  4. kiwi

    kiwi

    Joined:
    Nov 13, 2008
    Posts:
    11
    Ok, so I did just find similar questions to this going back to 2006 all of which seem to say "yes, it's going to take range into account" - which is disappointing.
     
  5. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,355
    You can re-write the attenuation function if you want. It just won't work with the deferred renderer, whose lighting is hard-coded.