Beispiel #1
0
    /// <summary>
    /// Final Initilization and startup.
    /// </summary>
    private void Init()
    {
        if (profile == null)
        {
            return;
        }

        if (serverMode)
        {
            started = true;
            return;
        }

        InitImageEffects();

        // Setup Camera
        if (PlayerCamera != null)
        {
            if (setCameraClearFlags)
            {
                PlayerCamera.clearFlags = CameraClearFlags.Skybox;
            }

            // Workaround for deferred forve HDR...
            if (PlayerCamera.actualRenderingPath == RenderingPath.DeferredShading)
            {
                SetCameraHDR(PlayerCamera, true);
            }
            else
            {
                SetCameraHDR(PlayerCamera, HDR);
            }

            Components.GlobalReflectionProbe.myProbe.farClipPlane = PlayerCamera.farClipPlane;
        }

        started = true;

        //Render moon once always on start
        if (MoonShader != null)
        {
            MoonShader.SetFloat("_Phase", customMoonPhase);
            MoonShader.SetColor("_Color", skySettings.moonColor);
            MoonShader.SetFloat("_Brightness", skySettings.moonBrightness * (1 - GameTime.solarTime));
        }
    }
Beispiel #2
0
    private void SetMaterialsVariables()
    {
        //Simple
        skyMat.SetColor("_SkyColor", skySettings.simpleSkyColor.Evaluate(GameTime.solarTime));
        skyMat.SetColor("_HorizonColor", skySettings.simpleHorizonColor.Evaluate(GameTime.solarTime));
        skyMat.SetColor("_SunColor", skySettings.simpleSunColor.Evaluate(GameTime.solarTime));
        skyMat.SetFloat("_SunDiskSizeSimple", skySettings.simpleSunDiskSize.Evaluate(GameTime.solarTime));
        skyMat.SetFloat("_StarsIntensity", skySettings.starsIntensity.Evaluate(GameTime.solarTime));
        //Clouds
        skyMat.SetVector("_CloudAnimation", cirrusAnim);

        //cirrus
        if (cloudsSettings.cirrusCloudsTexture != null)
        {
            skyMat.SetTexture("_CloudMap", cloudsSettings.cirrusCloudsTexture);
        }

        skyMat.SetColor("_CloudColor", cloudsSettings.cirrusCloudsColor.Evaluate(GameTime.solarTime));
        skyMat.SetFloat("_CloudAltitude", cloudsSettings.cirrusCloudsAltitude);
        skyMat.SetFloat("_CloudAlpha", cloudsConfig.cirrusAlpha);
        skyMat.SetFloat("_CloudCoverage", cloudsConfig.cirrusCoverage);
        skyMat.SetFloat("_CloudColorPower", cloudsConfig.cirrusColorPow);

        //Globals
        Shader.SetGlobalVector("_SunDir", -Components.Sun.transform.forward);
        Shader.SetGlobalColor("_EnviroLighting", lightSettings.LightColor.Evaluate(GameTime.solarTime));
        // Moon
        Shader.SetGlobalVector("_SunPosition", Components.Sun.transform.localPosition + (-Components.Sun.transform.forward * 10000f));
        Shader.SetGlobalVector("_MoonPosition", Components.Moon.transform.localPosition);
        //Color Mods
        Shader.SetGlobalColor("_weatherSkyMod", Color.Lerp(currentWeatherSkyMod, interiorZoneSettings.currentInteriorSkyboxMod, interiorZoneSettings.currentInteriorSkyboxMod.a));
        Shader.SetGlobalColor("_weatherFogMod", Color.Lerp(currentWeatherFogMod, interiorZoneSettings.currentInteriorFogColorMod, interiorZoneSettings.currentInteriorFogColorMod.a));
        //Fog
        Shader.SetGlobalVector("_EnviroSkyFog", new Vector4(Fog.skyFogHeight, Fog.skyFogIntensity, Fog.skyFogStart, fogSettings.heightFogIntensity));

        Shader.SetGlobalFloat("_distanceFogIntensity", fogSettings.distanceFogIntensity);

        if (Application.isPlaying)
        {
            Shader.SetGlobalFloat("_maximumFogDensity", 1 - fogSettings.maximumFogDensity);
        }
        else
        {
            Shader.SetGlobalFloat("_maximumFogDensity", 1f);
        }

        if (fogSettings.useSimpleFog)
        {
            Shader.EnableKeyword("ENVIRO_SIMPLE_FOG");
            Shader.SetGlobalVector("_EnviroParams", new Vector4(Mathf.Clamp(1f - GameTime.solarTime, 0.5f, 1f), fogSettings.distanceFog ? 1f : 0f, 0f, HDR ? 1f : 0f));
        }
        else
        {
            Shader.SetGlobalColor("_scatteringColor", skySettings.scatteringColor.Evaluate(GameTime.solarTime));
            Shader.SetGlobalFloat("_scatteringStrenght", Fog.scatteringStrenght);
            Shader.SetGlobalFloat("_scatteringPower", skySettings.scatteringCurve.Evaluate(GameTime.solarTime));
            Shader.SetGlobalFloat("_SunBlocking", Fog.sunBlocking);
            Shader.SetGlobalVector("_EnviroParams", new Vector4(Mathf.Clamp(1f - GameTime.solarTime, 0.5f, 1f), fogSettings.distanceFog ? 1f : 0f, fogSettings.heightFog ? 1f : 0f, HDR ? 1f : 0f));
            Shader.SetGlobalVector("_Bm", BetaMie(skySettings.turbidity, skySettings.waveLength) * (skySettings.mie * (Fog.scatteringStrenght * GameTime.solarTime)));
            Shader.SetGlobalVector("_BmScene", BetaMie(skySettings.turbidity, skySettings.waveLength) * (fogSettings.mie * (Fog.scatteringStrenght * GameTime.solarTime)));
            Shader.SetGlobalVector("_Br", BetaRay(skySettings.waveLength) * skySettings.rayleigh);
            Shader.SetGlobalVector("_mieG", GetMieG(skySettings.g));
            Shader.SetGlobalVector("_mieGScene", GetMieGScene(skySettings.g));
            Shader.SetGlobalVector("_SunParameters", new Vector4(skySettings.sunIntensity, skySettings.sunDiskScale, skySettings.sunDiskIntensity, 0f));
            Shader.SetGlobalFloat("_Exposure", skySettings.skyExposure);
            Shader.SetGlobalFloat("_SkyLuminance", skySettings.skyLuminence.Evaluate(GameTime.solarTime));
            Shader.SetGlobalFloat("_SkyColorPower", skySettings.skyColorPower.Evaluate(GameTime.solarTime));
            Shader.SetGlobalFloat("_heightFogIntensity", fogSettings.heightFogIntensity);
            Shader.SetGlobalFloat("_lightning", thunder);
            Shader.DisableKeyword("ENVIRO_SIMPLE_FOG");
        }

        Shader.DisableKeyword("ENVIROVOLUMELIGHT");

        if (MoonShader != null)
        {
            MoonShader.SetFloat("_Phase", customMoonPhase);
            MoonShader.SetColor("_Color", skySettings.moonColor);
            MoonShader.SetFloat("_Brightness", skySettings.moonBrightness * (1 - GameTime.solarTime));
            MoonShader.SetFloat("_moonFogIntensity", Fog.moonIntensity);
        }
    }