Search Unity

Bake indirect light map at runtime

Discussion in 'Global Illumination' started by kevin-masson, Oct 2, 2018.

  1. kevin-masson

    kevin-masson

    Joined:
    Sep 24, 2018
    Posts:
    73
    I would like to take benefits of indirect lighting but my scene is generated at runtime. Is there a way to generate lights in a script ?
     
  2. fguinier

    fguinier

    Unity Technologies

    Joined:
    Sep 14, 2015
    Posts:
    146
    You can use Enlighten to add light at runtime, however the geometries need to be static so internal enligthen indirect lighting can be precomputed.
     
  3. kevin-masson

    kevin-masson

    Joined:
    Sep 24, 2018
    Posts:
    73
    But if we set them to static and generate create them when running the game, will it work ?
     
  4. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    If you generate mesh, no
    GI with enlighten compute the visibility of all surfaces and use that to inject light at runtime.
    -> environement isn't generated at runtime
    -> light is generated at runtime

    If you want dynamic scene with dynamic mesh created at runtime, use SEGI (search the forum)
     
    kevin-masson likes this.
  5. kevin-masson

    kevin-masson

    Joined:
    Sep 24, 2018
    Posts:
    73
    SEGI is not supported on WebGL and this is the platform we are targetting... But this is only a matter of time before we can use compute shaders in web browsers https://www.khronos.org/registry/webgl/specs/latest/2.0-compute/
     
  6. neoshaman

    neoshaman

    Joined:
    Feb 11, 2011
    Posts:
    6,493
    There is another untested solution though, it's a cheap approximation though, if you are willing to test and roll your own solution...
     
  7. kevin-masson

    kevin-masson

    Joined:
    Sep 24, 2018
    Posts:
    73
    You mean there is another solution with SEGI ?