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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity 5 - Dynamic point lights over terrain

Discussion in 'General Graphics' started by Incendiary-Games, May 8, 2015.

  1. Incendiary-Games

    Incendiary-Games

    Joined:
    Mar 24, 2015
    Posts:
    18
    I'm running into an issue I don't know how to solve and Google searching hasn't helped yet. I have a dynamic projectile I'm spawning at runtime with a point light attached. The light lights up any meshes in the scene but not my terrain. I'm using the forward rendering path, terrain is uing Built in legacy diffuse shader (tried standard, doesn't work either.), and Cast Shadows is set on the terrain. In Window- > Lighting I have Precomputed realtime GI and Baked GI checked. If I go to Window -> Lighting -> Objects and uncheck Terrain Lightmap static I get the dynamic lights working on the terrain.

    My fear is that this means the terrain won't be baked which I fear may impact performance later on. Is it expected that runtime dynamic lights don't light terrain that was statically baked? This would seem to indicate so ( http://docs.unity3d.com/460/Documentation/Manual/LightmappingInDepth.html )

    I would expect for Unity to keep a list of lights that shouldn't move (don't have rigid bodies on them) as static and everything else to be dynamic.

    Thanks!
     
  2. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,327
    Caution: this is a guess.

    If you check this document, you'll see that forward rendering path uses limited number of per-pixel lights per object. Basically, depending on quality settings, you'll get main directional light, few brightest per-pixel lights, everything else is being stuffed into per-vertex lights/spherical harmonics.

    So. The thing is, terrain is a HUGE object. If your terrain is a normal static mesh (and not some kind of special object specifically tailored to work as terrain with many dynamic lights), it'll grab pretty much every light in the scene, select several brightest lights, and if your projectile is fairly dim, it won't be one of them.

    To solve the issue either
    1. try marking projectile light as "important"
    or
    2. Try to split terrain into smaller chunks.
    or
    3. (Try to) switch to deferred lighting.

    Please note that this is simply an educated guess regarding possible source of your problem, it might not be real cause of your issue.
     
    Last edited: May 8, 2015
  3. Incendiary-Games

    Incendiary-Games

    Joined:
    Mar 24, 2015
    Posts:
    18
    So right now my scene has one static directional light and the ONLY dynamic light is what I'm spawning on the projectile. I'm *well* aware of forward rendering path lighting limitations. Switching to deferred is broken currently on android on unity 5 for Oculus rift, so its not an option.
     
  4. neginfinity

    neginfinity

    Joined:
    Jan 27, 2013
    Posts:
    13,327
    Android? I cannot help you with that. (I would need test scene/debug it on android device, and frankly, I'm not very interested)

    If I were you, however, I would:
    1. Ensure that your single dynamic light is marked as important. (It is mobile device, after all, wouldn't be surprised if it has 0 per-pixel lights in forward rendering path by default)
    2. Ensure that default quality settings are high enough for android platform (I spent plenty of time recently trying to figure out why I don't have shadows in webplayer)
    3. Check compiled android shader for trouble.
     
  5. Incendiary-Games

    Incendiary-Games

    Joined:
    Mar 24, 2015
    Posts:
    18
    It also occurs on Windows build... Like I said earlier the light renders fine against static meshes, even meshes placed on the terrain. *Only* the terrain, and only if the terrain has baked lighting on it is it broken.........

    I ended up filing a bug.
     
  6. Polkatuba

    Polkatuba

    Joined:
    Oct 31, 2014
    Posts:
    79
    Is your dynamic point light set as "Realtime"? Leaving it "Mixed" will not work as there is currently a limitation with the engine.