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.

Calculating spotlight falloff on CPU (HDRP)

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

  1. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    305
    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