Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Calculating spotlight falloff on CPU (HDRP)

Discussion in 'Shaders' started by Gooren, Jul 11, 2021.

  1. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    278
    Hi, how could one calculate spotlight falloff strength at specific distance when using HDRP? I need to calculate this on CPU.

    I tried the following:
    Code (CSharp):
    1. float distanceNormalized = distanceFromSpotLightToSamplePoint / _spotLight.range;
    2. float falloff = 1f / (distanceNormalized * distanceNormalized);
    3. float intensityAtDistance = _spotLight.intensity * falloff;
     
    Last edited: Jul 15, 2021
unityunity