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. Join us on Thursday, June 8, for a Q&A with Unity's Content Pipeline group here on the forum, and on the Unity Discord, and discuss topics around Content Build, Import Workflows, Asset Database, and Addressables!
    Dismiss Notice

Lightmap baking: Cast shadows set to OFF, but still casting shadow (Progressive lightmaps)

Discussion in 'Global Illumination' started by GoldGamesDeveloper, Apr 27, 2021.

  1. GoldGamesDeveloper

    GoldGamesDeveloper

    Joined:
    Jun 10, 2018
    Posts:
    5
    When I bake lightmap, objects that have cast shadows set to off still cast shadows. Is there any way to fix that? It's annoying bug and it has been there since 2018.x version.
     
  2. Jaimi

    Jaimi

    Joined:
    Jan 10, 2009
    Posts:
    6,090
    Is that a bug? I think you need to uncheck the "static" to stop it from casting shadows in lightmaps.
     
  3. Pema-Malling

    Pema-Malling

    Unity Technologies

    Joined:
    Jul 3, 2020
    Posts:
    213
    That doesn't sound right to me. Which version of Unity are on? And do you have repro project on hand?
     
  4. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    9,994
    Are you sure it's from direct light? That's what the off in cast shadows prevents.

    Indirect shadows are not quite shadows. If you want it to not contribute to GI at all, you either need to not have it static, or maybe try something, switching to something transparent for the bake, then switch to the normal shader after.
     
    ShellanderGames and Pema-Malling like this.
  5. Reahreic

    Reahreic

    Joined:
    Mar 23, 2011
    Posts:
    282

    Is there a way to have something receive indirect baked GI, but not contribute shadows to other objects?

    We're using 2022 and have decal quads that unless we set entirely to real-time lighting leave shadow blotches on the mesh they float just overtop of. (Almost like AO is bleeding)
     
  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    9,994
    If by "not contribute shadows" you mean direct shadows, then yes (by turning off cast shadows).

    If you mean "shadows" by bounced indirect light / skylight etc, then not really.

    My workaround is to duplicate the immediate environment, set baked scaled for the environment to 0 (so I don't waste lightmap space on those), then place the item that I want to receive GI but not affect the environment in the duplicate environment (then place it in its proper place at runtime).

    So for example, I have a few items I want to be placed on this desk later in the game.
    upload_2023-1-10_20-38-55.png

    I bake them here:

    upload_2023-1-10_20-39-12.png

    Then I bring them to the actual play area at runtime.
     
  7. Reahreic

    Reahreic

    Joined:
    Mar 23, 2011
    Posts:
    282
    Pretty much, my desire is for the decals to have the same baked lighting as the mesh they're placed upon, but not affect said meshes own baked lighting. (As if the decal was a perfectly transparent vinyl sticker.)

    Runtime relocation works for some areas, but is problematic in others where there isn't the space for duplicate scene geometry.

    Ultimately, I've discussed this topic before, but the general consensus was it's not really supported and was hpoing you had an amazing workaround I could steal.

    The part I don't get is that it's not affecting all decal meshes equally despite identical settings. Decals use their own Lightmap Parameter's assets based on the suggestions in the linked thread, but it's had limited success.
     
  8. Filto

    Filto

    Joined:
    Mar 15, 2009
    Posts:
    713
    Any update on this? Been searching high and low. Surely there must be a way to let an object receive lightmaps without casting AO (or affecting light otherwise). How do one deal with skirt meshes and decals for instance without it? This is puzzling o_O

    Edit: I found a workaround

    1. Change material to transparency and set alpha to 0
    2. Bake your lightmaps
    3. Set your material back to original settings
     
    Last edited: Mar 31, 2023