protected override void ValueChanged(MyGuiControlBase sender) { var settings = new MyRenderFogSettings() { FogMultiplier = MySector.FogProperties.FogMultiplier, FogColor = MySector.FogProperties.FogColor, FogDensity = MySector.FogProperties.FogDensity }; MyRenderProxy.UpdateFogSettings(ref settings); MyRenderProxy.SetSettingsDirty(); }
public override bool Draw() { VRageRender.MyRenderProxy.GetRenderProfiler().StartProfilingBlock("MyGuiScreenGamePlay::Draw"); //VRageRender.MyRenderProxy.DebugDrawSphere( // new Vector3D(-60.7171351205786, 34.002275028352, 78.131769977211), // 0.02f, // Vector3.One, // 1, true, true); //VRageRender.MyRenderProxy.DebugDrawSphere( // new Vector3(-13.36391f, -1.974166f, -35.97278f), // 0.2f, // Vector3.One, // 1, true, true); //Vector3 target = new Vector3(-83.87779f, -62.17611f, -127.3294f); //Vector3 pos = new Vector3(-87.42791f, -57.17604f, -139.3147f); //VRageRender.MyRenderProxy.DebugDrawLine3D( // target, pos, Color.Green, Color.Yellow, false); //if (MyCubeBuilder.Static.CurrentGrid != null) //{ // Matrix m = MyCubeBuilder.Static.CurrentGrid.WorldMatrix; // m.Translation = MySession.Static.ControlledObject.WorldMatrix.Translation; // VRageRender.MyRenderProxy.DebugDrawAxis(m, 1, false); //} if (MySector.MainCamera != null) { // set new camera values MySession.Static.CameraController.ControlCamera(MySector.MainCamera); // update camera properties accordingly to the new settings - zoom, spring, shaking... MySector.MainCamera.Update(MyEngineConstants.UPDATE_STEP_SIZE_IN_SECONDS); // upload to renderer MySector.MainCamera.UploadViewMatrixToRender(); } MyRenderProxy.UpdateGameplayFrame(MySession.Static.GameplayFrameCounter); MyRenderFogSettings fogSettings = new MyRenderFogSettings() { FogMultiplier = MySector.FogProperties.FogMultiplier, FogColor = MySector.FogProperties.FogColor, FogDensity = MySector.FogProperties.FogDensity / 100.0f }; VRageRender.MyRenderProxy.UpdateFogSettings(ref fogSettings); MyRenderProxy.UpdateSSAOSettings(ref MySector.SSAOSettings); MyRenderProxy.UpdateHBAOSettings(MySector.HBAOSettings); var gravityProviders = Sandbox.Game.GameSystems.MyGravityProviderSystem.NaturalGravityProviders; float planetFactor = 0; Vector3D cameraPos = MySector.MainCamera.WorldMatrix.Translation; foreach (var gravityProvider in gravityProviders) { var planet = gravityProvider as MyPlanet; if (planet != null) { if (planet.HasAtmosphere) { double distanceToPlanet = (planet.WorldMatrix.Translation - cameraPos).Length(); float t = ((float)distanceToPlanet - planet.AverageRadius) / (planet.AtmosphereRadius - planet.AverageRadius); if (t < 1.0f) { planetFactor = 1.0f - MathHelper.Clamp(t, 0f, 1f); // Dark side intensity hack //float sunDot = sunDirection.Dot(Vector3D.Normalize(planet.WorldMatrix.Translation - cameraPos)); // //if(sunDot < 0f // && planetFactor > 0.8f) //{ // float planetInfluence = 1.0f - MathHelper.Clamp((planetFactor - 0.8f) / 0.15f, 0.0f, 1.0f); // float positionInfluence = MathHelper.Clamp(1.0f + sunDot / 0.1f, 0f, 1f); // MySector.SunProperties.SunIntensity = MathHelper.Clamp(planetInfluence + positionInfluence, 0.0f, 1.0f) * MyDefinitionManager.Static.EnvironmentDefinition.SunProperties.SunIntensity; //} //else //{ // MySector.SunProperties.SunIntensity = MyDefinitionManager.Static.EnvironmentDefinition.SunProperties.SunIntensity; //} break; } } } } var envData = MySector.SunProperties.EnvironmentData; envData.Skybox = MySession.Static.CustomSkybox != null && MySession.Static.CustomSkybox.Length > 0 ? MySession.Static.CustomSkybox : MySector.EnvironmentDefinition.EnvironmentTexture; envData.SkyboxOrientation = MySector.EnvironmentDefinition.EnvironmentOrientation.ToQuaternion(); envData.EnvironmentLight.SunLightDirection = -MySector.SunProperties.SunDirectionNormalized; MyEnvironmentLightData.CalculateBackLightDirections(envData.EnvironmentLight.SunLightDirection, MySector.SunRotationAxis, out envData.EnvironmentLight.BackLightDirection1, out envData.EnvironmentLight.BackLightDirection2); envData.PlanetFactor = planetFactor; envData.SunBillboardEnabled = MyFakes.ENABLE_SUN_BILLBOARD; VRageRender.MyRenderProxy.UpdateRenderEnvironment(ref envData, MySector.ResetEyeAdaptation); MySector.ResetEyeAdaptation = false; VRageRender.MyRenderProxy.UpdateEnvironmentMap(); var postprocessedSettings = MyPostprocessSettings.LerpExposure(ref MyPostprocessSettingsWrapper.Settings, ref MyPostprocessSettingsWrapper.PlanetSettings, planetFactor); MyRenderProxy.SwitchPostprocessSettings(ref postprocessedSettings); if (MyRenderProxy.SettingsDirty) MyRenderProxy.SwitchRenderSettings(MyRenderProxy.Settings); VRageRender.MyRenderProxy.GetRenderProfiler().StartNextBlock("Main render"); VRageRender.MyRenderProxy.Draw3DScene(); using (Stats.Generic.Measure("GamePrepareDraw")) { if (MySession.Static != null) MySession.Static.Draw(); } VRageRender.MyRenderProxy.GetRenderProfiler().StartNextBlock("Draw HUD"); if (MySession.Static.ControlledEntity != null && MySession.Static.CameraController != null) MySession.Static.ControlledEntity.DrawHud(MySession.Static.CameraController, MySession.Static.LocalPlayerId); VRageRender.MyRenderProxy.GetRenderProfiler().StartNextBlock("FillDebugScreen"); //FillDebugScreen(); VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); if (MySandboxGame.IsPaused && !MyHud.MinimalHud) DrawPauseIndicator(); return true; }
public static void UpdateFogSettings( ref MyRenderFogSettings settings ) { var message = MessagePool.Get<MyRenderMessageUpdateFogSettings>(MyRenderMessageEnum.UpdateFogSettings); message.Settings = settings; EnqueueMessage(message); }