Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

LightProbes.GetInterpolatedProbe includes dynamic lights?

Discussion in 'Global Illumination' started by MattDavis, Mar 16, 2015.

  1. MattDavis

    MattDavis

    Joined:
    Aug 11, 2013
    Posts:
    16
    Hi,

    I'm trying to use LightProbes.GetInterpolatedProbe in Unity 5, and I'm under the impression that the result is supposed to be influenced by dynamic lights: http://docs.unity3d.com/ScriptReference/LightProbes.GetInterpolatedProbe.html

    The function returns the interpolated light probe values just fine, but when I place a point light in the scene and move it around, it doesn't change the result at all. What am I missing? Do I need to somehow mark the point light as being part of the light probe group?
     
  2. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    I think they are only meant to pick up the indirect bounced light from dynamic lights. All your objects will already be effected by the dynamic light directly any way, so you wouldn't want that light added to the probes themselves.
     
  3. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Correct.

    Direct lighting only ends up in the light probe if the light is marked as a baked.
     
  4. MattDavis

    MattDavis

    Joined:
    Aug 11, 2013
    Posts:
    16
    That makes sense, thank you.

    What I'm actually doing is extracting the dominant direction and colour for use in a toon shader, so I do want direct dynamic lights to be included. I think I can probably get good results by using SphericalHarmonicsL2.AddDirectionalLight on the interpolated probe for each dynamic light source.
     
  5. colin299

    colin299

    Joined:
    Sep 2, 2013
    Posts:
    181
    hello DaleMagicalWhale,
    Could you tell us how do you use C# script to convert LightProbes.GetInterpolatedProbe(...) 's result (9x3 = 27 floats)
    to a RGB Color(Vector3)?

    I am trying to get the baked light for my toon shader's tint color also.
    Currently I am using code by bluescrn.(I modify a bit in order to use it in Unity5, the API is different in Unity5)
    http://forum.unity3d.com/threads/getinterpolatedlightprobe-interpreting-the-coefficients.209223/

    Provide a world space position & normal direction, the code above will return a RGB color.
    But the result is different from the color calculated by "Use light probes" option in renderer(with Mobile/Diffuse or Standard Shader),


    does your color result using LightProbes.GetInterpolatedProbe(...) similar to "Use light probes" option in renderer's result?
     
  6. MattDavis

    MattDavis

    Joined:
    Aug 11, 2013
    Posts:
    16
    Yeah, I was trying to use the code in that thread too, and I'm having similar incorrect results. In the meantime I'm passing the light direction to the shader and calling ShadeSH9 in the same two directions at every vertex. I'll make a post in that other thread.
     
    colin299 likes this.