示例#1
0
    public IEnumerator BakingWithATrousFiltering_DoesNotFallback()
    {
        EditorSceneManager.OpenScene("Assets/Tests/Editor/Tests_Unit_Editmode/BakeATrous.unity", OpenSceneMode.Single);
        yield return(null);

        LightingSettings lightingSettings = null;

        Lightmapping.TryGetLightingSettings(out lightingSettings);

        Assert.That(lightingSettings, !Is.EqualTo(null), "LightingSettings is null");

        lightingSettings.lightmapper        = LightingSettings.Lightmapper.ProgressiveGPU;
        lightingSettings.mixedBakeMode      = MixedLightingMode.IndirectOnly;
        lightingSettings.directionalityMode = LightmapsMode.NonDirectional;

        // Activate A-Trous filtering
        lightingSettings.filterTypeIndirect = LightingSettings.FilterType.ATrous;

        Lightmapping.Clear();
        Lightmapping.Bake();

        // Check that we did not fallback to CPULM
        Assert.AreEqual(lightingSettings.lightmapper, LightingSettings.Lightmapper.ProgressiveGPU);

        Lightmapping.Clear();
        Lightmapping.ClearLightingDataAsset();
    }
    public IEnumerator TiledBaking_GPU_1k_lightmap_4_tiles()
    {
        EditorSceneManager.OpenScene(scenePath, OpenSceneMode.Single);
        yield return(null);

        LightingSettings lightingSettings = null;

        Lightmapping.TryGetLightingSettings(out lightingSettings);

        Assert.That(lightingSettings, !Is.EqualTo(null), "LightingSettings is null");

        lightingSettings.tiledBaking        = LightingSettings.TiledBaking.Quarter;
        lightingSettings.lightmapResolution = 100;
        lightingSettings.lightmapMaxSize    = 1024;

        Lightmapping.Clear();
        Lightmapping.Bake();

        LightmapConvergence lc = Lightmapping.GetLightmapConvergence(0);

        Assert.That(lc.GetTileCount(), Is.EqualTo(4), "Max tiling pass num should be 4");

        while (Lightmapping.isRunning)
        {
            yield return(null);
        }

        Lightmapping.Clear();
        Lightmapping.ClearLightingDataAsset();
    }
示例#3
0
    public void GPULM_BakeSceneWithOnlyBlackLight_DoesNotFallbackToCPU()
    {
        // Open the initial scene
        EditorSceneManager.OpenScene("Assets/Tests/Editor/Tests_Unit_Editmode/GPU-Rebake.unity");

        // Clear baked data and cache
        clearAll();

        // VerifySettings are correct
        SetupLightingSettings();

        // Get the settings to be able to check for a fallback to CPU
        LightingSettings lightingSettings = null;

        Lightmapping.TryGetLightingSettings(out lightingSettings);
        Assert.IsTrue(lightingSettings != null, "Lighting settings are available.");

        // Get the light
        Light light = GameObject.Find("Directional Light").GetComponent <Light>();

        Assert.IsNotNull(light);

        // Set the light color
        light.color = Color.black;

        // Bake the scene GI
        Lightmapping.Bake();

        Assert.IsTrue(lightingSettings.lightmapper == LightingSettings.Lightmapper.ProgressiveGPU, "Using GPU Lightmapper after initial bake.");

        clearAll();
    }
示例#4
0
 public bool TryGetScreenClearColor(ref Color color)
 {
     return(MaterialSettings.TryGetScreenClearColor(ref color) ||
            RenderingSettings.TryGetScreenClearColor(ref color) ||
            LightingSettings.TryGetScreenClearColor(ref color) ||
            ValidationSettings.TryGetScreenClearColor(ref color));
 }
    public IEnumerator TiledBaking_GPU_1k_lightmap_4_tiles_1_Empty_Tile()
    {
        EditorSceneManager.OpenScene("Assets/Tests/Editor/Tests_Unit_Editmode/ThreePlanes.unity", OpenSceneMode.Single);
        yield return(null);

        LightingSettings lightingSettings = null;

        Lightmapping.TryGetLightingSettings(out lightingSettings);

        Assert.That(lightingSettings, !Is.EqualTo(null), "LightingSettings is null");

        lightingSettings.tiledBaking = LightingSettings.TiledBaking.Quarter;

        Lightmapping.Clear();
        Lightmapping.Bake();

        LightmapConvergence lc = Lightmapping.GetLightmapConvergence(0);

        Assert.That(lc.GetTileCount(), Is.EqualTo(4), "Max tiling pass num should be 4");

        while (Lightmapping.isRunning)
        {
            yield return(null);
        }

        Lightmapping.Clear();
        Lightmapping.ClearLightingDataAsset();
    }
示例#6
0
        public SettingsViewModel(IScreen screen, ISettingsManager settingsManager, IVersionManager versionManager, IGameManager gameManager)
        {
            HostScreen       = screen;
            _settingsManager = settingsManager;
            _versionManager  = versionManager;
            _gameManager     = gameManager;

            ApiKey                      = _settingsManager.Settings.ApiKey;
            AuthUser                    = _settingsManager.Settings.AuthUser;
            AuthPass                    = _settingsManager.Settings.AuthPass;
            Endpoint                    = _settingsManager.Settings.Endpoint;
            PbxFolder                   = _settingsManager.Settings.PinballXFolder;
            SyncStarred                 = _settingsManager.Settings.SyncStarred;
            DownloadOnStartup           = _settingsManager.Settings.DownloadOnStartup;
            PatchTableScripts           = _settingsManager.Settings.PatchTableScripts;
            MinimizeToTray              = _settingsManager.Settings.MinimizeToTray;
            ReformatXml                 = _settingsManager.Settings.ReformatXml;
            XmlFileVP                   = _settingsManager.Settings.XmlFile[Platform.VP];
            StartWithWindows            = _settingsManager.Settings.StartWithWindows;
            DownloadOrientation         = _settingsManager.Settings.DownloadOrientation;
            DownloadOrientationFallback = _settingsManager.Settings.DownloadOrientationFallback;
            DownloadLighting            = _settingsManager.Settings.DownloadLighting;
            DownloadLightingFallback    = _settingsManager.Settings.DownloadLightingFallback;

            SaveSettings = ReactiveCommand.CreateFromTask(_ => Save());
            SaveSettings.IsExecuting.ToProperty(this, vm => vm.IsValidating, out _isValidating);
            SaveSettings.ThrownExceptions.Subscribe(e =>
            {
                // todo either remove or treat correctly.
                Console.WriteLine("Exception while saving settings.");
            });

            ChooseFolder  = ReactiveCommand.Create(OpenFolderDialog);
            CloseSettings = ReactiveCommand.CreateCombined(new[] { HostScreen.Router.NavigateBack });

            _settingsManager.WhenAnyValue(sm => sm.Settings.IsFirstRun).ToProperty(this, vm => vm.IsFirstRun, out _isFirstRun);
            _settingsManager.WhenAnyValue(sm => sm.CanCancel)
            .CombineLatest(screen.Router.NavigationStack.Changed, (canCancel, _) => canCancel || screen.Router.NavigationStack.Count > 1)
            .DistinctUntilChanged()
            .StartWith(true)
            .ToProperty(this, vm => vm.CanCancel, out _canCancel);

            OrientationSettings.Add(new OrientationSetting("Portrait", SettingsManager.Orientation.Portrait));
            OrientationSettings.Add(new OrientationSetting("Landscape", SettingsManager.Orientation.Landscape));
            OrientationSettings.Add(new OrientationSetting("Universal (VP10)", SettingsManager.Orientation.Universal));
            LightingSettings.Add(new LightingSetting("Day", SettingsManager.Lighting.Day));
            LightingSettings.Add(new LightingSetting("Night", SettingsManager.Lighting.Night));
            LightingSettings.Add(new LightingSetting("Universal (VP10)", SettingsManager.Lighting.Universal));
            XmlFilesVP.Add("Visual Pinball");
            XmlFilesVP.Add("Vpdb");
            OrientationFallbackSettings.Add(new OrientationSetting("Same *", SettingsManager.Orientation.Same));
            OrientationFallbackSettings.Add(new OrientationSetting("Portrait", SettingsManager.Orientation.Portrait));
            OrientationFallbackSettings.Add(new OrientationSetting("Landscape", SettingsManager.Orientation.Landscape));
            OrientationFallbackSettings.Add(new OrientationSetting("Any", SettingsManager.Orientation.Any));
            LightingFallbackSettings.Add(new LightingSetting("Same *", SettingsManager.Lighting.Same));
            LightingFallbackSettings.Add(new LightingSetting("Day", SettingsManager.Lighting.Day));
            LightingFallbackSettings.Add(new LightingSetting("Night", SettingsManager.Lighting.Night));
            LightingFallbackSettings.Add(new LightingSetting("Any", SettingsManager.Lighting.Any));
        }
示例#7
0
 public Preset(GlobalSettings global, CameraSettings camera, LightingSettings lights, PostProcessingSettings pp, SkyboxParams skybox)
 {
     this.camera = camera;
     this.global = global;
     this.lights = lights;
     this.pp     = pp;
     this.skybox = skybox;
 }
示例#8
0
 private static void StartLightmapping(LightingSettings settings)
 {
     GenerateLightmapUVs();
     Lightmapping.lightingSettings = settings;
     if (Lightmapping.BakeAsync())
     {
         SceneView.duringSceneGui += SceneView_duringSceneGui;
     }
 }
示例#9
0
    protected static void SetupLightingSettings()
    {
        LightingSettings lightingSettings = null;

        Lightmapping.TryGetLightingSettings(out lightingSettings);
        Assert.IsTrue(lightingSettings != null, "Lighting settings are available.");
        lightingSettings.lightmapper    = LightingSettings.Lightmapper.ProgressiveGPU;
        lightingSettings.prioritizeView = true;
        Assert.IsTrue(lightingSettings.lightmapper == LightingSettings.Lightmapper.ProgressiveGPU, "Using GPU Lightmapper.");
        Assert.IsTrue(lightingSettings.prioritizeView, "Using Progressive.");
    }
示例#10
0
        public Preset(GlobalSettings global, CameraSettings camera, LightingSettings lights, PostProcessingSettings pp, SkyboxParams skybox)
        {
            this.camera = camera;
            this.global = global;
            this.lights = lights;
            this.pp     = pp;
            this.skybox = skybox;

            // Skybox setting is generated when preset is being saved.
            skyboxSetting = null;
        }
示例#11
0
        private IEnumerator Start()
        {
            yield return(new WaitUntil(() =>
            {
                switch (KKAPI.KoikatuAPI.GetCurrentGameMode())
                {
                case KKAPI.GameMode.Maker:
                    return KKAPI.Maker.MakerAPI.InsideAndLoaded;

                case KKAPI.GameMode.Studio:
                    return KKAPI.Studio.StudioAPI.StudioLoaded;

                case KKAPI.GameMode.MainGame:
                    return null != GameObject.Find("MapScene") && SceneManager.GetActiveScene().isLoaded&& null != Camera.main;      //KKAPI doesn't provide an api for in game check

                default:
                    return false;
                }
            }));

            Settings               = new GlobalSettings();
            CameraSettings         = new CameraSettings();
            LightingSettings       = new LightingSettings();
            PostProcessingSettings = new PostProcessingSettings(CameraSettings.MainCamera);

            _skyboxManager           = Instance.GetOrAddComponent <SkyboxManager>();
            _skyboxManager.Parent    = this;
            _skyboxManager.AssetPath = ConfigCubeMapPath.Value;
            _skyboxManager.Logger    = Logger;
            DontDestroyOnLoad(_skyboxManager);

            _postProcessingManager        = Instance.GetOrAddComponent <PostProcessingManager>();
            _postProcessingManager.Parent = this;
            _postProcessingManager.LensDirtTexturesPath = ConfigLensDirtPath.Value;
            DontDestroyOnLoad(_postProcessingManager);

            _lightManager = new LightManager(this);

            _focusPuller = Instance.GetOrAddComponent <FocusPuller>();
            _focusPuller.init(this);
            DontDestroyOnLoad(_focusPuller);
            _presetManager = new PresetManager(ConfigPresetPath.Value, this);

            _inspector = new Inspector.Inspector(this);

            // It takes some time to fully loaded in studio to save/load stuffs.
            yield return(new WaitUntil(() =>
            {
                return (KoikatuAPI.GetCurrentGameMode() == GameMode.Studio) ? KKAPI.Studio.StudioAPI.InsideStudio && _skyboxManager != null : true;
            }));

            _isLoaded = true;
        }
    public IEnumerator ActivateDirectLighting_DuringABake_DoesNotFallback()
    {
        EditorSceneManager.OpenScene("Assets/Tests/Editor/Tests_Unit_Editmode/BakeRestartScene.unity", OpenSceneMode.Single);
        yield return(null);

        LightingSettings lightingSettings = null;

        Lightmapping.TryGetLightingSettings(out lightingSettings);

        Assert.That(lightingSettings, !Is.EqualTo(null), "LightingSettings is null");

        lightingSettings.lightmapper        = LightingSettings.Lightmapper.ProgressiveGPU;
        lightingSettings.mixedBakeMode      = MixedLightingMode.IndirectOnly;
        lightingSettings.directionalityMode = LightmapsMode.NonDirectional;

        GameObject dirLightGO = GameObject.FindGameObjectsWithTag("TheLight")[0];

        dirLightGO.SetActive(false);
        Light light = dirLightGO.GetComponent(typeof(Light)) as Light;

        light.lightmapBakeType = LightmapBakeType.Baked;

        Lightmapping.Clear();
        Lightmapping.BakeAsync();

        foreach (bool b in RunABake(0.2f))
        {
            yield return(null);
        }

        // Make sure it is still baking before we
        // switch the light on and restart the bake
        Assert.IsTrue(Lightmapping.isBaking);

        // Activate the light, cause the bake to restart
        dirLightGO.SetActive(true);

        foreach (bool b in RunABake(0.2f))
        {
            yield return(null);
        }

        // Check that baking is still running
        Assert.IsTrue(Lightmapping.isBaking);
        // Check that we did not fallback to CPULM
        Assert.AreEqual(lightingSettings.lightmapper, LightingSettings.Lightmapper.ProgressiveGPU);

        Lightmapping.Cancel();
        Lightmapping.Clear();
        Lightmapping.ClearLightingDataAsset();
    }
示例#13
0
 public void ApplyLightingSettings(LightingSettings settings, float duration = 0f)
 {
     if (settings.overrideFog)
     {
         fogColor.Set(settings.fogColor, duration);
         fogDensity.Set(settings.fogDensity, duration);
     }
     ApplyLightOnly(settings.light, duration);
     if (settings.overrideSkybox)
     {
         skybox.Set(settings.skyboxTexture, duration);
         skyColor.Set(settings.skyColor, duration);
     }
 }
示例#14
0
        private void LightSettings_OnLightingUpdated(LightingSettings sender)
        {
            if (sender == lightSettings)
            {
                if (light != null)
                {
                    //update light object
                    light.LocalPosition = new Vector3(lightSettings.Position.X, lightSettings.Position.Y, lightSettings.Position.Z);
                    light.Color         = new Vector3(lightSettings.Color.X, lightSettings.Color.Y, lightSettings.Color.Z);
                    light.Power         = lightSettings.Power;

                    Invalidate();
                }
            }
        }
示例#15
0
            public static LightingSettings ReadLightingSettings(this SCMap scMap)
            {
                LightingSettings lightingSettings = new LightingSettings();

                lightingSettings.bgTexturePath      = scMap.ReadString();
                lightingSettings.skyCubeMapPath     = scMap.ReadString();
                lightingSettings.envCubeMap         = scMap.ReadString();
                lightingSettings.lightingMultiplier = scMap.ReadFloat();
                lightingSettings.sunDirection       = scMap.ReadVector3();
                lightingSettings.sunAmbience        = scMap.ReadColorRGB();
                lightingSettings.sunColor           = scMap.ReadColorRGB();
                lightingSettings.shadowColor        = scMap.ReadColorRGB();
                lightingSettings.specularColor      = scMap.ReadColorRGBA();
                lightingSettings.bloom = scMap.ReadFloat();
                return(lightingSettings);
            }
    public IEnumerator Export_Training_Data_With_AO_And_Tiled_Baking_On()
    {
        EditorSceneManager.OpenScene("Assets/Tests/Editor/Tests_Unit_Editmode/ExtractTrainingDataScene.unity", OpenSceneMode.Single);
        yield return(null);

        LightingSettings lightingSettings = null;

        Lightmapping.TryGetLightingSettings(out lightingSettings);

        Assert.That(lightingSettings, !Is.EqualTo(null), "LightingSettings is null");

        lightingSettings.tiledBaking        = LightingSettings.TiledBaking.Quarter;
        lightingSettings.exportTrainingData = false;
        lightingSettings.ao = true;

        Lightmapping.Clear();
        Lightmapping.Bake();

        while (Lightmapping.isRunning)
        {
            yield return(null);
        }

        Assert.That(!System.IO.Directory.Exists("Assets/TrainingData/Lightmap-0"));
        Assert.That(!System.IO.File.Exists("Assets/TrainingData/Lightmap-0/indirect.exr"));

        Lightmapping.Clear();
        Lightmapping.ClearLightingDataAsset();
        lightingSettings.exportTrainingData = true;
        Lightmapping.Bake();

        while (Lightmapping.isRunning)
        {
            yield return(null);
        }

        Assert.That(System.IO.Directory.Exists("Assets/TrainingData/Lightmap-0"));
        Assert.That(System.IO.File.Exists("Assets/TrainingData/Lightmap-0/indirect.exr"));
        Assert.That(System.IO.File.Exists("Assets/TrainingData/Lightmap-0/ambient_occlusion.exr"));

        Lightmapping.Clear();
        Lightmapping.ClearLightingDataAsset();

        System.IO.Directory.Delete("Assets/TrainingData", true);
        Assert.That(!System.IO.Directory.Exists("Assets/TrainingData"));
    }
    public IEnumerator ActivateAO_DuringABake_DoesNotFallback()
    {
        EditorSceneManager.OpenScene("Assets/Tests/Editor/Tests_Unit_Editmode/BakeRestartScene.unity", OpenSceneMode.Single);
        yield return(null);

        LightingSettings lightingSettings = null;

        Lightmapping.TryGetLightingSettings(out lightingSettings);

        Assert.That(lightingSettings, !Is.EqualTo(null), "LightingSettings is null");

        lightingSettings.lightmapper = LightingSettings.Lightmapper.ProgressiveGPU;
        GameObject dirLightGO = GameObject.FindGameObjectsWithTag("TheLight")[0];

        dirLightGO.SetActive(false);
        lightingSettings.ao = false;

        Lightmapping.Clear();
        Lightmapping.BakeAsync();

        foreach (bool b in RunABake(0.2f))
        {
            yield return(null);
        }

        // Make sure it is still baking before we
        // switch the AO on and restart the bake
        Assert.IsTrue(Lightmapping.isBaking);

        // Switch AO on, cause the bake to restart
        lightingSettings.ao = true;

        foreach (bool b in RunABake(0.2f))
        {
            yield return(null);
        }

        // Check that baking is still running
        Assert.IsTrue(Lightmapping.isBaking);
        // Check that we did not fallback to CPULM
        Assert.AreEqual(lightingSettings.lightmapper, LightingSettings.Lightmapper.ProgressiveGPU);

        Lightmapping.Cancel();
        Lightmapping.Clear();
        Lightmapping.ClearLightingDataAsset();
    }
示例#18
0
    public void CheckAllLightingSettings()
    {
        var guids = AssetDatabase.FindAssets("t:LightingSettings");

        foreach (var guid in guids)
        {
            string           path             = AssetDatabase.GUIDToAssetPath(guid);
            LightingSettings lightingSettings = AssetDatabase.LoadAssetAtPath <LightingSettings>(path);
            if (lightingSettings.bakedGI)
            {
                Assert.IsTrue(lightingSettings.lightmapper != LightingSettings.Lightmapper.Enlighten,
                              $"Lighting settings ({path}) uses deprecated lightmapper Enlighten.");
                Assert.IsTrue(lightingSettings.filteringMode == LightingSettings.FilterMode.None,
                              $"Lighting settings ({path}) have baked GI with filter mode enabled. It is recommended to turn of filter mode to reduce halo effect (If you still want to use it please contact URP team first).");
            }
        }
    }
示例#19
0
        public UI3DPreview()
        {
            HdriManager.Scan();
            HdriManager.OnHdriLoaded += HdriManager_OnHdriLoaded;
            InitializeComponent();
            previewRenderMode = PreviewRenderMode.FullShading;
            Instance          = this;

            materialSettings = new MaterialSettings();
            materialSettings.Load();
            materialSettings.OnMaterialUpdated += MaterialSettings_OnMaterialUpdated;

            lightSettings = new LightingSettings();
            lightSettings.OnLightingUpdated += LightSettings_OnLightingUpdated;

            InitGL();
            Log.Info("3d view inited");
        }
示例#20
0
        private IEnumerator Start()
        {
            if (IsStudio())
            {
                StudioHooks.Init();
            }
            yield return(new WaitUntil(() =>
            {
                return IsLoaded();
            }));

            Settings               = new GlobalSettings();
            CameraSettings         = new CameraSettings();
            LightingSettings       = new LightingSettings();
            PostProcessingSettings = new PostProcessingSettings(CameraSettings.MainCamera);
            SSSSettings            = new SSSSettings();

            _sssManager = new SSSManager();
            _sssManager.Initialize();

            _skyboxManager           = Instance.GetOrAddComponent <SkyboxManager>();
            _skyboxManager.Parent    = this;
            _skyboxManager.AssetPath = ConfigCubeMapPath.Value;
            _skyboxManager.Logger    = Logger;
            DontDestroyOnLoad(_skyboxManager);

            _postProcessingManager        = Instance.GetOrAddComponent <PostProcessingManager>();
            _postProcessingManager.Parent = this;
            _postProcessingManager.LensDirtTexturesPath = ConfigLensDirtPath.Value;
            DontDestroyOnLoad(_postProcessingManager);

            LocalizationManager.Parent          = this;
            LocalizationManager.CurrentLanguage = ConfigLanguage.Value;

            _lightManager  = new LightManager(this);
            _presetManager = new PresetManager(ConfigPresetPath.Value, this);

            yield return(new WaitUntil(() => PCSSLight.LoadAssets()));

            yield return(new WaitUntil(() => SEGI.LoadAssets()));

            _inspector = new Inspector.Inspector(this);
            _isLoaded  = true;
        }
    public IEnumerator Extract_AO_With_Tiled_Baking_On()
    {
        EditorSceneManager.OpenScene("Assets/Tests/Editor/Tests_Unit_Editmode/AOTestScene.unity", OpenSceneMode.Single);
        yield return(null);

        LightingSettings lightingSettings = null;

        Lightmapping.TryGetLightingSettings(out lightingSettings);

        Assert.That(lightingSettings, !Is.EqualTo(null), "LightingSettings is null");

        lightingSettings.tiledBaking = LightingSettings.TiledBaking.Quarter;
        lightingSettings.extractAO   = false;

        Lightmapping.Clear();
        Lightmapping.Bake();

        while (Lightmapping.isRunning)
        {
            yield return(null);
        }
        Assert.That(!System.IO.File.Exists("Assets/Tests/Editor/Tests_Unit_Editmode/AOTestScene/Lightmap-0_ao.exr"));

        Lightmapping.Clear();
        Lightmapping.ClearLightingDataAsset();
        lightingSettings.extractAO = true;
        Lightmapping.Bake();

        while (Lightmapping.isRunning)
        {
            yield return(null);
        }

        Assert.That(System.IO.File.Exists("Assets/Tests/Editor/Tests_Unit_Editmode/AOTestScene/Lightmap-0_ao.exr"));

        Lightmapping.Clear();
        Lightmapping.ClearLightingDataAsset();
    }
示例#22
0
    public static void AllLightingSettingsHaveNoBakedGI(string projectName, List <string> excludePaths = null)
    {
        var guids = AssetDatabase.FindAssets("t:LightingSettings");

        foreach (var guid in guids)
        {
            var path = AssetDatabase.GUIDToAssetPath(guid);

            // We only care what is in assets folder
            if (!path.StartsWith("Assets"))
            {
                continue;
            }

            if (excludePaths != null && excludePaths.Contains(path))
            {
                continue;
            }

            LightingSettings lightingSettings = AssetDatabase.LoadAssetAtPath <LightingSettings>(path);
            Assert.IsFalse(lightingSettings.bakedGI, $"Lighting Setting ({path}) has baked GI enabled. {projectName} project should not have baked GI");
        }
    }
示例#23
0
    public bool ParseSCMapFile(string filePath = "")
    {
        if (filePath != "")
        {
            OpenSCMap(filePath);
        }

        fs = scMapFile.Open(FileMode.Open, FileAccess.Read);

        header = this.ReadMapHeader();

        terrain = this.ReadSCTearrain();

        lightingSettings = this.ReadLightingSettings();

        fogSettings = this.ReadFogSettings();

        waterSettings = this.ReadWaterSettings();

        float_8          = this.ReadFloats(20);
        waterTexture     = this.ReadString();
        waterTextureRamp = this.ReadString();
        float_9          = this.ReadFloats(4);

        //Read Waves
        for (int i = 0; i < 4; i++)
        {
            Wave wave = this.ReadWave();
            waves.Add(wave);
        }

        //Read GClass0
        int gClass0Count = this.ReadInt();

        for (int i = 0; i < gClass0Count; i++)
        {
            GClass0 tmpGClass0 = this.ReadGClass0();
            gClass0.Add(tmpGClass0);
        }
        hasGClass0 = !waterSettings.hasWater || gClass0Count > 0;


        unk0 = this.ReadString();

        //Read GClass69
        int gClass69Count = this.ReadInt();

        for (int i = 0; i < gClass69Count; i++)
        {
            Layer tmpLayer = this.ReadGClass69();
            layers.Add(tmpLayer);
        }


        int_9  = this.ReadInt();
        int_10 = this.ReadInt();


        //Read gClass1
        int gClass1Count = this.ReadInt();

        for (int i = 0; i < gClass1Count; i++)
        {
            GClass1 gClass1 = this.ReadDecal();
            gClass1s.Add(gClass1);
        }

        //Read GClass70

        int gClass70Count = this.ReadInt();

        for (int i = 0; i < gClass70Count; i++)
        {
            GClass70 gClass70 = this.ReadGClass70();
            gClass70s.Add(gClass70);
        }

        unk1 = this.ReadInt();
        unk2 = this.ReadInt();

        //Read UnknowArray

        count3 = this.ReadInt();
        int lenght3 = this.ReadInt();

        numArray3 = this.ReadBytes(lenght3);// texture terrain colors?
        for (int i = 1; i < count3; i++)
        {
            lenght3 = this.ReadInt();
            this.SkipBytes(lenght3);
        }

        unk3 = this.ReadInt();

        int lenght2 = this.ReadInt();

        numArray2 = this.ReadBytes(lenght2);// texture?

        unk4 = this.ReadInt();

        toSkip0 = this.ReadInt();
        this.SkipBytes(toSkip0);

        toSkip1 = Mathf.RoundToInt(terrain.size.x / 2 * terrain.size.y / 2);
        this.SkipBytes(toSkip1);
        this.SkipBytes(toSkip1);
        this.SkipBytes(toSkip1);

        byte_0 = this.ReadBytes((int)(terrain.size.x * terrain.size.y));

        if (header.version <= 52)
        {
            unk5 = this.ReadShort();
        }

        //Read Prop

        int propCount = this.ReadInt();

        for (int i = 0; i < propCount; i++)
        {
            Prop prop = this.ReadProp();
            props.Add(prop);
        }

        fs.Close();

        return(true);
    }
示例#24
0
        internal static void DrawDynSkyboxOptions(LightingSettings lightingSettings, SkyboxManager skyboxManager, bool showAdvanced)
        {
            if (skyboxManager != null && skyboxManager.Skybox != null)
            {
                GUILayout.Space(10);

                GUILayout.BeginVertical(GUIStyles.Skin.box);
                dynSkyScrollView = GUILayout.BeginScrollView(dynSkyScrollView);
                {
                    Material mat = skyboxManager.Skybox;

                    if (mat.shader.name == ProceduralSkyboxSettings.shaderName)
                    {
                        Label("Unity Skybox Settings", "", true);

                        Selection("Sun", (ProceduralSkyboxSettings.SunDisk)mat.GetInt("_SunDisk"), quality =>
                        {
                            mat.SetInt("_SunDisk", (int)quality);
                            skyboxManager.Update = true;
                        });
                        Slider("Sun Size", mat.GetFloat("_SunSize"), 0, 1, "N2", value =>
                        {
                            mat.SetFloat("_SunSize", value);
                            skyboxManager.Update = true;
                        });
                        Slider("Sun Size Convergence", mat.GetFloat("_SunSizeConvergence"), 1, 10, "N2", value =>
                        {
                            mat.SetFloat("_SunSizeConvergence", value);
                            skyboxManager.Update = true;
                        });
                        Slider("Atmosphere Thickness", mat.GetFloat("_AtmosphereThickness"), 0, 5, "N2", value =>
                        {
                            mat.SetFloat("_AtmosphereThickness", value);
                            skyboxManager.Update = true;
                        });
                        SliderColor("Sky Tint", mat.GetColor("_SkyTint"), c =>
                        {
                            mat.SetColor("_SkyTint", c);
                            skyboxManager.Update = true;
                        }, true);
                        SliderColor("Ground Color", mat.GetColor("_GroundColor"), c =>
                        {
                            mat.SetColor("_GroundColor", c);
                            skyboxManager.Update = true;
                        }, true);
                        Slider("Exposure", mat.GetFloat("_Exposure"), 0, 8, "N2", value =>
                        {
                            mat.SetFloat("_Exposure", value);
                            skyboxManager.Update = true;
                        });
                    }
                    else if (mat.shader.name == TwoPointColorSkyboxSettings.shaderName)
                    {
                        Label("Two Point Color Skybox Settings", "", true);
                        SliderColor("Colour A", mat.GetColor("_ColorA"), c =>
                        {
                            mat.SetColor("_ColorA", c);
                            skyboxManager.Update = true;
                        }, true);
                        Slider("Intensity A", mat.GetFloat("_IntensityA"), 0, 2, "N2", intensity =>
                        {
                            mat.SetFloat("_IntensityA", intensity);
                            skyboxManager.Update = true;
                        });
                        Dimension("Box Size", mat.GetVector("_DirA"), direction =>
                        {
                            mat.SetVector("_DirA", direction);
                            skyboxManager.Update = true;
                        });
                        SliderColor("Colour B", mat.GetColor("_ColorB"), c =>
                        {
                            mat.SetColor("_ColorB", c);
                            skyboxManager.Update = true;
                        }, true);
                        Slider("Intensity B", mat.GetFloat("_IntensityB"), 0, 2, "N2", intensity =>
                        {
                            mat.SetFloat("_IntensityB", intensity);
                            skyboxManager.Update = true;
                        });
                        Dimension("Box Size", mat.GetVector("_DirB"), direction =>
                        {
                            mat.SetVector("_DirB", direction);
                            skyboxManager.Update = true;
                        });
                    }
                    else if (mat.shader.name == HemisphereGradientSkyboxSetting.shaderName)
                    {
                        Label("Hemisphere Skybox Settings", "", true);
                        SliderColor("North Pole", mat.GetColor("_TopColor"), c =>
                        {
                            mat.SetColor("_TopColor", c);
                            skyboxManager.Update = true;
                        }, true);
                        SliderColor("Equator", mat.GetColor("_MiddleColor"), c =>
                        {
                            mat.SetColor("_MiddleColor", c);
                            skyboxManager.Update = true;
                        }, true);
                        SliderColor("South Pole", mat.GetColor("_BottomColor"), c =>
                        {
                            mat.SetColor("_BottomColor", c);
                            skyboxManager.Update = true;
                        }, true);
                    }
                    else if (mat.shader.name == FourPointGradientSkyboxSetting.shaderName)
                    {
                        Label("Four Point Gradient Skybox Settings", "", true);
                        SliderColor("Base Color", mat.GetColor("_BaseColor"), c =>
                        {
                            mat.SetColor("_BaseColor", c);
                            skyboxManager.Update = true;
                        }, true);
                        for (int i = 1; i <= 4; i++)
                        {
                            // Switch is compile time property.
                            SliderColor("Color " + i, mat.GetColor("_Color" + i), c =>
                            {
                                mat.SetColor("_Color" + i, c);
                                skyboxManager.Update = true;
                            }, true);
                            Dimension("Direction " + i, mat.GetVector("_Direction" + i), direction =>
                            {
                                mat.SetVector("_Direction" + i, direction);
                                skyboxManager.Update = true;
                            });
                            Slider("Exponent " + i, mat.GetFloat("_Exponent" + i), 0, 2, "N1", intensity =>
                            {
                                mat.SetFloat("_Exponent" + i, intensity);
                                skyboxManager.Update = true;
                            });
                        }
                    }
                }
                GUILayout.EndScrollView();
                GUILayout.EndVertical();
            }
        }
示例#25
0
        internal static void Draw(LightingSettings lightingSettings, SkyboxManager skyboxManager, bool showAdvanced)
        {
            GUILayout.BeginVertical(GUIStyles.Skin.box);
            {
                Label("Environment Skybox", "", true);
                GUILayout.Space(1);
                //inactivate controls if no cubemap
                if (skyboxManager.TexturePaths.IsNullOrEmpty())
                {
                    Label("No custom cubemaps found", "");
                }
                else
                {
                    cubeMapScrollView = GUILayout.BeginScrollView(cubeMapScrollView, GUILayout.MaxHeight(300));
                    int selectedCubeMapIdx = GUILayout.SelectionGrid(skyboxManager.CurrentTextureIndex, skyboxManager.Previews.ToArray(), Inspector.Width / 150, GUIStyles.Skin.box);
                    if (-1 != selectedCubeMapIdx)
                    {
                        skyboxManager.CurrentTexturePath = skyboxManager.TexturePaths[selectedCubeMapIdx];
                    }

                    GUILayout.EndScrollView();
                }
                DrawDynSkyboxOptions(lightingSettings, skyboxManager, showAdvanced);
                GUILayout.Space(10);
                if (showAdvanced)
                {
                    Label("Skybox Material", lightingSettings?.SkyboxSetting?.name ?? "");
                    Label("Sun Source", lightingSettings?.SunSetting?.name ?? "");
                    GUILayout.Space(10);
                }
                Label("Environment Lighting", "", true);
                GUILayout.Space(1);
                Selection("Source", lightingSettings.AmbientModeSetting, mode =>
                {
                    lightingSettings.AmbientModeSetting = mode;
                    if (mode != LightingSettings.AIAmbientMode.Skybox)
                    {
                        skyboxManager.CurrentTexturePath = SkyboxManager.noCubemap;
                    }
                });
                Slider("Intensity", lightingSettings.AmbientIntensity, LightSettings.IntensityMin, LightSettings.IntensityMax, "N1", intensity => { lightingSettings.AmbientIntensity = intensity; });
                if (null != skyboxManager.Skybox && null != skyboxManager.Skyboxbg)
                {
                    Material skybox = skyboxManager.Skybox;
                    if (skybox.HasProperty("_Exposure"))
                    {
                        Slider("Exposure", skyboxManager.Exposure, ExposureMin, ExposureMax, "N1", exp => { skyboxManager.Exposure = exp; skyboxManager.Update = true; });
                    }
                    if (skybox.HasProperty("_Rotation"))
                    {
                        Slider("Rotation", skyboxManager.Rotation, RotationMin, RotationMax, "N1", rot => { skyboxManager.Rotation = rot; skyboxManager.Update = true; });
                    }
                    GUILayout.Space(10);
                    if (skybox.HasProperty("_Tint"))
                    {
                        SliderColor("Skybox Tint", skyboxManager.Tint, c => { skyboxManager.Tint = c; skyboxManager.Update = true; }, true);
                    }
                }
                GUILayout.Space(10);
                Label("Environment Reflections", "", true);
                GUILayout.Space(1);
                Selection("Resolution", lightingSettings.ReflectionResolution, LightingSettings.ReflectionResolutions, resolution => lightingSettings.ReflectionResolution = resolution);
                Slider("Intensity", lightingSettings.ReflectionIntensity, 0f, 1f, "N1", intensity => { lightingSettings.ReflectionIntensity = intensity; });
                Slider("Bounces", lightingSettings.ReflectionBounces, 1, 5, bounces => { lightingSettings.ReflectionBounces = bounces; });
            }
            GUILayout.EndVertical();
            GUILayout.Space(1);
            GUILayout.BeginVertical(GUIStyles.Skin.box);
            {
                Label("Reflection Probes", "", true);
                ReflectionProbe[] rps = skyboxManager.GetReflectinProbes();
                if (0 < rps.Length)
                {
                    string[] probeNames = rps.Select(probe => probe.name).ToArray();
                    selectedProbe = GUILayout.SelectionGrid(selectedProbe, probeNames, 3, GUIStyles.toolbarbutton);
                    ReflectionProbe rp = rps[selectedProbe];
                    GUILayout.Space(1);
                    GUILayout.BeginVertical(GUIStyles.Skin.box);
                    probeSettingsScrollView = GUILayout.BeginScrollView(probeSettingsScrollView);
                    {
                        Label("Type", rp.mode.ToString());
                        Label("Runtime settings", "");
                        Slider("Importance", rp.importance, 0, 1000, importance => rp.importance = importance);
                        Slider("Intensity", rp.intensity, 0, 10, "N2", intensity => rp.intensity = intensity);
                        rp.boxProjection = Toggle("Box Projection", rp.boxProjection);
                        rp.blendDistance = Text("Blend Distance", rp.blendDistance);
                        Dimension("Box Size", rp.size, size => rp.size       = size);
                        Dimension("Box Offset", rp.center, size => rp.center = size);
                        GUILayout.Space(10);
                        Label("Cubemap capture settings", "");
                        Selection("Resolution", rp.resolution, LightingSettings.ReflectionResolutions, resolution => rp.resolution = resolution);
                        rp.hdr            = Toggle("HDR", rp.hdr);
                        rp.shadowDistance = Text("Shadow Distance", rp.shadowDistance);
                        Selection("Clear Flags", rp.clearFlags, flag => rp.clearFlags = flag);
                        if (showAdvanced)
                        {
                            SelectionMask("Culling Mask", rp.cullingMask, mask => rp.cullingMask = mask);
                        }
                        rp.nearClipPlane = Text("Clipping Planes - Near", rp.nearClipPlane, "N2");
                        rp.farClipPlane  = Text("Clipping Planes - Far", rp.farClipPlane, "N2");
                        SliderColor("Background", rp.backgroundColor, colour => { rp.backgroundColor = colour; });
                        Selection("Time Slicing Mode", rp.timeSlicingMode, mode => rp.timeSlicingMode = mode);
                    }
                    GUILayout.EndScrollView();
                    GUILayout.EndVertical();
                }
            }
            GUILayout.EndVertical();
        }
示例#26
0
    public void RefProbeAPI(string settings, BakeAPI bakeAPI)
    {
        EditorSceneManager.OpenScene(sceneFileName, OpenSceneMode.Single);

        // Bake with a lighting settings asset.
        string[] settingsAssets = AssetDatabase.FindAssets(settings + " t:lightingsettings", foldersToLookIn);
        Debug.Log("Found " + settingsAssets.Length + " matching lighting settings assets in " + foldersToLookIn[0]);
        Assert.That(settingsAssets.Length, Is.EqualTo(1));
        string lsaPath = AssetDatabase.GUIDToAssetPath(settingsAssets[0]);

        Debug.Log("Loading " + lsaPath);
        LightingSettings lightingSettings = (LightingSettings)AssetDatabase.LoadAssetAtPath(lsaPath, typeof(LightingSettings));

        Lightmapping.lightingSettings = lightingSettings;
        string fileName = System.IO.Path.GetFileNameWithoutExtension(lsaPath);

        Assert.That(fileName, Is.EqualTo(settings));
        Lightmapping.Clear();
        // The disk cache needs clearing between runs because we are only changing the API and not necessarily the settings.
        // Changing the API use to bake the probe is assumed to not affect the result so the reflection probe is fetched from the disk cache.
        // To detect that everything works as intended the cached reflection probe needs to be cleared.
        Lightmapping.ClearDiskCache();
        Debug.Log("Baking " + fileName);
        bool result = true;

        switch (bakeAPI)
        {
        case BakeAPI.Bake:
            result = Lightmapping.Bake();
            break;

        case BakeAPI.BakeAll:
        {
            var probe = Object.FindObjectOfType <ReflectionProbe>();
            Assert.That(probe, !Is.EqualTo(null), "Couldn't find ReflectionProbe");
            Debug.Log("Found reflection probe: " + probe.name);

            var oldEnabledValue = probe.enabled;
            probe.enabled = false;
            result        = Lightmapping.Bake();
            probe.enabled = oldEnabledValue;
            result       &= Lightmapping.BakeAllReflectionProbesSnapshots();
        }
        break;

        case BakeAPI.BakeSingle:
        {
            var probe = Object.FindObjectOfType <ReflectionProbe>();
            Assert.That(probe, !Is.EqualTo(null), "Couldn't find ReflectionProbe");
            Debug.Log("Found reflection probe: " + probe.name);

            var oldEnabledValue = probe.enabled;
            probe.enabled = false;
            result        = Lightmapping.Bake();
            probe.enabled = oldEnabledValue;
            result       &= Lightmapping.BakeReflectionProbeSnapshot(probe);
        }
        break;
        }
        Assert.That(result, Is.True);

        // Get Test settings.
        var graphicsTestSettingsCustom = Object.FindObjectOfType <UniversalGraphicsTestSettings>();

        Assert.That(graphicsTestSettingsCustom, !Is.EqualTo(null), "Couldn't find GraphicsTestSettingsCustom");

        // Load reference image.
        var referenceImagePath = System.IO.Path.Combine("Assets/ReferenceImages", string.Format("{0}/{1}/{2}/{3}/{4}",
                                                                                                UseGraphicsTestCasesAttribute.ColorSpace,
                                                                                                UseGraphicsTestCasesAttribute.Platform,
                                                                                                UseGraphicsTestCasesAttribute.GraphicsDevice,
                                                                                                UseGraphicsTestCasesAttribute.LoadedXRDevice,
                                                                                                "RefProbeAPI_" + settings + "-" + bakeAPI.ToString() + "_.png"));

        Debug.Log("referenceImagePath " + referenceImagePath);
        var referenceImage = AssetDatabase.LoadAssetAtPath <Texture2D>(referenceImagePath);

        // Compare screenshots.
        GraphicsTestCase testCase = new GraphicsTestCase(settings, referenceImage);
        var cameras = GameObject.FindGameObjectsWithTag("MainCamera").Select(x => x.GetComponent <Camera>());

        ImageAssert.AreEqual(testCase.ReferenceImage, cameras.Where(x => x != null), graphicsTestSettingsCustom.ImageComparisonSettings);
        UnityEditor.TestTools.Graphics.ResultsUtility.ExtractImagesFromTestProperties(TestContext.CurrentContext.Test);
    }
示例#27
0
        internal static void Draw(LightingSettings lightingSettings, SkyboxManager skyboxManager, bool showAdvanced)
        {
            GUILayout.BeginVertical(GUIStyles.Skin.box);
            {
                Label("Environment Skybox", "", true);
                GUILayout.Space(1);
                //inactivate controls if no cubemap
                if (skyboxManager.TexturePaths.IsNullOrEmpty())
                {
                    Label("No custom cubemaps found", "");
                }
                else
                {
                    cubeMapScrollView = GUILayout.BeginScrollView(cubeMapScrollView, GUILayout.MaxHeight(300));
                    int selectedCubeMapIdx = GUILayout.SelectionGrid(skyboxManager.CurrentTextureIndex, skyboxManager.Previews.ToArray(), Inspector.Width / 150, GUIStyles.Skin.box);
                    if (-1 != selectedCubeMapIdx)
                    {
                        skyboxManager.CurrentTexturePath = skyboxManager.TexturePaths[selectedCubeMapIdx];
                    }

                    GUILayout.EndScrollView();
                }
                DrawDynSkyboxOptions(lightingSettings, skyboxManager, showAdvanced);
                GUILayout.Space(10);
                if (showAdvanced)
                {
                    Label("Skybox Material", lightingSettings?.SkyboxSetting?.name ?? "");
                    Label("Sun Source", lightingSettings?.SunSetting?.name ?? "");
                    GUILayout.Space(10);
                }
                Label("Environment Lighting", "", true);
                GUILayout.Space(1);
                Selection("Source", lightingSettings.AmbientModeSetting, mode =>
                {
                    lightingSettings.AmbientModeSetting = mode;
                    if (mode != LightingSettings.AIAmbientMode.Skybox)
                    {
                        skyboxManager.CurrentTexturePath = SkyboxManager.noCubemap;
                    }
                });
                Slider("Intensity", lightingSettings.AmbientIntensity, LightSettings.IntensityMin, LightSettings.IntensityMax, "N1", intensity => { lightingSettings.AmbientIntensity = intensity; });
                if (null != skyboxManager.Skybox && null != skyboxManager.Skyboxbg)
                {
                    Material skybox = skyboxManager.Skybox;
                    if (skybox.HasProperty("_Exposure"))
                    {
                        Slider("Exposure", skyboxManager.Exposure, ExposureMin, ExposureMax, "N1", exp => { skyboxManager.Exposure = exp; skyboxManager.Update = true; });
                    }
                    if (skybox.HasProperty("_Rotation"))
                    {
                        Slider("Rotation", skyboxManager.Rotation, RotationMin, RotationMax, "N1", rot => { skyboxManager.Rotation = rot; skyboxManager.Update = true; });
                    }
                    GUILayout.Space(10);
                    if (skybox.HasProperty("_Tint"))
                    {
                        SliderColor("Skybox Tint", skyboxManager.Tint, c => { skyboxManager.Tint = c; skyboxManager.Update = true; }, true);
                    }
                }
                GUILayout.Space(10);
                Label("Environment Reflections", "", true);
                GUILayout.Space(1);
                Selection("Resolution", lightingSettings.ReflectionResolution, LightingSettings.ReflectionResolutions, resolution => lightingSettings.ReflectionResolution = resolution);
                Slider("Intensity", lightingSettings.ReflectionIntensity, 0f, 1f, "N1", intensity => { lightingSettings.ReflectionIntensity = intensity; });
                Slider("Bounces", lightingSettings.ReflectionBounces, 1, 5, bounces => { lightingSettings.ReflectionBounces = bounces; });
            }
            GUILayout.EndVertical();
            GUILayout.Space(1);
            GUILayout.BeginVertical(GUIStyles.Skin.box);
            {
                Toggle("Reflection Probes", inspectReflectionProbes, true, inspect => inspectReflectionProbes = inspect);
                if (inspectReflectionProbes)
                {
                    ReflectionProbe[] rps = skyboxManager.GetReflectinProbes();
                    if (0 < rps.Length)
                    {
                        string[] probeNames = rps.Select(probe => probe.name).ToArray();
                        selectedProbe = GUILayout.SelectionGrid(selectedProbe, probeNames, 3, GUIStyles.toolbarbutton);
                        ReflectionProbe rp = rps[selectedProbe];
                        GUILayout.Space(1);
                        GUILayout.BeginVertical(GUIStyles.Skin.box);
                        probeSettingsScrollView = GUILayout.BeginScrollView(probeSettingsScrollView);
                        {
                            Label("Type", rp.mode.ToString());
                            Label("Runtime settings", "");
                            Slider("Importance", rp.importance, 0, 1000, importance => rp.importance    = importance);
                            Slider("Intensity", rp.intensity, 0, 10, "N2", intensity => rp.intensity    = intensity);
                            Toggle("Box Projection", rp.boxProjection, false, box => rp.boxProjection   = box);
                            Text("Blend Distance", rp.blendDistance, "N2", distance => rp.blendDistance = distance);
                            Dimension("Box Size", rp.size, size => rp.size       = size);
                            Dimension("Box Offset", rp.center, size => rp.center = size);
                            GUILayout.Space(10);
                            Label("Cubemap capture settings", "");
                            Selection("Resolution", rp.resolution, LightingSettings.ReflectionResolutions, resolution => rp.resolution = resolution);
                            Toggle("HDR", rp.hdr, false, hdr => rp.hdr = hdr);
                            Text("Shadow Distance", rp.shadowDistance, "N2", distance => rp.shadowDistance = distance);
                            Selection("Clear Flags", rp.clearFlags, flag => rp.clearFlags = flag);
                            if (showAdvanced)
                            {
                                SelectionMask("Culling Mask", rp.cullingMask, mask => rp.cullingMask = mask);
                            }
                            Text("Clipping Planes - Near", rp.nearClipPlane, "N2", plane => rp.nearClipPlane = plane);
                            Text("Clipping Planes - Far", rp.farClipPlane, "N2", plane => rp.farClipPlane    = plane);
                            SliderColor("Background", rp.backgroundColor, colour => { rp.backgroundColor = colour; });
                            Selection("Time Slicing Mode", rp.timeSlicingMode, mode => rp.timeSlicingMode = mode);
                        }
                        GUILayout.EndScrollView();
                        GUILayout.EndVertical();
                    }
                }
            }
            GUILayout.EndVertical();
            GUILayout.BeginVertical(GUIStyles.Skin.box);
            {
                Toggle("SEGI (Experimental)", inspectSEGI, true, inspect => inspectSEGI = inspect);
                if (inspectSEGI)
                {
                    if (null != Graphics.Instance.CameraSettings.MainCamera && null == segi)
                    {
                        segi = Graphics.Instance.CameraSettings.MainCamera.GetOrAddComponent <SEGI>();
                        if (null != segi)
                        {
                            segi.enabled = false;
                        }
                    }

                    if (null != segi)
                    {
                        Toggle("Enable", segi.enabled, false, enable => segi.enabled = enable);
                        if (segi.enabled)
                        {
                            GUILayout.BeginVertical(GUIStyles.Skin.box);
                            segiScrollView = GUILayout.BeginScrollView(segiScrollView);
                            {
                                Label("Main Configuration", "", true);
                                Selection("Voxel Resolution", segi.voxelResolution, resolution => segi.voxelResolution = resolution);
                                Toggle("Volex AA", segi.voxelAA, false, aa => segi.voxelAA = aa);
                                Slider("Inner Occlusion Layers", segi.innerOcclusionLayers, 0, 2, layers => segi.innerOcclusionLayers = layers);
                                Toggle("Gaussian Mip Filter", segi.gaussianMipFilter, false, filter => segi.gaussianMipFilter         = filter);
                                Text("Voxel Space Size", segi.voxelSpaceSize, "N2", size => segi.voxelSpaceSize    = size);
                                Text("Shadow Space Size", segi.shadowSpaceSize, "N2", size => segi.shadowSpaceSize = size);
                                SelectionMask("GI Culling Mask", segi.giCullingMask, mask => segi.giCullingMask    = mask);
                                Toggle("Update GI", segi.updateGI, false, update => segi.updateGI = update);
                                Toggle("Infinite Bounces", segi.infiniteBounces, false, bounce => segi.infiniteBounces = bounce);
                                Label("VRAM usage", segi.vramUsage.ToString("N2") + " MB");
                                GUILayout.Space(10);
                                Label("Environmental Properties", "", true);
                                string sun = segi.sun ? segi.sun.ToString() : "Please set one directional light as sunlight";
                                Label("Sun", sun);
                                Slider("Soft Sunlight", segi.softSunlight, 0f, 16f, "N2", soft => segi.softSunlight = soft);
                                SliderColor("Sky Colour", segi.skyColor, colour => segi.skyColor = colour);
                                Slider("Sky Intensity", segi.skyIntensity, 0f, 8f, "N2", intensity => segi.skyIntensity         = intensity);
                                Toggle("Spherical Skylight", segi.sphericalSkylight, false, spherical => segi.sphericalSkylight = spherical);
                                GUILayout.Space(10);
                                Label("Tracing Properties", "", true);
                                Slider("Temporal Blend Weight", segi.temporalBlendWeight, 0f, 1f, "N2", weight => segi.temporalBlendWeight = weight);
                                Toggle("Bilateral Filtering", segi.useBilateralFiltering, false, filter => segi.useBilateralFiltering      = filter);
                                Toggle("Half Resolution", segi.halfResolution, false, half => segi.halfResolution = half);
                                Toggle("Stochastic Sampling", segi.stochasticSampling, false, sampling => segi.stochasticSampling = sampling);
                                Slider("Cones", segi.cones, 1, 128, cones => segi.cones = cones);
                                Slider("Cones Trace Steps", segi.coneTraceSteps, 1, 32, cones => segi.coneTraceSteps               = cones);
                                Slider("Cones Length", segi.coneLength, 0.1f, 2f, "N2", cones => segi.coneLength                   = cones);
                                Slider("Cones Width", segi.coneWidth, 0.5f, 6f, "N2", cones => segi.coneWidth                      = cones);
                                Slider("Cones Trace Bias", segi.coneTraceBias, 0f, 4f, "N2", cones => segi.coneTraceBias           = cones);
                                Slider("Occlusion Strength", segi.occlusionStrength, 0f, 4f, "N2", cones => segi.occlusionStrength = cones);
                                Slider("Near Occlusion Strength", segi.nearOcclusionStrength, 0f, 4f, "N2", cones => segi.nearOcclusionStrength             = cones);
                                Slider("Far Occlusion Strength", segi.farOcclusionStrength, 0f, 4f, "N2", cones => segi.farOcclusionStrength                = cones);
                                Slider("Farthest Occlusion Strength", segi.farthestOcclusionStrength, 0f, 4f, "N2", cones => segi.farthestOcclusionStrength = cones);
                                Slider("Occlusion Power", segi.occlusionPower, 0.001f, 4f, "N2", cones => segi.occlusionPower = cones);
                                Slider("Near Light Gain", segi.nearLightGain, 0f, 4f, "N2", cones => segi.nearLightGain       = cones);
                                Slider("GI Gain", segi.giGain, 0f, 4f, "N2", cones => segi.giGain = cones);
                                GUILayout.Space(10);
                                Slider("Secondary Bounce Gain", segi.secondaryBounceGain, 0f, 4f, "N2", cones => segi.secondaryBounceGain = cones);
                                Slider("Secondary Cones", segi.secondaryCones, 3, 16, cones => segi.secondaryCones = cones);
                                Slider("Secondary Occlusion Strength", segi.secondaryOcclusionStrength, 0.1f, 4f, "N2", cones => segi.secondaryOcclusionStrength = cones);
                                GUILayout.Space(10);
                                Label("Reflection Properties", "", true);
                                Toggle("Do Reflections", segi.doReflections, false, reflections => segi.doReflections   = reflections);
                                Slider("Reflection Steps", segi.reflectionSteps, 12, 128, cones => segi.reflectionSteps = cones);
                                Slider("Reflection Occlusion Power", segi.reflectionOcclusionPower, 0.001f, 4f, "N2", cones => segi.reflectionOcclusionPower = cones);
                                Slider("Sky Reflection Intensity", segi.skyReflectionIntensity, 0f, 1f, "N2", intensity => segi.skyReflectionIntensity       = intensity);
                                GUILayout.Space(10);
                                Label("Debug Tools", "", true);
                                Toggle("Visualize Sun Depth Texture", segi.visualizeSunDepthTexture, false, visual => segi.visualizeSunDepthTexture = visual);
                                Toggle("Visualize GI", segi.visualizeGI, false, visual => segi.visualizeGI             = visual);
                                Toggle("Visualize Voxels", segi.visualizeVoxels, false, visual => segi.visualizeVoxels = visual);
                            }
                            GUILayout.EndScrollView();
                            GUILayout.EndVertical();
                        }
                    }
                }
            }
            GUILayout.EndVertical();
        }