793 lines
25 KiB
C#
793 lines
25 KiB
C#
using System;
|
|
using BitStrap;
|
|
using Colorful;
|
|
using UltimateWater;
|
|
using UltimateWater.Internal;
|
|
using UnityEngine;
|
|
using UnityEngine.PostProcessing;
|
|
using UnityEngine.Rendering.PostProcessing;
|
|
using VolumetricFogAndMist;
|
|
using uNature.Core.FoliageClasses;
|
|
|
|
public class RenderSettingsMy : MonoBehaviour
|
|
{
|
|
public enum ReflectionQuality
|
|
{
|
|
NONE = 0,
|
|
SIMPLE = 1,
|
|
FULL = 2,
|
|
COUNT = 3
|
|
}
|
|
|
|
public enum ShadowsQuality
|
|
{
|
|
NONE = 0,
|
|
LOW = 1,
|
|
MEDIUM = 2,
|
|
HIGH = 3
|
|
}
|
|
|
|
public enum Antialiasing
|
|
{
|
|
NONE = 0,
|
|
FXAA = 1,
|
|
TAA = 2
|
|
}
|
|
|
|
[Serializable]
|
|
public class QualityDefinition
|
|
{
|
|
public string name = string.Empty;
|
|
|
|
public int qualityLevel = 4;
|
|
|
|
public bool useBirds = true;
|
|
|
|
public bool useCameraWaterDrops = true;
|
|
|
|
public float grassDensity = 1f;
|
|
|
|
public int grassGlobalDistance = 70;
|
|
|
|
public float shadowsFactor = 1f;
|
|
|
|
[Space(10f)]
|
|
public int windWavesResolution = 256;
|
|
|
|
public int waterRipplesQuality = 32;
|
|
|
|
public bool useCaustics = true;
|
|
|
|
[Space(10f)]
|
|
public float fishDistanceBehaviorMultiplier = 1f;
|
|
|
|
public float fishDistanceAnimationMultiplier = 1f;
|
|
|
|
public float fishSpawnersAmount = 1f;
|
|
|
|
public float rodBendDelay;
|
|
}
|
|
|
|
public enum RenderQuality
|
|
{
|
|
VERY_LOW = 0,
|
|
LOW = 1,
|
|
MEDIUM = 2,
|
|
HIGH = 3,
|
|
VERY_HIGH = 4,
|
|
COUNT = 5
|
|
}
|
|
|
|
public int resolutionWidth;
|
|
|
|
public int resolutionHeight;
|
|
|
|
[Space(10f)]
|
|
public bool useMotionBlur = true;
|
|
|
|
public bool useVsync = true;
|
|
|
|
public bool useAO;
|
|
|
|
public float fov = 60f;
|
|
|
|
public float underwaterBlur = 0.3f;
|
|
|
|
public bool underwaterDistortion = true;
|
|
|
|
public float blur = 0.625f;
|
|
|
|
[Space(10f)]
|
|
public ReflectionQuality reflectionQuality = ReflectionQuality.FULL;
|
|
|
|
public bool useWaterRipples = true;
|
|
|
|
[Space(10f)]
|
|
public Camera cameraFilters;
|
|
|
|
private BrightnessContrastGamma brightnessContrastGamma;
|
|
|
|
public float cameraBrightness = 1f;
|
|
|
|
public float cameraContrast = 1f;
|
|
|
|
public float cameraGamma = 1f;
|
|
|
|
[Space(10f)]
|
|
public QualityDefinition[] qualityDefinitions = new QualityDefinition[5];
|
|
|
|
public QualityDefinition[] qualityDefinitionsVR = new QualityDefinition[5];
|
|
|
|
[Space(10f)]
|
|
public RenderQuality currentQuality = RenderQuality.VERY_HIGH;
|
|
|
|
public RenderQuality currentWaterQuality = RenderQuality.VERY_HIGH;
|
|
|
|
public int currentTextureQuality = 2;
|
|
|
|
public ShadowsQuality currentShadowsQuality;
|
|
|
|
public Antialiasing currentAntialiasing = Antialiasing.TAA;
|
|
|
|
private GameObject[] birdObjects;
|
|
|
|
private Water water;
|
|
|
|
private LayerMask reflectionMask = 0;
|
|
|
|
public void Initialize()
|
|
{
|
|
resolutionWidth = 0;
|
|
resolutionHeight = 0;
|
|
WindowMod.SaveStartMode();
|
|
}
|
|
|
|
private void OnApplicationQuit()
|
|
{
|
|
WindowMod.LoadStartMode();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
if (Screen.width == 0 || Screen.height == 0 || Screen.width == 1 || Screen.height == 1)
|
|
{
|
|
ChangeResolution(Screen.currentResolution.width, Screen.currentResolution.height, true);
|
|
}
|
|
Debug.Log("Screen prefs resolution: " + Screen.width + " " + Screen.height);
|
|
Debug.Log("Screen.currentResolution: " + Screen.currentResolution.width + " " + Screen.currentResolution.height);
|
|
brightnessContrastGamma = cameraFilters.GetComponent<BrightnessContrastGamma>();
|
|
CheckSystemSpecification();
|
|
ChangeRenderQuality(currentQuality);
|
|
ChangeWaterQuality(currentWaterQuality);
|
|
RefreshAll();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if ((bool)GlobalSettings.Instance && GlobalSettings.Instance.turnOnMyCheats && Input.GetKeyDown(KeyCode.F4))
|
|
{
|
|
brightnessContrastGamma.gameObject.SetActive(!brightnessContrastGamma.gameObject.activeSelf);
|
|
}
|
|
}
|
|
|
|
public void ChangeRenderQuality(RenderQuality renderQuality)
|
|
{
|
|
if (renderQuality != RenderQuality.COUNT)
|
|
{
|
|
currentQuality = renderQuality;
|
|
RefreshSettings();
|
|
}
|
|
}
|
|
|
|
public void ChangeWaterQuality(RenderQuality renderQuality)
|
|
{
|
|
if (renderQuality != RenderQuality.COUNT)
|
|
{
|
|
currentWaterQuality = renderQuality;
|
|
RefreshWaterSettings();
|
|
}
|
|
}
|
|
|
|
public void ChangeVRShadows(ShadowsQuality shadowsQuality)
|
|
{
|
|
if (shadowsQuality != currentShadowsQuality)
|
|
{
|
|
currentShadowsQuality = shadowsQuality;
|
|
RefreshVRShadows();
|
|
}
|
|
}
|
|
|
|
public void ChangeTextureQuality(int textureQuality)
|
|
{
|
|
currentTextureQuality = textureQuality;
|
|
if (currentTextureQuality == 0)
|
|
{
|
|
QualitySettings.masterTextureLimit = 2;
|
|
}
|
|
else if (currentTextureQuality == 1)
|
|
{
|
|
QualitySettings.masterTextureLimit = 1;
|
|
}
|
|
else if (currentTextureQuality == 2)
|
|
{
|
|
QualitySettings.masterTextureLimit = 0;
|
|
}
|
|
}
|
|
|
|
public void ChangeResolution(int width, int height, bool fullScreen, int refreshRate = 0)
|
|
{
|
|
if (VRManager.IsVROn())
|
|
{
|
|
}
|
|
DEVMODE currentSettings = WindowMod.GetCurrentSettings();
|
|
Utilities.LogError("ChangeResolution: " + currentSettings.dmPelsWidth + " | " + width + " x " + currentSettings.dmPelsHeight + " | " + height + " fullscreen: " + fullScreen + " " + refreshRate + "Hz", "orange", true);
|
|
if (currentSettings.dmPelsWidth < width || currentSettings.dmPelsHeight < height)
|
|
{
|
|
Utilities.LogError("WindowMod.ChangeDisplaySettings");
|
|
WindowMod.ChangeDisplaySettings(width, height);
|
|
}
|
|
if (refreshRate > 0)
|
|
{
|
|
Screen.SetResolution(width, height, fullScreen, refreshRate);
|
|
}
|
|
else
|
|
{
|
|
Screen.SetResolution(width, height, fullScreen);
|
|
}
|
|
resolutionWidth = width;
|
|
resolutionHeight = height;
|
|
}
|
|
|
|
public void ToggleQuality()
|
|
{
|
|
currentQuality++;
|
|
if (currentQuality == RenderQuality.COUNT)
|
|
{
|
|
currentQuality = RenderQuality.VERY_LOW;
|
|
}
|
|
ChangeRenderQuality(currentQuality);
|
|
}
|
|
|
|
[Button]
|
|
public void RefreshAll()
|
|
{
|
|
RefreshSettings();
|
|
RefreshWaterReflection();
|
|
RefreshVsync();
|
|
RefreshPostprocesses();
|
|
RefreshWaterRipples();
|
|
RefreshCameraFilters();
|
|
RefreshVRShadows();
|
|
LeanTween.delayedCall(0.01f, RefreshWaterSettings).setIgnoreTimeScale(true);
|
|
}
|
|
|
|
public void RefreshSettings()
|
|
{
|
|
RenderQuality renderQuality = currentQuality;
|
|
QualityDefinition quality = qualityDefinitions[(int)renderQuality];
|
|
if (VRManager.IsVROn() && VRManager.Instance.forceVRQuality)
|
|
{
|
|
if (renderQuality != RenderQuality.LOW && renderQuality != RenderQuality.MEDIUM)
|
|
{
|
|
renderQuality = RenderQuality.HIGH;
|
|
}
|
|
quality = qualityDefinitionsVR[(int)renderQuality];
|
|
}
|
|
QualitySettings.SetQualityLevel(quality.qualityLevel);
|
|
if (!GameController.Instance || !GameController.Instance.fishingPlayer || (bool)GameController.Instance.fishingPlayer.waterRaindropsIME)
|
|
{
|
|
}
|
|
if ((bool)GameController.Instance && (bool)FoliageCore_MainManager.instance)
|
|
{
|
|
if (VRManager.IsVROn())
|
|
{
|
|
if (quality.grassDensity > 0f)
|
|
{
|
|
FoliageCore_MainManager.instance.density = GameController.Instance.vrGrassDensity;
|
|
}
|
|
else
|
|
{
|
|
FoliageCore_MainManager.instance.density = 0f;
|
|
}
|
|
FoliageCore_MainManager.instance.globalFadeDistance = GameController.Instance.vrGrassDistance;
|
|
}
|
|
else
|
|
{
|
|
FoliageCore_MainManager.instance.density = quality.grassDensity;
|
|
}
|
|
}
|
|
if ((bool)GameController.Instance && VRManager.IsVROn())
|
|
{
|
|
foreach (GameObject item in GameController.Instance.terrainsNormal)
|
|
{
|
|
if (item != null)
|
|
{
|
|
Terrain component = item.GetComponent<Terrain>();
|
|
if (component != null)
|
|
{
|
|
component.drawTreesAndFoliage = quality.grassDensity > 0f;
|
|
}
|
|
}
|
|
}
|
|
QualitySettings.lodBias = ((!GameController.Instance.iceLevel) ? GameController.Instance.vrLodBias : GameController.Instance.vrLodBiasIce);
|
|
QualitySettings.lodBias *= quality.shadowsFactor;
|
|
GameController.Instance.fishingPlayer.dustParticles.EnableEmission(false);
|
|
if ((bool)GameController.Instance.fishingPlayer.underwaterCamera.GetComponentInChildren<ParticleSystem>())
|
|
{
|
|
GameController.Instance.fishingPlayer.underwaterCamera.GetComponentInChildren<ParticleSystem>().EnableEmission(renderQuality >= RenderQuality.HIGH);
|
|
}
|
|
if (GameController.Instance.refreshVRQualityAll != null)
|
|
{
|
|
for (int i = 0; i < GameController.Instance.refreshVRQualityAll.Length; i++)
|
|
{
|
|
if ((bool)GameController.Instance.refreshVRQualityAll[i])
|
|
{
|
|
GameController.Instance.refreshVRQualityAll[i].Refresh();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ((bool)GameController.Instance && GameController.Instance.unityGrassDistance.y > 0f)
|
|
{
|
|
for (int j = 0; j < GameController.Instance.terrainsNormal.Count; j++)
|
|
{
|
|
if (GameController.Instance.terrainsNormal[j] != null)
|
|
{
|
|
Terrain component2 = GameController.Instance.terrainsNormal[j].GetComponent<Terrain>();
|
|
if (VRManager.IsVROn() && (bool)GameController.Instance)
|
|
{
|
|
component2.detailObjectDistance = GameController.Instance.vrGrassDistance;
|
|
component2.detailObjectDensity = GameController.Instance.vrGrassDensity;
|
|
}
|
|
else
|
|
{
|
|
component2.detailObjectDistance = Mathf.Lerp(GameController.Instance.unityGrassDistance.x, GameController.Instance.unityGrassDistance.y, quality.grassDensity);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (birdObjects != null)
|
|
{
|
|
LeanTween.delayedCall((!quality.useBirds) ? 0.1f : 0f, (Action)delegate
|
|
{
|
|
for (int k = 0; k < birdObjects.Length; k++)
|
|
{
|
|
birdObjects[k].SetActive(quality.useBirds);
|
|
}
|
|
});
|
|
}
|
|
if (VRManager.IsVROn() && VRManager.Instance.forceVRQuality)
|
|
{
|
|
RefreshVRShadows();
|
|
}
|
|
else if ((bool)GameController.Instance)
|
|
{
|
|
float num = (QualitySettings.shadowDistance = (float)((!GameController.Instance.iceLevel) ? GameController.Instance.shadowDistance : GameController.Instance.shadowDistanceWinter) * quality.shadowsFactor);
|
|
QualitySettings.shadowCascades = ((!GameController.Instance.iceLevel) ? GameController.Instance.shadowMaxCascades : GameController.Instance.shadowMaxCascadesWinter);
|
|
if (QualitySettings.shadowCascades == 4)
|
|
{
|
|
Vector3 zero = Vector3.zero;
|
|
float num3 = 150f / num;
|
|
zero = GameController.Instance.shadow4CascadeSplit * num3;
|
|
QualitySettings.shadowCascade4Split = zero;
|
|
}
|
|
else if (QualitySettings.shadowCascades == 2)
|
|
{
|
|
QualitySettings.shadowCascade2Split = GameController.Instance.shadow2CascadeSplit;
|
|
}
|
|
if (QualitySettings.shadowResolution > GameController.Instance.maxShadowResolution)
|
|
{
|
|
QualitySettings.shadowResolution = GameController.Instance.maxShadowResolution;
|
|
}
|
|
}
|
|
LeanTween.delayedCall(0.01f, RefreshWaterSettings).setIgnoreTimeScale(true);
|
|
}
|
|
|
|
public void RefreshWaterSettings()
|
|
{
|
|
if (!VRManager.IsVROn() || VRManager.Instance.forceVRQuality)
|
|
{
|
|
}
|
|
RenderQuality renderQuality = currentWaterQuality;
|
|
QualityDefinition qualityDefinition = qualityDefinitions[(int)renderQuality];
|
|
WaterQualitySettings.Instance.SetQualityLevel(4);
|
|
if ((bool)water)
|
|
{
|
|
water.WindWaves.Resolution = qualityDefinition.windWavesResolution;
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
if (VRManager.IsVROn())
|
|
{
|
|
GameController.Instance.azureSkyController.sunLightWaterEffects.enabled = false;
|
|
GameController.Instance.azureSkyController.moonLightWaterEffects.enabled = false;
|
|
}
|
|
else
|
|
{
|
|
GameController.Instance.azureSkyController.sunLightWaterEffects.enabled = qualityDefinition.useCaustics && !GameController.Instance.iceLevel && water.Geometry.GeometryType != WaterGeometry.Type.CustomMeshes;
|
|
GameController.Instance.azureSkyController.moonLightWaterEffects.enabled = qualityDefinition.useCaustics && !GameController.Instance.iceLevel && water.Geometry.GeometryType != WaterGeometry.Type.CustomMeshes;
|
|
}
|
|
}
|
|
}
|
|
if ((bool)GameController.Instance && (bool)GameController.Instance.fishingPlayer)
|
|
{
|
|
GameController.Instance.fishingPlayer.waterSimulationSpace.PixelsPerUnit = qualityDefinition.waterRipplesQuality;
|
|
GameController.Instance.fishingPlayer.waterSimulationSpace.Refresh();
|
|
RefreshWaterRipples();
|
|
}
|
|
}
|
|
|
|
public void RefreshWaterReflection()
|
|
{
|
|
if (!(water == null))
|
|
{
|
|
if (reflectionQuality == ReflectionQuality.NONE)
|
|
{
|
|
water.PlanarReflection.ReflectionMask = 0;
|
|
water.PlanarReflection.ReflectSkybox = true;
|
|
water.PlanarReflection.Resolution = 0.1f;
|
|
}
|
|
else if (reflectionQuality == ReflectionQuality.SIMPLE)
|
|
{
|
|
water.PlanarReflection.ReflectionMask = reflectionMask;
|
|
water.PlanarReflection.ReflectSkybox = true;
|
|
water.PlanarReflection.Resolution = 0.3f;
|
|
}
|
|
else if (reflectionQuality == ReflectionQuality.FULL)
|
|
{
|
|
water.PlanarReflection.ReflectionMask = reflectionMask;
|
|
water.PlanarReflection.ReflectSkybox = true;
|
|
water.PlanarReflection.Resolution = 0.65f;
|
|
}
|
|
if ((bool)GameController.Instance && !GameController.Instance.fishingPlayer.underwaterCamera.isTurnedOn)
|
|
{
|
|
GameController.Instance.waterParameters.SetReflectionColor(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void RefreshVsync()
|
|
{
|
|
QualitySettings.vSyncCount = (useVsync ? 1 : 0);
|
|
if (VRManager.IsVROn())
|
|
{
|
|
QualitySettings.vSyncCount = 0;
|
|
}
|
|
LeanTween.delayedCall(0.01f, RefreshWaterSettings).setIgnoreTimeScale(true);
|
|
}
|
|
|
|
public void RefreshPostprocesses()
|
|
{
|
|
if (!GameController.Instance || !GameController.Instance.fishingPlayer || !GameController.Instance.fishingPlayer.postProcessingBehaviour_1)
|
|
{
|
|
return;
|
|
}
|
|
if (VRManager.IsVROn())
|
|
{
|
|
GameController.Instance.fishingPlayer.amplifyMotionEffect.enabled = false;
|
|
if ((bool)GameController.Instance.fishingPlayer.ufpsCamera.GetComponent<AmplifyMotionCamera>())
|
|
{
|
|
GameController.Instance.fishingPlayer.ufpsCamera.GetComponent<AmplifyMotionCamera>().enabled = false;
|
|
}
|
|
if ((bool)GameController.Instance.fishingPlayer.ufpsCamera.GetComponent<VolumetricFogPosT>())
|
|
{
|
|
GameController.Instance.fishingPlayer.ufpsCamera.GetComponent<VolumetricFogPosT>().enabled = false;
|
|
}
|
|
GameController.Instance.fishingPlayer.amplifyOcclusion.enabled = GameController.Instance.oceanLevel;
|
|
GameController.Instance.fishingPlayer.amplifyOcclusionUnderwater.enabled = true;
|
|
GameController.Instance.fishingPlayer.underwaterCamera.GetComponent<UnderwaterIME>()._Blur.Iterations = 0;
|
|
GameController.Instance.fishingPlayer.underwaterCamera.GetComponent<UnderwaterIME>()._CameraBlurScale = 0f;
|
|
}
|
|
else
|
|
{
|
|
GameController.Instance.fishingPlayer.amplifyMotionEffect.enabled = useMotionBlur;
|
|
GameController.Instance.fishingPlayer.amplifyOcclusion.enabled = useAO;
|
|
GameController.Instance.fishingPlayer.amplifyOcclusionUnderwater.enabled = useAO;
|
|
GameController.Instance.fishingPlayer.underwaterCamera.GetComponent<UnderwaterIME>()._CameraBlurScale = underwaterBlur;
|
|
}
|
|
AntialiasingModel.Settings settings = GameController.Instance.fishingPlayer.postProcessingBehaviour_1.profile.antialiasing.settings;
|
|
settings.taaSettings.stationaryBlending = Mathf.Lerp(0.6f, 1f, blur);
|
|
settings.taaSettings.motionBlending = Mathf.Lerp(0.6f, 1f, blur) - 0.1f;
|
|
GameController.Instance.fishingPlayer.postProcessingBehaviour_1.profile.antialiasing.settings = settings;
|
|
if (VRManager.IsVROn())
|
|
{
|
|
GameController.Instance.fishingPlayer.postProcessLayer.temporalAntialiasing.stationaryBlending = Mathf.Lerp(0.2f, 1f, blur) - 0.1f;
|
|
GameController.Instance.fishingPlayer.postProcessLayer.temporalAntialiasing.motionBlending = Mathf.Lerp(0.2f, 1f, blur) - 0.2f;
|
|
}
|
|
else
|
|
{
|
|
GameController.Instance.fishingPlayer.postProcessLayer.temporalAntialiasing.stationaryBlending = Mathf.Lerp(0.5f, 1f, blur);
|
|
GameController.Instance.fishingPlayer.postProcessLayer.temporalAntialiasing.motionBlending = Mathf.Lerp(0.5f, 1f, blur) - 0.1f;
|
|
}
|
|
}
|
|
|
|
public void RefreshWaterRipples()
|
|
{
|
|
if ((bool)GameController.Instance && (bool)GameController.Instance.fishingPlayer)
|
|
{
|
|
GameController.Instance.fishingPlayer.waterSimulationSpace.gameObject.SetActive(false);
|
|
GameController.Instance.fishingPlayer.waterSimulationSpace.gameObject.SetActive(useWaterRipples);
|
|
GameController.Instance.fishingPlayer.rain.GetComponent<WaterParticleDisplacement>().enabled = useWaterRipples;
|
|
}
|
|
}
|
|
|
|
public void RefreshCameraFilters()
|
|
{
|
|
if ((bool)brightnessContrastGamma)
|
|
{
|
|
brightnessContrastGamma.Brightness = cameraBrightness;
|
|
brightnessContrastGamma.Contrast = cameraContrast;
|
|
brightnessContrastGamma.Gamma = cameraGamma;
|
|
bool active = cameraBrightness != 0f || cameraContrast != 0f || cameraGamma != 1f;
|
|
brightnessContrastGamma.gameObject.SetActive(active);
|
|
}
|
|
}
|
|
|
|
public void RefreshnewParams()
|
|
{
|
|
}
|
|
|
|
public void RefreshVRShadows()
|
|
{
|
|
if (VRManager.IsVROn())
|
|
{
|
|
if ((bool)MenuManager.Instance && MenuManager.Instance.gameObject.activeSelf)
|
|
{
|
|
QualitySettings.shadows = ShadowQuality.All;
|
|
QualitySettings.shadowResolution = ShadowResolution.High;
|
|
}
|
|
else if (currentShadowsQuality == ShadowsQuality.NONE)
|
|
{
|
|
QualitySettings.shadows = ShadowQuality.Disable;
|
|
}
|
|
else if (currentShadowsQuality == ShadowsQuality.LOW)
|
|
{
|
|
QualitySettings.shadows = ShadowQuality.HardOnly;
|
|
QualitySettings.shadowResolution = ShadowResolution.Low;
|
|
}
|
|
else if (currentShadowsQuality == ShadowsQuality.MEDIUM)
|
|
{
|
|
QualitySettings.shadows = ShadowQuality.HardOnly;
|
|
QualitySettings.shadowResolution = ShadowResolution.Medium;
|
|
}
|
|
else if (currentShadowsQuality == ShadowsQuality.HIGH)
|
|
{
|
|
QualitySettings.shadows = ShadowQuality.All;
|
|
QualitySettings.shadowResolution = ShadowResolution.High;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void RefreshAntialiasing()
|
|
{
|
|
if (!GameController.Instance || !GameController.Instance.fishingPlayer || !GameController.Instance.fishingPlayer.postProcessLayer)
|
|
{
|
|
return;
|
|
}
|
|
GameController.Instance.fishingPlayer.postProcessLayer.antialiasingMode = PostProcessLayer.Antialiasing.TemporalAntialiasing;
|
|
LeanTween.delayedCall(0.1f, (Action)delegate
|
|
{
|
|
if (currentAntialiasing == Antialiasing.NONE)
|
|
{
|
|
GameController.Instance.fishingPlayer.postProcessLayer.antialiasingMode = PostProcessLayer.Antialiasing.None;
|
|
}
|
|
else if (currentAntialiasing == Antialiasing.FXAA)
|
|
{
|
|
GameController.Instance.fishingPlayer.postProcessLayer.antialiasingMode = PostProcessLayer.Antialiasing.FastApproximateAntialiasing;
|
|
}
|
|
else
|
|
{
|
|
GameController.Instance.fishingPlayer.postProcessLayer.antialiasingMode = PostProcessLayer.Antialiasing.TemporalAntialiasing;
|
|
}
|
|
});
|
|
}
|
|
|
|
public QualityDefinition GetQualityDefinition()
|
|
{
|
|
if (VRManager.IsVROn())
|
|
{
|
|
return qualityDefinitionsVR[(int)currentQuality];
|
|
}
|
|
return qualityDefinitions[(int)currentQuality];
|
|
}
|
|
|
|
[Button]
|
|
public void OnSceneChanged()
|
|
{
|
|
birdObjects = MultiTags.FindGameObjectsWithMultiTag("BIRDS");
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
water = GameController.Instance.water;
|
|
}
|
|
else
|
|
{
|
|
water = UnityEngine.Object.FindObjectOfType<Water>();
|
|
}
|
|
if ((bool)water)
|
|
{
|
|
reflectionMask = water.PlanarReflection.ReflectionMask;
|
|
}
|
|
}
|
|
|
|
public void CheckSystemSpecification()
|
|
{
|
|
}
|
|
|
|
public void Save()
|
|
{
|
|
string currentProfilePrefix = GlobalSettings.Instance.saveManager.GetCurrentProfilePrefix();
|
|
using (ES2Writer eS2Writer = ES2Writer.Create(currentProfilePrefix))
|
|
{
|
|
eS2Writer.Write(resolutionWidth, "resolutionWidth");
|
|
eS2Writer.Write(resolutionHeight, "resolutionHeight");
|
|
eS2Writer.Write((int)currentQuality, "currentQuality");
|
|
eS2Writer.Write((int)currentWaterQuality, "currentWaterQuality");
|
|
eS2Writer.Write((int)reflectionQuality, "reflectionQuality");
|
|
eS2Writer.Write((int)currentShadowsQuality, "shadowsQuality");
|
|
eS2Writer.Write((int)currentAntialiasing, "antialiasing");
|
|
eS2Writer.Write(currentTextureQuality, "currentTextureQuality");
|
|
eS2Writer.Write(useWaterRipples, "useWaterRipples");
|
|
eS2Writer.Write(useMotionBlur, "useMotionBlur");
|
|
eS2Writer.Write(useVsync, "useVsync");
|
|
eS2Writer.Write(useAO, "useAO");
|
|
eS2Writer.Write(fov, "fov");
|
|
eS2Writer.Write(underwaterBlur, "underwaterBlur");
|
|
eS2Writer.Write(underwaterDistortion, "underwaterDistortion");
|
|
eS2Writer.Write(blur, "blur");
|
|
eS2Writer.Write(cameraBrightness, "cameraBrightness");
|
|
eS2Writer.Write(cameraContrast, "cameraContrast");
|
|
eS2Writer.Write(cameraGamma, "cameraGamma");
|
|
try
|
|
{
|
|
eS2Writer.Save();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
Debug.LogException(exception, this);
|
|
}
|
|
Debug.Log("Save RenderSettings");
|
|
}
|
|
}
|
|
|
|
public void Load()
|
|
{
|
|
reflectionQuality = ReflectionQuality.FULL;
|
|
Debug.Log("VRAM: " + SystemInfo.graphicsMemorySize);
|
|
if (SystemInfo.graphicsMemorySize < 1000)
|
|
{
|
|
currentQuality = RenderQuality.LOW;
|
|
currentWaterQuality = RenderQuality.LOW;
|
|
currentTextureQuality = 0;
|
|
Debug.Log("VRAM quality: LOW");
|
|
}
|
|
else if (SystemInfo.graphicsMemorySize < 2000)
|
|
{
|
|
currentQuality = RenderQuality.MEDIUM;
|
|
currentWaterQuality = RenderQuality.MEDIUM;
|
|
currentTextureQuality = 1;
|
|
Debug.Log("VRAM quality: MEDIUM");
|
|
}
|
|
else
|
|
{
|
|
currentQuality = RenderQuality.VERY_HIGH;
|
|
currentWaterQuality = RenderQuality.VERY_HIGH;
|
|
currentTextureQuality = 2;
|
|
Debug.Log("VRAM quality: HIGH");
|
|
}
|
|
string currentProfilePrefix = GlobalSettings.Instance.saveManager.GetCurrentProfilePrefix();
|
|
using (ES2Reader eS2Reader = ES2Reader.Create(currentProfilePrefix))
|
|
{
|
|
resolutionWidth = SaveManager.Read(eS2Reader, "resolutionWidth", (!VRManager.IsVROn()) ? Screen.currentResolution.width : 800);
|
|
resolutionHeight = SaveManager.Read(eS2Reader, "resolutionHeight", (!VRManager.IsVROn()) ? Screen.currentResolution.height : 600);
|
|
Debug.Log("resolutionWidth: " + resolutionWidth + " resolutionHeight: " + resolutionHeight);
|
|
if (GlobalSettings.Instance.currentPlatform == GlobalSettings.Platform.ARCADE)
|
|
{
|
|
resolutionWidth = Screen.currentResolution.width;
|
|
resolutionHeight = Screen.currentResolution.height;
|
|
ChangeResolution(resolutionWidth, resolutionHeight, true);
|
|
}
|
|
else if (VRManager.IsVROn() && !eS2Reader.TagExists("resolutionWidth"))
|
|
{
|
|
ChangeResolution(800, 600, false);
|
|
}
|
|
if (resolutionWidth > Screen.width || resolutionHeight > Screen.height)
|
|
{
|
|
Utilities.LogError("Wrong resolution prefs: " + Screen.width + " x " + Screen.height + " (" + resolutionWidth + " x " + resolutionHeight + ")", "red");
|
|
if (resolutionWidth != 0 && resolutionHeight != 0 && resolutionWidth != 1 && resolutionHeight != 1)
|
|
{
|
|
ChangeResolution(resolutionWidth, resolutionHeight, Screen.fullScreen);
|
|
}
|
|
}
|
|
currentQuality = (RenderQuality)SaveManager.Read(eS2Reader, "currentQuality", (int)currentQuality);
|
|
currentWaterQuality = (RenderQuality)SaveManager.Read(eS2Reader, "currentWaterQuality", (int)currentWaterQuality);
|
|
currentTextureQuality = SaveManager.Read(eS2Reader, "currentTextureQuality", currentTextureQuality);
|
|
reflectionQuality = (ReflectionQuality)SaveManager.Read(eS2Reader, "reflectionQuality", (int)reflectionQuality);
|
|
currentShadowsQuality = (ShadowsQuality)SaveManager.Read(eS2Reader, "shadowsQuality", 1);
|
|
currentAntialiasing = (Antialiasing)SaveManager.Read(eS2Reader, "antialiasing", 2);
|
|
useWaterRipples = SaveManager.Read(eS2Reader, "useWaterRipples", true);
|
|
useMotionBlur = SaveManager.Read(eS2Reader, "useMotionBlur", true);
|
|
useVsync = SaveManager.Read(eS2Reader, "useVsync", false);
|
|
useAO = SaveManager.Read(eS2Reader, "useAO", true);
|
|
fov = SaveManager.Read(eS2Reader, "fov", 60f);
|
|
if (fov < 50f || fov > 100f)
|
|
{
|
|
fov = 60f;
|
|
}
|
|
underwaterBlur = SaveManager.Read(eS2Reader, "underwaterBlur", 0.2f);
|
|
underwaterDistortion = SaveManager.Read(eS2Reader, "underwaterDistortion", !VRManager.IsVROn());
|
|
blur = SaveManager.Read(eS2Reader, "blur", 0.625f);
|
|
cameraBrightness = SaveManager.Read(eS2Reader, "cameraBrightness", 0f);
|
|
cameraContrast = SaveManager.Read(eS2Reader, "cameraContrast", 0f);
|
|
cameraGamma = SaveManager.Read(eS2Reader, "cameraGamma", 1f);
|
|
}
|
|
CheckSystemSpecification();
|
|
RefreshAll();
|
|
}
|
|
|
|
public void Reset()
|
|
{
|
|
resolutionWidth = Screen.width;
|
|
resolutionHeight = Screen.height;
|
|
if (GlobalSettings.Instance.currentPlatform == GlobalSettings.Platform.ARCADE)
|
|
{
|
|
resolutionWidth = Screen.currentResolution.width;
|
|
resolutionHeight = Screen.currentResolution.height;
|
|
ChangeResolution(resolutionWidth, resolutionHeight, true);
|
|
}
|
|
else if (VRManager.IsVROn())
|
|
{
|
|
ChangeResolution(800, 600, false);
|
|
}
|
|
if (VRManager.IsVROn())
|
|
{
|
|
currentQuality = RenderQuality.VERY_LOW;
|
|
currentWaterQuality = RenderQuality.MEDIUM;
|
|
currentTextureQuality = 2;
|
|
currentShadowsQuality = ShadowsQuality.LOW;
|
|
Debug.Log("VRAM quality: VR");
|
|
}
|
|
else if (SystemInfo.graphicsMemorySize < 1000)
|
|
{
|
|
currentQuality = RenderQuality.LOW;
|
|
currentWaterQuality = RenderQuality.LOW;
|
|
currentTextureQuality = 0;
|
|
Debug.Log("VRAM quality: LOW");
|
|
}
|
|
else if (SystemInfo.graphicsMemorySize < 2000)
|
|
{
|
|
currentQuality = RenderQuality.MEDIUM;
|
|
currentWaterQuality = RenderQuality.MEDIUM;
|
|
currentTextureQuality = 1;
|
|
Debug.Log("VRAM quality: MEDIUM");
|
|
}
|
|
else
|
|
{
|
|
currentQuality = RenderQuality.VERY_HIGH;
|
|
currentWaterQuality = RenderQuality.VERY_HIGH;
|
|
currentTextureQuality = 2;
|
|
Debug.Log("VRAM quality: HIGH");
|
|
}
|
|
if (VRManager.IsVROn())
|
|
{
|
|
reflectionQuality = ReflectionQuality.SIMPLE;
|
|
}
|
|
else
|
|
{
|
|
reflectionQuality = ReflectionQuality.FULL;
|
|
}
|
|
currentAntialiasing = Antialiasing.TAA;
|
|
useWaterRipples = true;
|
|
useMotionBlur = true;
|
|
useVsync = false;
|
|
useAO = true;
|
|
fov = 60f;
|
|
underwaterBlur = 0.2f;
|
|
underwaterDistortion = !VRManager.IsVROn();
|
|
blur = 0.625f;
|
|
cameraBrightness = 0f;
|
|
cameraContrast = 0f;
|
|
cameraGamma = 1f;
|
|
RefreshAll();
|
|
Save();
|
|
}
|
|
}
|