Search Unity

Lighting blocker mesh for baked lights.

Discussion in 'Global Illumination' started by petey, Sep 3, 2019.

  1. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,292
    Hi there,

    Just wondering, is there a setting to make a mesh only block baked lighting in the lightmapper.
    I’m trying to shape some light shafts in a level but the objects I’m using to shape the light have to be set to static, which means they’ll also have Lightmaps baked for them. Is there a way to avoid that?

    Thanks,
    Pete
     
  2. thefranke

    thefranke

    Unity Technologies

    Joined:
    Jun 20, 2015
    Posts:
    86
    Hey Pete,

    there are two ways in fact: The old one is to go to the MeshRenderer, make it Lightmap Static/Contribute Global Illumination and set Scale in Lightmap to 0. This will effectively do what you described. If you want to have the object also bounce light rather than just block it, and you are on 2019.2, you can instead check Contribute Global Illumination on the Mesh Renderer and select Light Probes in the Receive Global Illumination dropdown menu. More details are here: https://blogs.unity3d.com/2019/08/28/static-lighting-with-light-probes/

    Cheers
     
  3. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,292
    Ahh thanks so much @thefranke that’s great!
    Hey another thing that tripped me up a little was that you can’t seem to use quads to block the light, they seem to need a little thickness. That’s fine though because I’ll make them in Houdini and just extrude a little.
     
  4. thefranke

    thefranke

    Unity Technologies

    Joined:
    Jun 20, 2015
    Posts:
    86
    Perhaps it's a backface issue? Regular quads should work, but only blocking light from the front side. You could also use a thin box.
     
  5. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,292
    Yeah it's weird, I made this quick scene to demo it. The quad seems really glitchy.

    Sep-04-2019 22-16-34.gif

    It's no problem for me to add a bit of thickness to the blockers, but it might be good thing to look at because that glitchyness confused the heck out me for a while. :)
     
  6. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    98
    When you use a simple quad the rays shot from the scene towards the light source hit the quad from behind. The lightmapper treats such hits as invalid. It will then flood fill invalid areas by valid areas from neighboring regions which leads to those large blocks that you can see. You can verify this by switching to the texel validity view.

    The usual way to fix this is to apply a material to the quad and set it to double sided GI. Then rays hitting the quad from behind will still be treated as valid paths and you should be getting your desired result.

    In your case, if you know that rays will only ever hit the quad from one direction, you can flip it 180 degrees so it faces your scene.
     
    teutonicus likes this.
  7. petey

    petey

    Joined:
    May 20, 2009
    Posts:
    1,292
    Oh that’s interesting, so it’s optimising for those areas under things and whatnot.
    Thanks for that @uy3d !