Search Unity

MeshRenderer CastShadows [OFF] disables baked GI shadows

Discussion in 'Global Illumination' started by GearedSun, Jul 7, 2021.

  1. GearedSun

    GearedSun

    Joined:
    Apr 17, 2014
    Posts:
    30
    Hi,

    I have updated project to Unity 2019.4.28 and the Cast Shadows parameter on Mesh Renderer component behaves differently now.

    * When I set Cast Shadows to OFF, none of these objects cast lightmapped indirect shadows after baking.

    This is either a bug or completely different behavior from previous Unity versions I used (most recently 2019.1).
    Originally the parameter influenced only direct shadows, not baked indirect. This way I can't have fully baked shadows and hand-pick which objects cast dynamic shadows and which do not.

    The only way would be to create a script, which would disable dynamic shadow casting in Awake or Start, but that is just stupid. If somebody decided that setting Cast Shadows to OFF should also disable indirect, baked lighting, then you should have added a separate parameter for that.
     
    Last edited: Jul 7, 2021
  2. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    Hey! I've attempted to investigate the issue myself, but was unable to reproduce it. I've attached a .gif comparison below:
    MeshRenderer-Shadows-OnVsOff.gif

    I've used 2019.4.28f1, and baked the lighting using the CPU PLM. Pillar meshes on the left-hand side were set to either cast shadows, or have shadows turned off entirely.

    I am not ruling out the possibility that you are indeed experiencing a bug. If you believe that is the case, please report the bug as per these guidelines.
     
  3. GearedSun

    GearedSun

    Joined:
    Apr 17, 2014
    Posts:
    30
    Hi,
    I mainly use GPU lightmapper.

    I've tested it now with the CPU lightmapper and lighting is correct! So it must be related to GPU lightmapper.

    Object on the LEFT has Cast Shadows ON and on the RIGHT has shadows OFF.
    As you can see the image on the right is not correct at all. It looks like a diffuse with GI additively slapped onto it.

    unity_indirect.jpg

    They have indirect lighting from environment (ambient) color and one single directional light. The material used is default diffuse to rule out the shader. Could you please test it with GPU lightmapper? Could GPU drivers have any impact on this?
     
  4. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    GPU PLM does not exhibit this issue on my end either. There might be something specific about your scene setup. Report a bug with a small repro project, and post the bug ID here afterwards. We will investigate.
     
  5. GearedSun

    GearedSun

    Joined:
    Apr 17, 2014
    Posts:
    30
    Well that is really weird. I've created completely fresh project with one mesh and a single scene. The result is the same:
    unity_indirect2.jpg .

    Project files are here as an attachment and bugreport has been sent.

    (Case 1348581) Indirect Environment Lighting broken with Shadows OFF and GPU Lightmapper
     

    Attached Files:

  6. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,735
    Can confirm on 2020.3.13f1
    upload_2021-7-7_19-10-16.png

    It has nothing to do with the Direct Light. I actually deleted the Directional Light in this test.

    It seems like Cast Shadows also affects indirect light (maybe only from environment?), although it used to be only for direct shadows.

    Not sure if it's a bug or a feature.

    It could be a feature, I can actually think of a couple of areas where it would be useful to me, BUT, ideally these would be decoupled and I could turn cast shadows on / off for direct and indirect separately.

    It is also consistent with the CPU Lightmapper. For me GPU and CPU produce the same results.

    The corners look like they are brighter, because light does bounce around it, but it doesn't get occluded. So it has the inverse AO look.

    If I limit the bounces to 1 it looks like this :

    upload_2021-7-7_19-12-46.png

    Since the mesh doesn't occlude the light coming from the environment, it becomes almost uniformly lit.
     
    Last edited: Jul 7, 2021
  7. GearedSun

    GearedSun

    Joined:
    Apr 17, 2014
    Posts:
    30
  8. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    Yes, I have managed to reproduce the issue on my end, thanks to the repro project you've provided. Also, the additional information which @AcidArrow has provided was very useful. Thanks to you both for the assistance!

    Seeing how this issue affects both CPU and GPU lightmappers, it warranted two separate bug reports:
    Keep in mind that we'd still need to investigate this issue further on our end before the fix is made available. Subsequent backports will take additional time, so we cannot give an ETA at this time.
     
  9. Jesper-Mortensen

    Jesper-Mortensen

    Unity Technologies

    Joined:
    Mar 15, 2013
    Posts:
    232
    This issue has been fixed now. The behavior is that environment lighting behaves the same as indirect lighting and is not affected by the cast shadows flag. To make specific objects not affect indirect lighting and environment lighting, the renderer should be set to not Contribute to GI.

    This fix will be backported to supported releases.
     
    GearedSun likes this.
  10. GearedSun

    GearedSun

    Joined:
    Apr 17, 2014
    Posts:
    30
    @Jesper-Mortensen
    Is there a time-frame for backport to 2019.4.x? I'd like to know because it might change our release plans a bit. All I can find is "Planned for 2019.4.X".
     
  11. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    No ETA as of yet. Last update on the case was posted on the 10th of October.