Search Unity

Light intensity at a point in space?

Discussion in 'General Graphics' started by Vectrex, Aug 13, 2020.

  1. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    Howdy, just trying to sample the light at a point in space. I COULD use a rendertexture, but that won't include the lights themselves.
    I realised that the generation of lightprobes is doing what, I think.
    Is there any way to use the probe api to generate the data for a single probe where I place it?
    Any other suggestions?
     
    Last edited: Aug 14, 2020
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,352
    The way you'd do this with light probes would be to have a light probe grid, and then use GetInterpolatedProbe to get the interpolated lighting data for a specific position.
    https://docs.unity3d.com/ScriptReference/LightProbes.GetInterpolatedProbe.html

    Light probes only include fully baked lights and ambient lighting for a specific position. They're also encoded in a spherical harmonic, meaning they're storing the amount of light coming from different directions, not the total light from all directions. You'd have to evaluate the spherical harmonic in the 6 main axis to get something that's approximately the total light. For real time lights you'd still need to get a list of all lights in the scene, find which ones that point is in range of, calculate the attenuation and occlusion (aka shadow). And realistically that all has to be done on the CPU.
     
  3. Vectrex

    Vectrex

    Joined:
    Oct 31, 2009
    Posts:
    267
    Yeah, trouble is it needs to be dynamic. So I'll probably just use a render texture
     
  4. koirat

    koirat

    Joined:
    Jul 7, 2012
    Posts:
    2,074
    If it needs to be dynamic you can raycast from all runtime lights affecting the point to probed position. if raycast is not occluded than just add calculated light value at this point.