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

Pointlight Range falloff

Discussion in 'General Graphics' started by clammy2017, Mar 8, 2019.

  1. clammy2017

    clammy2017

    Joined:
    Feb 21, 2018
    Posts:
    27
    Hi.

    Is it possible to change the falloff of a realtime point light source?

    I want to change it to a linear falloff to match the artwork i've been given.

    Googling got me some code, that I don't really understand where and how to plug it in - and seems to be for baked lightmaps.

    Is there any way of doing it in real time? I'm using 2018.3.5f1 if that's any help? I can happily upgrade to latest/beta/etc though if it means I can do this.

    Thanks
     
  2. blossomgames

    blossomgames

    Joined:
    Oct 23, 2013
    Posts:
    30
    Hi,

    In c:\Program Files\Unity\Hub\Editor\2018.3.6f1\Editor\Data\CGIncludes\ you have various hlsl files that define shading/lighting. In UnityCG.cginc I found a function Shade4PointLights which computes lighting for points lights, but I think it's some special case for forward rendering. Maybe you can hack away some more functions to get linear falloff.

    Although, instead of fiddling with Unity's core cg include files maybe you could write custom lighting for surface shaders? Have a look here: https://docs.unity3d.com/Manual/SL-SurfaceShaderLighting.html and here https://docs.unity3d.com/Manual/SL-SurfaceShaderLightingExamples.html

    All best