void OnEnable() { serObj = new SerializedObject(target); updateGIevery = serObj.FindProperty("updateGIevery"); voxelResolution = serObj.FindProperty("voxelResolution"); visualizeSunDepthTexture = serObj.FindProperty("visualizeSunDepthTexture"); visualizeGI = serObj.FindProperty("visualizeGI"); sun = serObj.FindProperty("sun"); giCullingMask = serObj.FindProperty("giCullingMask"); shadowSpaceSize = serObj.FindProperty("shadowSpaceSize"); temporalBlendWeight = serObj.FindProperty("temporalBlendWeight"); visualizeVoxels = serObj.FindProperty("visualizeVoxels"); updateGI = serObj.FindProperty("updateGI"); skyColor = serObj.FindProperty("skyColor"); voxelSpaceSize = serObj.FindProperty("voxelSpaceSize"); useBilateralFiltering = serObj.FindProperty("useBilateralFiltering"); halfResolution = serObj.FindProperty("halfResolution"); stochasticSampling = serObj.FindProperty("stochasticSampling"); infiniteBounces = serObj.FindProperty("infiniteBounces"); followTransform = serObj.FindProperty("followTransform"); cones = serObj.FindProperty("cones"); coneTraceSteps = serObj.FindProperty("coneTraceSteps"); coneLength = serObj.FindProperty("coneLength"); coneWidth = serObj.FindProperty("coneWidth"); occlusionStrength = serObj.FindProperty("occlusionStrength"); nearOcclusionStrength = serObj.FindProperty("nearOcclusionStrength"); occlusionPower = serObj.FindProperty("occlusionPower"); coneTraceBias = serObj.FindProperty("coneTraceBias"); nearLightGain = serObj.FindProperty("nearLightGain"); giGain = serObj.FindProperty("giGain"); secondaryBounceGain = serObj.FindProperty("secondaryBounceGain"); softSunlight = serObj.FindProperty("softSunlight"); doReflections = serObj.FindProperty("doReflections"); voxelAA = serObj.FindProperty("voxelAA"); reflectionSteps = serObj.FindProperty("reflectionSteps"); skyReflectionIntensity = serObj.FindProperty("skyReflectionIntensity"); gaussianMipFilter = serObj.FindProperty("gaussianMipFilter"); reflectionOcclusionPower = serObj.FindProperty("reflectionOcclusionPower"); farOcclusionStrength = serObj.FindProperty("farOcclusionStrength"); farthestOcclusionStrength = serObj.FindProperty("farthestOcclusionStrength"); secondaryCones = serObj.FindProperty("secondaryCones"); secondaryOcclusionStrength = serObj.FindProperty("secondaryOcclusionStrength"); skyIntensity = serObj.FindProperty("skyIntensity"); sphericalSkylight = serObj.FindProperty("sphericalSkylight"); innerOcclusionLayers = serObj.FindProperty("innerOcclusionLayers"); instance = target as SEGI; }
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; }
internal static void Draw(GlobalSettings renderingSettings, LightManager lightManager, bool showAdvanced) { GUILayout.BeginVertical(GUIStyles.Skin.box); { if (showAdvanced) { Toggle("Use Alloy Light", lightManager.UseAlloyLight, false, useAlloy => lightManager.UseAlloyLight = useAlloy); Toggle("Lights Use Linear Intensity", renderingSettings.LightsUseLinearIntensity, false, useLinear => renderingSettings.LightsUseLinearIntensity = useLinear); Toggle("Lights Use Color Temperature", renderingSettings.LightsUseColorTemperature, false, useTemperature => renderingSettings.LightsUseColorTemperature = useTemperature); } GUILayout.BeginHorizontal(); { GUILayout.BeginVertical(GUIStyles.Skin.box, GUILayout.Width(200), GUILayout.MaxWidth(250)); { LightGroup(lightManager, "Directional Lights", LightSettings.LightType.Directional); if (0 < lightManager.DirectionalLights.Count) { GUILayout.BeginVertical(GUIStyles.Skin.box); dirLightScrollView = GUILayout.BeginScrollView(dirLightScrollView); lightManager.DirectionalLights.ForEach(l => LightOverviewModule(lightManager, l)); GUILayout.FlexibleSpace(); GUILayout.EndScrollView(); GUILayout.EndVertical(); } LightGroup(lightManager, "Point Lights", LightSettings.LightType.Point); if (0 < lightManager.PointLights.Count) { GUILayout.BeginVertical(GUIStyles.Skin.box); pointLightScrollView = GUILayout.BeginScrollView(pointLightScrollView); lightManager.PointLights.ForEach(l => LightOverviewModule(lightManager, l)); GUILayout.FlexibleSpace(); GUILayout.EndScrollView(); GUILayout.EndVertical(); } LightGroup(lightManager, "Spot Lights", LightSettings.LightType.Spot); if (0 < lightManager.SpotLights.Count) { GUILayout.BeginVertical(GUIStyles.Skin.box); spotLightScrollView = GUILayout.BeginScrollView(spotLightScrollView); lightManager.SpotLights.ForEach(l => LightOverviewModule(lightManager, l)); GUILayout.FlexibleSpace(); GUILayout.EndScrollView(); GUILayout.EndVertical(); } } GUILayout.EndVertical(); GUILayout.BeginVertical(GUIStyles.Skin.box); { if (null != lightManager.SelectedLight) { if (lightManager.SelectedLight.enabled) { AlloyAreaLight alloyLight = null; if (lightManager.UseAlloyLight) { alloyLight = lightManager.SelectedLight.light.GetComponent <AlloyAreaLight>(); } Label(lightManager.SelectedLight.light.name, "", true); GUILayout.BeginVertical(GUIStyles.Skin.box); inspectorScrollView = GUILayout.BeginScrollView(inspectorScrollView); { Label("Colour", "", true); SliderColor("Colour", lightManager.SelectedLight.color, c => lightManager.SelectedLight.color = c); if (renderingSettings.LightsUseColorTemperature) { Slider("Temperature (K)", lightManager.SelectedLight.light.colorTemperature, 0f, 30000f, "N0", t => lightManager.SelectedLight.light.colorTemperature = t); } GUILayout.Space(10); Label("Shadows", "", true); Selection("Shadow Type", lightManager.SelectedLight.shadows, type => lightManager.SelectedLight.shadows = type); Slider("Strength", lightManager.SelectedLight.light.shadowStrength, 0f, 1f, "N2", strength => lightManager.SelectedLight.light.shadowStrength = strength); if (LightType.Directional == lightManager.SelectedLight.type && renderingSettings.UsePCSS) { Slider("Resolution", lightManager.SelectedLight.ShadowCustomResolution, 0, PCSSLight.MaxShadowCustomResolution, resolution => lightManager.SelectedLight.ShadowCustomResolution = resolution); } else { Selection("Resolution", lightManager.SelectedLight.light.shadowResolution, resolution => lightManager.SelectedLight.light.shadowResolution = resolution, 2); } Slider("Bias", lightManager.SelectedLight.light.shadowBias, 0f, 2f, "N3", bias => lightManager.SelectedLight.light.shadowBias = bias); Slider("Normal Bias", lightManager.SelectedLight.light.shadowNormalBias, 0f, 3f, "N2", nbias => lightManager.SelectedLight.light.shadowNormalBias = nbias); Slider("Near Plane", lightManager.SelectedLight.light.shadowNearPlane, 0f, 10f, "N2", np => lightManager.SelectedLight.light.shadowNearPlane = np); GUILayout.Space(10); Slider("Intensity", lightManager.SelectedLight.intensity, LightSettings.IntensityMin, LightSettings.IntensityMax, "N2", i => lightManager.SelectedLight.intensity = i); Slider("Indirect Multiplier", lightManager.SelectedLight.light.bounceIntensity, LightSettings.IntensityMin, LightSettings.IntensityMax, "N0", bi => lightManager.SelectedLight.light.bounceIntensity = bi); GUILayout.Space(10); if (lightManager.SelectedLight.type == LightType.Directional) { if (null != Graphics.Instance.CameraSettings.MainCamera && null == segi) { segi = Graphics.Instance.CameraSettings.MainCamera.GetComponent <SEGI>(); } if (null != segi && segi.enabled) { bool isSEGISun = ReferenceEquals(lightManager.SelectedLight.light, segi.sun); if (null != segi.sun && !isSEGISun) { GUI.enabled = false; } Toggle("SEGI Sun source", isSEGISun, false, sun => { if (sun) { segi.sun = lightManager.SelectedLight.light; } else { segi.sun = null; } }); GUI.enabled = true; } Vector3 rot = lightManager.SelectedLight.rotation; Slider("Vertical Rotation", rot.x, LightSettings.RotationXMin, LightSettings.RotationXMax, "N1", x => { rot.x = x; }); Slider("Horizontal Rotation", rot.y, LightSettings.RotationYMin, LightSettings.RotationYMax, "N1", y => { rot.y = y; }); if (rot != lightManager.SelectedLight.rotation) { lightManager.SelectedLight.rotation = rot; } } else { Slider("Light Range", lightManager.SelectedLight.range, 0.1f, 100f, "N1", range => { lightManager.SelectedLight.range = range; }); if (lightManager.SelectedLight.type == LightType.Spot) { Slider("Spot Angle", lightManager.SelectedLight.spotAngle, 1f, 179f, "N1", angle => { lightManager.SelectedLight.spotAngle = angle; }); } } GUILayout.Space(10); if (lightManager.UseAlloyLight && alloyLight.HasSpecularHighlight && null != alloyLight) { Slider("Specular Highlight", alloyLight.Radius, 0f, 1f, "N2", i => alloyLight.Radius = i); if (lightManager.SelectedLight.type == LightType.Point) { Slider("Length", alloyLight.Length, 0f, 1f, "N2", i => alloyLight.Length = i); } } if (showAdvanced) { Selection("Render Mode", lightManager.SelectedLight.light.renderMode, mode => lightManager.SelectedLight.light.renderMode = mode); SelectionMask("Culling Mask", lightManager.SelectedLight.light.cullingMask, mask => lightManager.SelectedLight.light.cullingMask = mask); } } GUILayout.EndScrollView(); GUILayout.EndVertical(); GUILayout.FlexibleSpace(); } else { Label("Selected light is disabled.", ""); } } else { Label("Select a light source on the left panel.", ""); } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); } GUILayout.EndVertical(); }
void Start() { segi = GetComponent <SEGI>(); }
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(); }