private void ApplyProperties() { WaterQuality waterQuality = Properties.Instance.WaterQuality; switch (waterQuality) { case WaterQuality.Simple: simpleWaterToggle.isOn = true; break; case WaterQuality.High: highWaterToggle.isOn = true; break; case WaterQuality.Ultra: ultraWaterToggle.isOn = true; break; } overallQualityDropdown.value = QualitySettings.GetQualityLevel(); guiScaleSlider.value = Properties.Instance.GuiScale; }
void Update() { if (gSettings != null) { string wQual = gSettings.waterQuality; if (wQual == "High" || wQual == "Very High") { waterQuality = WaterQuality.High; } else if (wQual == "Medium") { waterQuality = WaterQuality.Medium; } else { waterQuality = WaterQuality.Low; } } if (sharedMaterial != null) { UpdateShader(); } }
private Properties() { WaterQuality = WaterDefaultQuality; }
public static void SetWaterQuality(GameManager gameManager, int value) { CurrentWaterQuality = (WaterQuality)value; gameManager.World.WaterController.waterQuality = CurrentWaterQuality; PlayerPrefs.SetInt("WaterQuality", value); }
private void RenderToRefractionRenderTarget(BaseCamera camera, Vector4 clipPlane, WaterQuality quality) { GL.Enable(EnableCap.StencilTest); // Enable stencil test GL.DepthMask(false); // Disable write depth GL.ColorMask(false, false, false, false); // Disable write color GL.StencilFunc(StencilFunction.Always, 2, 0xFF); // Write 2 to stencil GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Replace); // Replace when depth test pass GL.StencilMask(0xFF); // Write to stencil GL.Clear(ClearBufferMask.StencilBufferBit); // Clear stencil buffer // prepass for stencil only GameWorld.GetWorldInstance().GetLevel().Water.GetData().StencilPass(camera, ref EngineStatics.ProjectionMatrix); GL.DepthMask(true); // Enable write depth GL.ColorMask(true, true, true, true); // Enable write color GL.StencilFunc(StencilFunction.Equal, 2, 0xFF); // Set stencil function GL.StencilMask(0x00); GL.StencilOp(StencilOp.Keep, StencilOp.Keep, StencilOp.Keep); // Set stencil operation /*TO DO : true - enable EngineSingleton.Grass refractions * false - disable EngineSingleton.Grass refractions*/ if (quality.EnableGrassRefraction) { if (GameWorld.GetWorldInstance().GetLevel().Grass != null) { GameWorld.GetWorldInstance().GetLevel().Grass.renderEntities(GameWorld.GetWorldInstance().GetLevel().DirectionalLight, camera, EngineStatics.ProjectionMatrix, GameWorld.GetWorldInstance().GetLevel().Terrain.GetData(), clipPlane); } if (GameWorld.GetWorldInstance().GetLevel().Plant != null) { GameWorld.GetWorldInstance().GetLevel().Plant.renderEntities(GameWorld.GetWorldInstance().GetLevel().DirectionalLight, camera, EngineStatics.ProjectionMatrix, GameWorld.GetWorldInstance().GetLevel().Terrain.GetData(), clipPlane); } } /*TO DO : true - enable building refractions * false - disable building refractions*/ if (quality.EnableBuilding) { if (GameWorld.GetWorldInstance().GetLevel().StaticMeshCollection != null) { foreach (Building house in GameWorld.GetWorldInstance().GetLevel().StaticMeshCollection) { house.RenderWaterRefraction(GameWorld.GetWorldInstance().GetLevel().DirectionalLight, camera, ref EngineStatics.ProjectionMatrix, clipPlane); } } } /*TO DO : true - enable EngineSingleton.Player and EngineSingleton.Enemy refractions * false - disable EngineSingleton.Player and EngineSingleton.Enemy refractions*/ if (quality.EnableMovableEntities) { if (GameWorld.GetWorldInstance().GetLevel().Player.GetData() != null) { if (GameWorld.GetWorldInstance().GetLevel().Player.GetData().IsVisibleByCamera) { GameWorld.GetWorldInstance().GetLevel().Player.GetData().RenderWaterRefraction(GameWorld.GetWorldInstance().GetLevel().DirectionalLight, camera, ref EngineStatics.ProjectionMatrix, clipPlane); } } if (GameWorld.GetWorldInstance().GetLevel().Bots != null) { foreach (var bot in GameWorld.GetWorldInstance().GetLevel().Bots) { if (bot.IsVisibleByCamera) { bot.RenderWaterRefraction(GameWorld.GetWorldInstance().GetLevel().DirectionalLight, camera, ref EngineStatics.ProjectionMatrix, clipPlane); } } } } /*TO DO : * Culling back faces of terrain, cause they don't refract in EngineSingleton.Water*/ GL.Enable(EnableCap.CullFace); GL.CullFace(CullFaceMode.Back); if (GameWorld.GetWorldInstance().GetLevel().Terrain.GetData() != null) { GameWorld.GetWorldInstance().GetLevel().Terrain.GetData().RenderWaterRefraction(GameWorld.GetWorldInstance().GetLevel().DirectionalLight, camera, ref EngineStatics.ProjectionMatrix, clipPlane); } GL.Disable(EnableCap.CullFace); GL.Disable(EnableCap.StencilTest); // Enable stencil test }