Best way to render fast day and night change scenes

Hi

Im working on project where we do nigh/day cycles - during 10-20 seconds for one day.
Can i use anyting but realtime lighting here? any mixed? and/or any use of light probes?

It is very low poly scene - with simple house and trees on a plane - but we need the lighting to be as realistic as possible.

We are using LWRP - are there any occlusion probes or similar that can work in LWRP?

Thanks a lot for any replies

It’s hard to know what is “best”, but I would probably approach this by doing the direct light in real-time and parameterizing the indirect lighting with spherical harmonics (i.e. basically a big light probe to approximate your sky). Bake out an indirect lightmap for each of the spherical harmonic coefficients. There are 9 so you baking will take some time, and you will end up with 3 maps (pack a different coefficient in each RGB channel), but that is the cost of partially pre-computing your dynamic lighting. To make it a bit easier you could write an editor script to automate the baking and merging; then just start it up and let it bake everything out.

At runtime, you can align a (disabled) white directional light to your sun direction and add it to a SphericalHarmonicsL2 object. That will calculate the weighting for each of the coefficients for you. Then, use a standard lit Shader Graph and multiplies out each lightmap, multiply it by your sunlight color, and just add it as emissive light to your output node.

If that’s too much texture memory for your application, you could use Valve’s 3 vector tangent basis instead (search for “Radiosity Normal Maps”). It uses only 3 coefficients for 3 different light directions so it can be packed into a single 3-channel lightmap, but it will give correspondingly less convincing results. Will be faster to bake out though.

If you parameterize your lighting in the lightmaps, you will need to do it for any light probes that you might want to use on dynamic objects too. Which means baking and saving out 9 different sets of light probes coefficients, and using the coefficient weights to set the actual values of your light probes every frame. That will be an extra cost if you need any dynamic objects in your scene to pick up the indirect lighting.

Here is a spherical harmonic skybox shader to get your started if you want to try baking out the different coefficients to see what they look like in your scene:

Shader "Skybox/Spherical Harmonic Skybox"
{
    Properties
    {
        _SHAr("Spherical Harmonics A Red", Color) = (1, 1, 1, 0)
        _SHAg("Spherical Harmonics A Green", Color) = (1, 1, 1, 0)
        _SHAb("Spherical Harmonics A Blue", Color) = (1, 1, 1, 0)
        _SHBr("Spherical Harmonics B Red", Color) = (1, 1, 1, 0)
        _SHBg("Spherical Harmonics B Green", Color) = (1, 1, 1, 0)
        _SHBb("Spherical Harmonics B Blue", Color) = (1, 1, 1, 0)
        _SHC("Spherical Harmonics C", Color) = (1, 1, 1, 0)
    }

        CGINCLUDE

#include "UnityCG.cginc"

        struct appdata
    {
        float4 position : POSITION;
        float3 texcoord : TEXCOORD0;
    };

    struct v2f
    {
        float4 position : SV_POSITION;
        float3 texcoord : TEXCOORD0;       
    };

    half4 _SHAr;
    half4 _SHAg;
    half4 _SHAb;
    half4 _SHBr;
    half4 _SHBg;
    half4 _SHBb;
    half4 _SHC;

    // normal should be normalized, w=1.0
    half3 SHEvalLinear(half4 normal)
    {
        half3 color;

        // Linear (L1) + constant (L0) polynomial terms
        color.r = dot(_SHAr, normal);
        color.g = dot(_SHAg, normal);
        color.b = dot(_SHAb, normal);

        // 4 of the quadratic (L2) polynomials
        half4 vB = normal.xyzz * normal.yzzx;
        color.r += dot(_SHBr, vB);
        color.g += dot(_SHBg, vB);
        color.b += dot(_SHBb, vB);

        // Final (5th) quadratic (L2) polynomial
        half vC = normal.x*normal.x - normal.y*normal.y;
        color += _SHC.rgb * vC;

        return color;
    }

    v2f vert(appdata v)
    {
        v2f o;
        o.position = UnityObjectToClipPos(v.position);
        o.texcoord = v.texcoord;
        return o;
    }

    half4 frag(v2f i) : COLOR
    {
        return half4(SHEvalLinear(float4(i.texcoord, 1)), 1);
    }

        ENDCG

        SubShader
    {
        Tags{ "RenderType" = "Background" "Queue" = "Background" }
            Pass
        {
            ZWrite Off
            Cull Off
            Fog{ Mode Off }
            CGPROGRAM
#pragma fragmentoption ARB_precision_hint_fastest
#pragma vertex vert
#pragma fragment frag
            ENDCG
        }
    }
}

And here is a useful light probe utility if you want to set your shader variables from a SphericalHarmonicsL2 object: