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.ControlledObject.WorldMatrix.Translation; // VRageRender.MyRenderProxy.DebugDrawAxis(m, 1, false); //} MatrixD viewMatrix = MySession.Static.CameraController.GetViewMatrix(); if (viewMatrix.IsValid() && viewMatrix != MatrixD.Zero) { MySector.MainCamera.SetViewMatrix(viewMatrix); } else { Debug.Fail("Camera matrix is invalid or zero!"); } VRageRender.MyRenderProxy.UpdateGodRaysSettings( MySector.GodRaysProperties.Enabled, MySector.GodRaysProperties.Density, MySector.GodRaysProperties.Weight, MySector.GodRaysProperties.Decay, MySector.GodRaysProperties.Exposition, false ); VRageRender.MyRenderProxy.UpdateAntiAliasSettings( MyPostProcessAntiAlias.Enabled ); VRageRender.MyRenderProxy.UpdateVignettingSettings( MyPostProcessVignetting.Enabled, MyPostProcessVignetting.VignettingPower ); VRageRender.MyRenderProxy.UpdateColorMappingSettings( MyPostProcessColorMapping.Enabled ); VRageRender.MyRenderProxy.UpdateChromaticAberrationSettings( MyPostProcessChromaticAberration.Enabled, MyPostProcessChromaticAberration.DistortionLens, MyPostProcessChromaticAberration.DistortionCubic, new Vector3(MyPostProcessChromaticAberration.DistortionWeightRed, MyPostProcessChromaticAberration.DistortionWeightGreen, MyPostProcessChromaticAberration.DistortionWeightBlue) ); VRageRender.MyRenderProxy.UpdateContrastSettings( MyPostProcessContrast.Enabled, MyPostProcessContrast.Contrast, MyPostProcessContrast.Hue, MyPostProcessContrast.Saturation ); VRageRender.MyRenderFogSettings fogSettings = new VRageRender.MyRenderFogSettings() { Enabled = MySector.FogProperties.EnableFog, FogNear = MySector.FogProperties.FogNear, FogFar = MySector.FogProperties.FogFar, FogMultiplier = MySector.FogProperties.FogMultiplier, FogBacklightMultiplier = MySector.FogProperties.FogBacklightMultiplier, FogColor = MySector.FogProperties.FogColor, FogDensity = MySector.FogProperties.FogDensity }; VRageRender.MyRenderProxy.UpdateFogSettings(ref fogSettings); VRageRender.MyRenderProxy.UpdateHDRSettings( MyPostProcessHDR.DebugHDRChecked, MyPostProcessHDR.Exposure, MyPostProcessHDR.Threshold, MyPostProcessHDR.BloomIntensity, MyPostProcessHDR.BloomIntensityBackground, MyPostProcessHDR.VerticalBlurAmount, MyPostProcessHDR.HorizontalBlurAmount, (int)MyPostProcessHDR.NumberOfBlurPasses ); VRageRender.MyRenderProxy.UpdateSSAOSettings( MyPostProcessVolumetricSSAO2.Enabled, MyPostProcessVolumetricSSAO2.ShowOnlySSAO, MyPostProcessVolumetricSSAO2.UseBlur, MyPostProcessVolumetricSSAO2.MinRadius, MyPostProcessVolumetricSSAO2.MaxRadius, MyPostProcessVolumetricSSAO2.RadiusGrowZScale, MyPostProcessVolumetricSSAO2.CameraZFarScale * MySector.MainCamera.FarPlaneDistance, MyPostProcessVolumetricSSAO2.Bias, MyPostProcessVolumetricSSAO2.Falloff, MyPostProcessVolumetricSSAO2.NormValue, MyPostProcessVolumetricSSAO2.Contrast ); Vector3 sunDirection = -MySector.SunProperties.SunDirectionNormalized; if (MySession.Static.Settings.EnableSunRotation) { float angle = 2.0f * MathHelper.Pi * (float)(MySession.Static.ElapsedGameTime.TotalMinutes / MySession.Static.Settings.SunRotationIntervalMinutes); float originalSunCosAngle = Math.Abs(Vector3.Dot(sunDirection, Vector3.Up)); Vector3 sunRotationAxis; if (originalSunCosAngle > 0.95f) { // original sun is too close to the poles sunRotationAxis = Vector3.Cross(Vector3.Cross(sunDirection, Vector3.Left), sunDirection); } else { sunRotationAxis = Vector3.Cross(Vector3.Cross(sunDirection, Vector3.Up), sunDirection); } sunDirection = Vector3.Transform(sunDirection, Matrix.CreateFromAxisAngle(sunRotationAxis, angle)); sunDirection.Normalize(); MySector.DirectionToSunNormalized = -sunDirection; } VRageRender.MyRenderProxy.UpdateRenderEnvironment( sunDirection, MySector.SunProperties.SunDiffuse, MySector.SunProperties.BackSunDiffuse, MySector.SunProperties.SunSpecular, MySector.SunProperties.SunIntensity, MySector.SunProperties.BackSunIntensity, true, MySector.SunProperties.AmbientColor, MySector.SunProperties.AmbientMultiplier, MySector.SunProperties.EnvironmentAmbientIntensity, MySector.SunProperties.BackgroundColor, MySector.BackgroundTexture, MySector.BackgroundOrientation, MySector.SunProperties.SunSizeMultiplier, MySector.DistanceToSun, MySector.SunProperties.SunMaterial, MySector.DayTime, MySector.ResetEyeAdaptation, MyFakes.ENABLE_SUN_BILLBOARD ); MySector.ResetEyeAdaptation = false; VRageRender.MyRenderProxy.UpdateEnvironmentMap(); VRageRender.MyRenderProxy.SwitchProsprocessSettings(MyPostprocessSettingsWrapper.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.ControlledEntity != null && MySession.Static.CameraController != null) { MySession.ControlledEntity.DrawHud(MySession.Static.CameraController, MySession.LocalPlayerId); } VRageRender.MyRenderProxy.GetRenderProfiler().StartNextBlock("FillDebugScreen"); //FillDebugScreen(); VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); if (MySandboxGame.IsPaused && !MyHud.MinimalHud) { DrawPauseIndicator(); } return(true); }
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.ControlledObject.WorldMatrix.Translation; // VRageRender.MyRenderProxy.DebugDrawAxis(m, 1, false); //} MySector.MainCamera.SetViewMatrix(MySession.Static.CameraController.GetViewMatrix()); VRageRender.MyRenderProxy.UpdateGodRaysSettings( MySector.GodRaysProperties.Enabled, MySector.GodRaysProperties.Density, MySector.GodRaysProperties.Weight, MySector.GodRaysProperties.Decay, MySector.GodRaysProperties.Exposition, false ); VRageRender.MyRenderProxy.UpdateAntiAliasSettings( MyPostProcessAntiAlias.Enabled ); VRageRender.MyRenderProxy.UpdateVignettingSettings( MyPostProcessVignetting.Enabled, MyPostProcessVignetting.VignettingPower ); VRageRender.MyRenderProxy.UpdateColorMappingSettings( MyPostProcessColorMapping.Enabled ); VRageRender.MyRenderProxy.UpdateChromaticAberrationSettings( MyPostProcessChromaticAberration.Enabled, MyPostProcessChromaticAberration.DistortionLens, MyPostProcessChromaticAberration.DistortionCubic, new Vector3(MyPostProcessChromaticAberration.DistortionWeightRed, MyPostProcessChromaticAberration.DistortionWeightGreen, MyPostProcessChromaticAberration.DistortionWeightBlue) ); VRageRender.MyRenderProxy.UpdateContrastSettings( MyPostProcessContrast.Enabled, MyPostProcessContrast.Contrast, MyPostProcessContrast.Hue, MyPostProcessContrast.Saturation ); VRageRender.MyRenderFogSettings fogSettings = new VRageRender.MyRenderFogSettings() { Enabled = MySector.FogProperties.EnableFog, FogNear = MySector.FogProperties.FogNear, FogFar = MySector.FogProperties.FogFar, FogMultiplier = MySector.FogProperties.FogMultiplier, FogBacklightMultiplier = MySector.FogProperties.FogBacklightMultiplier, FogColor = MySector.FogProperties.FogColor, FogDensity = MySector.FogProperties.FogDensity }; VRageRender.MyRenderProxy.UpdateFogSettings(ref fogSettings); VRageRender.MyRenderProxy.UpdateHDRSettings( MyPostProcessHDR.DebugHDRChecked, MyPostProcessHDR.Exposure, MyPostProcessHDR.Threshold, MyPostProcessHDR.BloomIntensity, MyPostProcessHDR.BloomIntensityBackground, MyPostProcessHDR.VerticalBlurAmount, MyPostProcessHDR.HorizontalBlurAmount, (int)MyPostProcessHDR.NumberOfBlurPasses ); VRageRender.MyRenderProxy.UpdateSSAOSettings( MyPostProcessVolumetricSSAO2.Enabled, MyPostProcessVolumetricSSAO2.ShowOnlySSAO, MyPostProcessVolumetricSSAO2.UseBlur, MyPostProcessVolumetricSSAO2.MinRadius, MyPostProcessVolumetricSSAO2.MaxRadius, MyPostProcessVolumetricSSAO2.RadiusGrowZScale, MyPostProcessVolumetricSSAO2.CameraZFarScale * MySector.MainCamera.FarPlaneDistance, MyPostProcessVolumetricSSAO2.Bias, MyPostProcessVolumetricSSAO2.Falloff, MyPostProcessVolumetricSSAO2.NormValue, MyPostProcessVolumetricSSAO2.Contrast ); VRageRender.MyRenderProxy.UpdateRenderEnvironment( -MySector.DirectionToSunNormalized, MySector.SunProperties.SunDiffuse, MySector.SunProperties.BackSunDiffuse, MySector.SunProperties.SunSpecular, MySector.SunProperties.SunIntensity, MySector.SunProperties.BackSunIntensity, true, MySector.SunProperties.AmbientColor, MySector.SunProperties.AmbientMultiplier, MySector.SunProperties.EnvironmentAmbientIntensity, MySector.SunProperties.BackgroundColor, MySector.BackgroundTexture, MySector.BackgroundOrientation, MySector.SunProperties.SunSizeMultiplier, MySector.DistanceToSun, MySector.SunProperties.SunMaterial, MySector.DayTime, MySector.ResetEyeAdaptation ); MySector.ResetEyeAdaptation = false; VRageRender.MyRenderProxy.UpdateEnvironmentMap(); VRageRender.MyRenderProxy.SwitchProsprocessSettings(MyPostprocessSettingsWrapper.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.ControlledEntity != null && MySession.Static.CameraController != null) MySession.ControlledEntity.DrawHud(MySession.Static.CameraController, MySession.LocalPlayerId); VRageRender.MyRenderProxy.GetRenderProfiler().StartNextBlock("FillDebugScreen"); //FillDebugScreen(); VRageRender.MyRenderProxy.GetRenderProfiler().EndProfilingBlock(); if (MySandboxGame.IsPaused && !MyHud.MinimalHud) DrawPauseIndicator(); return true; }