Search Unity

Lightning inside moving car

Discussion in 'Global Illumination' started by MadAboutPandas3, Apr 16, 2019.

  1. MadAboutPandas3

    MadAboutPandas3

    Joined:
    Jul 3, 2017
    Posts:
    29
    Hello,

    I am doing a game where the camera in inside the car and want to calculate global illumination. For now realtime lightning is active and the material uses a occlusion map. The occlusion is now much noticeable but the realtime soft shadows look a bit hard. The good thing is that there is only one light source: the sun. The bad thing is that the car is moving along a spline and the sun comes roughly from the front, sometimes from left or right, but never from behind. There are no bridges or tunnels.

    Calculating light maps are to static. Is it possible to rotate the sun every few angles and calculate the lightmaps and blend the resulting maps together. I doubt if this would look good.

    I am not sure if light probes help me. Can I place a car every few meters and place light probes inside and then remove the cars? Would this work? It is 6000 meters road.

    Does anyone have another idea?

    Kind Regards,
    Chris
     
  2. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    Hey! If you need your lighting to change over time, then realtime GI would be the best bet. If the lighting in your scene remains static (your sun does not move), then mixed lighting setup could be a good alternative.

    It is not possible to bake lightmaps in runtime. You could write a custom shader and a custom script which does what you have in mind, but the results will not look good, and you will end up using a lot of memory to do so.

    If the shadows is your biggest concern, then you could consider disabling shadows for some of the car interior meshes. Also, you can tweak shadow bias, but you will inevitably run into scenarios where shadows will look disconnected from the mesh, or have severe shadow acne. In HDRP, there are several ways you can mitigate this - some of which don't exist in built-in RP.

    I would highly recommend reading our official realtime GI tutorial which will teach you all the fundamentals. You can access it here - https://unity3d.com/learn/tutorials...uction-precomputed-realtime-gi?playlist=17102
     
  3. KarolisO

    KarolisO

    Joined:
    Feb 2, 2014
    Posts:
    30
    Assuming you are aiming for photorealism, I'm afraid Unitys Built-in RP does not have a satisfying solution for your case.

    I'd recommend sticking with realtime lighting due to the scale of the scene. As an experiment try setting the car as static geometry, precomputing the realtime GI and then setting the car back to non-static.

    The scene might also benefit from contact shadows. You'll need a plugin for that (NGSS or Sonic Ethers one).

    Lastly, at 6 kilometers you might run into floating point precision coordinate issues and need to implement a floating origin.
     
    Last edited: Apr 19, 2019
    keeponshading likes this.
  4. MadAboutPandas3

    MadAboutPandas3

    Joined:
    Jul 3, 2017
    Posts:
    29
    Thanks for the answers!
    I will post some screenshots when it is done.