internal static void DrawDebugHDRRenderTargets() { BlendState.Opaque.Apply(); // All RT should be of same size, so for size we can use any of them we just pick up depthRT float renderTargetAspectRatio = (float)MyCamera.Viewport.Width / (float)MyCamera.Viewport.Height; float normalizedSizeY = 0.40f; float normalizedSizeX = normalizedSizeY * renderTargetAspectRatio; MyMwcVector2Int delta = new MyMwcVector2Int((int)(MyCamera.Viewport.Height * 0.015f), (int)(MyCamera.Viewport.Height * 0.015f)); MyMwcVector2Int size = new MyMwcVector2Int((int)(MyCamera.Viewport.Height * normalizedSizeX), (int)(MyCamera.Viewport.Height * normalizedSizeY)); //MyGuiManager.DrawSpriteFast(MyRender.GetRenderTarget(MyRenderTargets.Diffuse), delta.X, delta.Y, size.X, size.Y, Color.White); //MyGuiManager.DrawSpriteFast(MyRender.GetRenderTarget(MyRenderTargets.Normals), delta.X + size.X + delta.X, delta.Y, size.X, size.Y, Color.White); }
public static void UpdateScreenSize() { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMinerGame::UpdateScreenSize"); ScreenSize = new MyMwcVector2Int((int)MyMinerGame.Static.GraphicsDevice.Viewport.Width, (int)MyMinerGame.Static.GraphicsDevice.Viewport.Height); ScreenSizeHalf = new MyMwcVector2Int(ScreenSize.X / 2, ScreenSize.Y / 2); if (MyGuiManager.GetScreenshot() != null) { ScreenSize.X = (int)(ScreenSize.X * MyGuiManager.GetScreenshot().SizeMultiplier); ScreenSize.Y = (int)(ScreenSize.Y * MyGuiManager.GetScreenshot().SizeMultiplier); ScreenSizeHalf = new MyMwcVector2Int(ScreenSize.X / 2, ScreenSize.Y / 2); } MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); }
internal static void DrawDebugBlendedRenderTargets() { BlendState.Opaque.Apply(); // All RT should be of same size, so for size we can use any of them we just pick up depthRT float renderTargetAspectRatio = (float)MyCamera.Viewport.Width / (float)MyCamera.Viewport.Height; float normalizedSizeY = 0.40f; //float normalizedSizeY = MyCamera.Viewport.Height / 1920f; float normalizedSizeX = normalizedSizeY * renderTargetAspectRatio; MyMwcVector2Int delta = new MyMwcVector2Int((int)(MyCamera.Viewport.Height * 0.015f), (int)(MyCamera.Viewport.Height * 0.015f)); MyMwcVector2Int size = new MyMwcVector2Int((int)(MyCamera.Viewport.Height * normalizedSizeX), (int)(MyCamera.Viewport.Height * normalizedSizeY)); MyGuiManager.DrawSpriteFast(MyRender.GetRenderTarget(MyRenderTargets.Diffuse), delta.X, delta.Y, size.X, size.Y, Color.White); MyGuiManager.DrawSpriteFast(MyRender.GetRenderTarget(MyRenderTargets.Normals), delta.X + size.X + delta.X, delta.Y, size.X, size.Y, Color.White); }
internal static void DrawDebugEnvironmentRenderTargets() { BlendState.Opaque.Apply(); int cubeSize = GetRenderTargetCube(MyRenderTargets.EnvironmentCube).GetLevelDescription(0).Width; cubeSize = 128; MyMwcVector2Int delta = new MyMwcVector2Int((int)(MyCamera.Viewport.Height * 0.07f), (int)(MyCamera.Viewport.Height * 0.015f)); MyMwcVector2Int size = new MyMwcVector2Int(cubeSize, cubeSize); int heightOffset = size.Y + delta.Y; for (int i = 0; i < 6; i++) { //var back = MyTextureManager.GetTexture<MyTextureCube>("Textures\\BackgroundCube\\Final\\TestCube", null, MinerWars.AppCode.Game.Managers.LoadingMode.Immediate); MyGuiManager.DrawSpriteFast(GetRenderTargetCube(MyRenderTargets.EnvironmentCube), (CubeMapFace)i, delta.X + size.X * i, delta.Y, size.X, size.Y, Color.White); MyGuiManager.DrawSpriteFast(GetRenderTargetCube(MyRenderTargets.EnvironmentCubeAux), (CubeMapFace)i, delta.X + size.X * i, delta.Y + heightOffset, size.X, size.Y, Color.White); MyGuiManager.DrawSpriteFast(GetRenderTargetCube(MyRenderTargets.AmbientCube), (CubeMapFace)i, delta.X + size.X * i, delta.Y + heightOffset * 2, size.X, size.Y, Color.White); MyGuiManager.DrawSpriteFast(GetRenderTargetCube(MyRenderTargets.AmbientCubeAux), (CubeMapFace)i, delta.X + size.X * i, delta.Y + heightOffset * 3, size.X, size.Y, Color.White); } }
internal static void DrawDebugEnvironmentRenderTargets() { BlendState.Opaque.Apply(); int cubeSize = GetRenderTargetCube(MyRenderTargets.EnvironmentCube).GetLevelDescription(0).Width; cubeSize = 128; MyMwcVector2Int delta = new MyMwcVector2Int((int)(MyCamera.Viewport.Height * 0.07f), (int)(MyCamera.Viewport.Height * 0.015f)); MyMwcVector2Int size = new MyMwcVector2Int(cubeSize, cubeSize); int heightOffset = size.Y + delta.Y; for (int i = 0; i < 6; i++) { //var back = MyTextureManager.GetTexture<MyTextureCube>("Textures\\BackgroundCube\\Final\\TestCube", null, MinerWars.AppCode.Game.Managers.LoadingMode.Immediate); MyGuiManager.DrawSpriteFast(GetRenderTargetCube(MyRenderTargets.EnvironmentCube), (CubeMapFace)i, delta.X + size.X * i, delta.Y, size.X, size.Y, Color.White); MyGuiManager.DrawSpriteFast(GetRenderTargetCube(MyRenderTargets.EnvironmentCubeAux), (CubeMapFace)i, delta.X + size.X * i, delta.Y + heightOffset, size.X, size.Y, Color.White); MyGuiManager.DrawSpriteFast(GetRenderTargetCube(MyRenderTargets.AmbientCube), (CubeMapFace)i, delta.X + size.X * i, delta.Y + heightOffset * 2, size.X, size.Y, Color.White); MyGuiManager.DrawSpriteFast(GetRenderTargetCube(MyRenderTargets.AmbientCubeAux), (CubeMapFace)i, delta.X + size.X * i, delta.Y + heightOffset * 3, size.X, size.Y, Color.White); } }
public static void UpdateScreenSize() { MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyMinerGame::UpdateScreenSize"); ScreenSize = new MyMwcVector2Int((int)MyMinerGame.Static.GraphicsDevice.Viewport.Width, (int)MyMinerGame.Static.GraphicsDevice.Viewport.Height); ScreenSizeHalf = new MyMwcVector2Int(ScreenSize.X / 2, ScreenSize.Y / 2); if (MyGuiManager.GetScreenshot() != null) { ScreenSize.X = (int)(ScreenSize.X * MyGuiManager.GetScreenshot().SizeMultiplier); ScreenSize.Y = (int)(ScreenSize.Y * MyGuiManager.GetScreenshot().SizeMultiplier); ScreenSizeHalf = new MyMwcVector2Int(ScreenSize.X / 2, ScreenSize.Y / 2); } MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock(); }
// Return picture size that is safe for displaying in bounding area and doesn't distort the aspect ratio of original picture or bounding area. // Example: picture of video frame is scaled to size of screen, so it fits it as much as possible, but still maintains aspect ration of // original video frame or screen. So if screen's heigh is not enouch, video frame is scaled down to fit height, but also width is scaled // according to original video frame. // It's used whenever we need to scale picture/texture to some area, usually to screen size. // Also this method calculated left/top coordinates, so it's always centered. static void GetSafeAspectRatioPictureSize(MyMwcVector2Int originalSize, Rectangle boundingArea, out Rectangle outRect) { outRect.Width = boundingArea.Width; outRect.Height = (int)(((float)outRect.Width / (float)originalSize.X) * originalSize.Y); if (outRect.Height > boundingArea.Height) { outRect.Height = boundingArea.Height; outRect.Width = (int)(outRect.Height * ((float)originalSize.X / (float)originalSize.Y)); } outRect.X = boundingArea.Left + (boundingArea.Width - outRect.Width) / 2; outRect.Y = boundingArea.Top + (boundingArea.Height - outRect.Height) / 2; }
// This method scales picture to bounding area according to bounding area's height. We don't care about width, so sometimes if picture has wide // aspect ratio, borders of image may be outisde of the bounding area. This method is used when we want to have picture covering whole screen // and don't care if part of picture is invisible. Also, aspect ration is unchanged too. static void GetSafeHeightPictureSize(MyMwcVector2Int originalSize, Rectangle boundingArea, out Rectangle outRect) { outRect.Height = boundingArea.Height; outRect.Width = (int)(((float)outRect.Height / (float)originalSize.Y) * originalSize.X); outRect.X = boundingArea.Left + (boundingArea.Width - outRect.Width) / 2; outRect.Y = boundingArea.Top + (boundingArea.Height - outRect.Height) / 2; }
public static void GetSafeAspectRatioFullScreenPictureSize(MyMwcVector2Int originalSize, out Rectangle outRect) { GetSafeAspectRatioPictureSize(originalSize, m_safeFullscreenRectangle, out outRect); }