Search Unity

Indoor/Outdoor transitions in a dynamic streaming world

Discussion in 'General Graphics' started by toxtronyx, Sep 14, 2016.

  1. toxtronyx


    Aug 21, 2014
    Hello folks!

    I ran into a problem causing some real nasty headaches and I am absolutely clueless how to get around this.
    Think of a streaming world divided into tiles and some sort of treadmill system to keep the distances low to avoid float point issues. Everything works as expected so far except one tiny little thing: Lighting. There are some seamless indoor/outdoor transitions in the game world named tunnels.
    As far as I understand lightprobes etc. don't work because nothing in this world is static as it needs to be moved by code when the player is too far away from the origin. Whats happening now is that the infinite light of course darkens stuff a bit by its shadow but the shadow distance is too short to cover the entire tunnels and the next thing is that the ambient light acts global so everything is fine at night, but far too bright at day. Last thing I should say: The system does not load/unload scenes but prefabs containing the data from the "work" scenes. This data is dynamically loaded/unloaded at runtime. So I have only one center place for the overall lighting.

    The only (not very cool) solution I came up with is a trigger based script dimming ambient and directional light down as soon as the player enters the tunnel. However this looks horrible when leaving the tunnel.

    Every tiny little idea is appreciated.

  2. Antony-Blackett


    Feb 15, 2011
    It's pretty hard to give you an answer as we don't know your code base and how your objects are setup in prefabs and how complex or malleable your content is. We also don't know what min spec hardware you're targeting and what your game performance is like.

    That said you just asked for ideas so here's a few:

    1) Cast a ray from your main outside light source (sun/moon) if there is 'ground' in the way then start to fade to tunnel lighting. You can fade to tunnel lighting over a set distance like 50 meters and measure that distance from the last point the ray from the main light source reached the player without being intercepted by a 'ground' object.

    1) User triggers in select special cases that are hard to make code for. This will reduce code complexity as well as reduce the amount of content maintenance.

    3) Increase your shadow distance (fixing the problem) and increase your shadow cascade count (maintaining good shadow resolution). This will be performance costly.

    4) Mark entrances/exits of tunnels with game objects (sounds like you already tried this) then blend the ambient light based on the distance to the closest tunnel exit rather than one the player has recently triggered by touching.

    5) Blend a colour for ambient light based on time of day, then add that to another colour that is based off inside and outside tunnels, set the added together colour as the ambient colour. When you enter/exit tunnels, blend your outside and tunnels colours up/down. This should give you seamless transitions from inside and outside no matter the time of day.

    All of these ideas could be considered a bit of a hack so maybe there is are better solutions, but remember that when making games you rarely want the perfect solution, just one that works well enough to enable the suspense of disbelief for your players while not costing you a house and/or your life in project development overruns.

    Hope those ideas help. Give some more details if you need more ideas for specific scenarios.
    theANMATOR2b likes this.
  3. toxtronyx


    Aug 21, 2014
    Thanks a lot for the suggestions! You pinned it with most of your concerns like performance etc. I like the Idea you mentioned in point 4 and 5. Blending the lighting by distance should give a decent effect and do the job. I give it a try.