Search Unity

Question Calculating spotlight falloff on CPU

Discussion in 'High Definition Render Pipeline' started by Gooren, Jul 15, 2021.

  1. Gooren

    Gooren

    Joined:
    Nov 20, 2015
    Posts:
    332
    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;
    NOTE: I already asked on the forum, only to later notice that I did so in the wrong section (Shaders instead of HDRP)

    EDIT: Better put - what I ultimately want to find out is the spot light intensity that applies at specific distance from the light source.
     
    Last edited: Jul 15, 2021