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. Dismiss Notice

Assigning lightmap UVs without contributing to lighting

Discussion in 'Global Illumination' started by allenwp, Jan 7, 2016.

  1. allenwp

    allenwp

    Joined:
    Sep 4, 2013
    Posts:
    46
    Hello!

    In our game we switch lightmaps at runtime. We also do this after performing a static combine, so it's important that each of the lightmaps have the same UV layout.

    In Unity 4, this was easy: bake once as a "UV" pass with all game objects enabled. Then lockAtlas and disable game objects that shouldn't contribute to the scene for each of the subsequent bakes. (Some game objects must be disabled during baking of certain lightmaps, such as shadow casters, etc.).

    In Unity 5, there is no more "lockAtlas" functionality, so if I enable/disable any game objects with renderers the UV layout will change. This means I must have all the renderers active during any of the bakes to "save them a spot" on the lightmap UV layout.

    But I still want to prevent these certain game objects from contributing to the lighting, even though their renderer is active. How do I do this?

    I have tried changing these objects to use transparent shaders and no material at all, but the objects still contribute to indirect lighting. Disabling shadows is easy, but these objects always seem to affect the indirect lighting in the scene.

    Ideas?

    EDIT: it's easy to get an object to not reflect light (a transparent shader that returns (0,0,0,0) seems to work)... But I'm specifically having a hard time preventing an object from blocking indirect light. No matter what shader or material configuration I use, it seems that my objects are always blocking indirect light.
     
    Last edited: Jan 7, 2016
  2. allenwp

    allenwp

    Joined:
    Sep 4, 2013
    Posts:
    46
    Hmm... I remember there was a bug listed somewhere that objects would still block indirect light, even when "Cast Shadows" is set to "off". I guess this is likely the cause of the problems I'm having... Too bad transparent objects also seem block indirect light.

    Please let me know if you figure out a way to get around this bug/limitation...
     
  3. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    If you have a transparent material you should create a new set of lightmap parameters and set in that lightmap parameters the opon for transparent. Then asine the transparent mesh that lightmap parameters and its working fine. That would work too for stuff that should not influence the scene.