public override void SetupEntity(MyEffectBase shader, MyRender.MyRenderElement renderElement) { MyEffectAtmosphere effectAtmosphere = shader as MyEffectAtmosphere; effectAtmosphere.SetWorldMatrix((Matrix)renderElement.WorldMatrixForDraw); effectAtmosphere.SetDiffuseColor(renderElement.Color); var atmosphere = renderElement.RenderObject as MyRenderAtmosphere; float depthScale = 0.2f; effectAtmosphere.SetInnerRadius(atmosphere.PlanetRadius); effectAtmosphere.SetOutherRadius(atmosphere.AtmosphereRadius); float scaleAtmosphere = 1.0f / (atmosphere.AtmosphereRadius - atmosphere.PlanetRadius); effectAtmosphere.SetScaleAtmosphere(scaleAtmosphere); effectAtmosphere.SetScaleAtmosphereOverScaleDepth(scaleAtmosphere / depthScale); Vector3 cameraToCenter = atmosphere.GetRelativeCameraPos(MyRenderCamera.Position); effectAtmosphere.SetRelativeCameraPos(cameraToCenter); effectAtmosphere.SetLightPos(-MySunGlare.GetSunDirection()); effectAtmosphere.SetIsInside(atmosphere.IsInside(MyRenderCamera.Position)); effectAtmosphere.SetScaleDepth(depthScale); effectAtmosphere.SetWavelength(atmosphere.AtmosphereWavelengths); }
public static void UpdateScreenSize() { MyMwcLog.WriteLine("MyVideoModeManager.UpdateScreenSize - START"); MyMwcLog.IncreaseIndent(); // Update or reload everything that depends on screen resolution MyMinerGame.UpdateScreenSize(); MyGuiManager.UpdateScreenSize(); MyGuiManager.RecreateMainMenuControls(); MyCamera.UpdateScreenSize(); MyHud.UpdateScreenSize(); MySunGlare.UpdateScreenSize(); if (MyGuiScreenGamePlay.Static != null) { MyGuiScreenGamePlay.Static.UpdateScreenSize(); } CenterizeWindowPosition(); /* * MyRender.CreateRenderTargets(); * MyRender.CreateEnvironmentMapsRT(MyRenderConstants.ENVIRONMENT_MAP_SIZE); */ MyMwcLog.DecreaseIndent(); MyMwcLog.WriteLine("MyVideoModeManager.UpdateScreenSize - END"); }
static void SetupAtmosphere(MyEffectVoxels shader, MyRenderVoxelCellBackground element) { shader.SetHasAtmosphere(element.HasAtmosphere); if (element.HasAtmosphere) { float depthScale = 0.2f; shader.SetInnerRadius(element.PlanetRadius); shader.SetOutherRadius(element.AtmosphereRadius); float scaleAtmosphere = 1.0f / (element.AtmosphereRadius - element.PlanetRadius); shader.SetScaleAtmosphere(scaleAtmosphere); shader.SetScaleAtmosphereOverScaleDepth(scaleAtmosphere / depthScale); Vector3 cameraToCenter = element.GetRelativeCameraPos(MyRenderCamera.Position); shader.SetRelativeCameraPos(cameraToCenter); shader.SetLightPos(-MySunGlare.GetSunDirection()); shader.SetIsInside(element.IsInside(MyRenderCamera.Position)); shader.SetScaleDepth(depthScale); shader.SetPositonToLeftBottomOffset(element.PositiontoLeftBottomOffset); shader.SetWavelength(element.AtmosphereWavelengths); } }
/// <summary> /// Load graphics resources content. /// </summary> public override void LoadContent() { int block1 = -1; MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMinerGame::LoadContent", ref block1); base.LoadContent(); DefaultSurface = MyMinerGame.Static.GraphicsDevice.GetRenderTarget(0); DefaultSurface.DebugName = "DefaultSurface"; DefaultDepth = MyMinerGame.Static.GraphicsDevice.DepthStencilSurface; DefaultDepth.DebugName = "DefaultDepth"; MyMwcLog.WriteLine("MyMinerGame.LoadContent() - START"); MyMwcLog.IncreaseIndent(); MyVideoModeManager.UpdateScreenSize(); System.Drawing.Font systemfont = new System.Drawing.Font("Tahoma", 12f, FontStyle.Regular); m_debugFont = new SharpDX.Direct3D9.Font(GraphicsDevice, systemfont); // GUI MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyGuiManager.LoadContent()"); MyGuiManager.LoadContent(); // Models MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyModels.LoadContent()"); MyModels.LoadContent(); // Render MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyRender.LoadContent();"); MyRender.LoadContent(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyDebugDraw.LoadContent();"); MyDebugDraw.LoadContent(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MyDebugDrawCachedLines.LoadContent()"); MyDebugDrawCachedLines.LoadContent(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartNextBlock("MySunGlare.LoadContent()"); MySunGlare.LoadContent(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); MyMwcLog.DecreaseIndent(); MyMwcLog.WriteLine("MyMinerGame.LoadContent() - END"); GC.Collect(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(block1); }
/// <summary> /// Called when graphics resources need to be unloaded. Override this method to unload any game-specific graphics resources. /// </summary> public override void UnloadContent() { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMinerGame::UnloadContent"); MyMwcLog.WriteLine("MyMinerGame.UnloadContent() - START"); MyMwcLog.IncreaseIndent(); if (m_debugFont != null) { m_debugFont.Dispose(); m_debugFont = null; } if (DefaultSurface != null) { DefaultSurface.Dispose(); DefaultSurface = null; } if (DefaultDepth != null) { DefaultDepth.Dispose(); DefaultDepth = null; } // GUI MyGuiManager.UnloadContent(); MyRender.UnloadContent(); MyTextureManager.UnloadContent(); MyModels.UnloadContent(); // Global content //Content.Unload(); // Render MySunGlare.UnloadContent(); MyDebugDrawCachedLines.UnloadContent(); MyDebugDraw.UnloadContent(); //MyRender.UnloadContent(); //it is unloaded in gui gameplay screen MyMwcLog.DecreaseIndent(); MyMwcLog.WriteLine("MyMinerGame.UnloadContent() - END"); GraphicsDevice.SetStreamSource(0, null, 0, 0); GraphicsDevice.Indices = null; GraphicsDevice.VertexDeclaration = null; GraphicsDevice.PixelShader = null; GraphicsDevice.VertexShader = null; for (int i = 0; i < 16; i++) { GraphicsDevice.SetTexture(i, null); } base.UnloadContent(); GC.Collect(); MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); }