Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Static shadows on static objects with Distance Shadowmask?

Discussion in 'Global Illumination' started by blzq, Jan 29, 2021.

  1. blzq

    blzq

    Joined:
    Jan 29, 2021
    Posts:
    2
    Is there any way to get static objects to cast baked shadows onto other static objects using Distance Shadowmask? I'm aware that the non-Distance Shadowmask quality setting does this, but in return the ability to cast realtime shadows onto dynamic objects from static objects is lost.

    Also as an aside, why is realtime shadowing for static object caster and static receiver useful? It seems that it would just reduce the quality and performance of shadows in places that it can be baked in.
     
  2. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
    No, there isn't. As to why, mixing realtime shadows and baked shadows would be difficult. The statics are all rendered into the same shadowmap with dynamics. You could try blending the shadowmask and the realtime shadowmap when rendering the statics, but you wouldn't be able to tell whether the shadow from the shadowmap comes from a static or dynamic. This isn't an issue when you are fully lit or in shadows, but if you have baked soft shadows with a wide penumbra, blending in this penumbra region becomes a problem. You could always prefer the soft shadow from the shadowmask, but then sharper shadows from dynamic objects would look soft whenever they overlay such a penumbra region on statics. You could opt for the sharp shadows from the shadowmap, but this would probably cause artifacts in the penumbra regions of statics casting shadows on other statics.
    In order to do this properly, you need to have separate shadowmaps for static and dynamic objects, along with the overhead of either sampling two maps for dynamic objects, or merging them for those. On the flip side, the static shadowmap could also be precalculated and cached, but Unity doesn't do that.
     
  3. blzq

    blzq

    Joined:
    Jan 29, 2021
    Posts:
    2
    Thanks for the response!

    Rigged up a penumbra scene with basic Shadowmask and I see what you mean about the unrealistic appearance of the shadow cast on the floor (in the image, the sphere is dynamic and everything else static, with a single directional light), although I feel it could still be an acceptable-looking option included in Distance Shadowmask depending on the scene.



    Alternatively, when using Distance Shadowmask since the shadows become realtime there aren't really any large penumbras anyway - so I feel like it could also have been another option to bake a second penumbra-less "realtime-appearance shadows" map for the static objects that is used below the distance threshold.

    Is there currently any easy way to implement either on a per-project basis?
     
  4. uy3d

    uy3d

    Unity Technologies

    Joined:
    Aug 16, 2016
    Posts:
    187
    You cannot directly influence the baking process. You could roll your own realtime shadow system to mix realtime and baked shadows, but I wouldn't call that easy.