Search Unity

Correct way of using static shadows?

Discussion in 'Getting Started' started by Neikke, Apr 29, 2019.

  1. Neikke

    Neikke

    Joined:
    Jun 23, 2017
    Posts:
    72
    Hi guys, I'm working on simple runner game for mobile platforms. And therefore, I would like to minimize realtime shadow casting as much as I can on objects that don't need it and don't move.

    Let's say I have 10 different platforms (some floating islands with trees and some non moving enemies on the ground). These platforms are being spawned outside of the screen and being moved in the direction of the Player which basically doesn't move at all - just jumping vertically to avoid obstacles / enemies on approaching platforms. So in fact my platforms DO move in the World, but there are a few objects inside of them that are non-moving relative to those platforms - like trees, houses etc and I would be happy to have their shadows present but not calculated each time an instance of this platform is being spawned.

    How should I approach it? How to make shadows on those platform instances not being calculated each time they respawn at runtime? Thanks in advance!
     
    Last edited: Apr 29, 2019
  2. Vefery

    Vefery

    Joined:
    Feb 23, 2018
    Posts:
    119
    If I'm not mistaking, there's no way to bake shadows relatively, Unity bakes shadows in world space.
    But you can try baking shadows in external program (for example in Blender), then exporting result as a texture map and pluging it into any material with "Lightmapped" shader. Since it's just a texture, I think it would behave like a texture