public void Render()
        {
            Texture cameraRT = MyRender.GetRenderTarget(MyRenderTargets.SecondaryCamera);

            m_setup.RenderTargets[0] = cameraRT;

            //SetRenderSetup();

            // Adjust render setup
            m_setup.AspectRatio    = cameraRT.GetLevelDescription(0).Width / (float)cameraRT.GetLevelDescription(0).Height;
            m_setup.Viewport       = new Viewport(0, 0, cameraRT.GetLevelDescription(0).Width, cameraRT.GetLevelDescription(0).Height);
            m_setup.ViewMatrix     = ViewMatrix;
            m_setup.CameraPosition = ViewMatrix.Translation;
            m_setup.Fov            = MathHelper.ToRadians(MySecondaryCameraConstants.FIELD_OF_VIEW);

            m_setup.ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(m_setup.Fov.Value,
                                                                           m_setup.AspectRatio.Value,
                                                                           MySecondaryCameraConstants.NEAR_PLANE_DISTANCE,
                                                                           //m_setup.LodTransitionBackgroundEnd.Value);
                                                                           MyCamera.FAR_PLANE_DISTANCE);
            ProjectionMatrix  = m_setup.ProjectionMatrix.Value;
            MyCamera.Viewport = m_setup.Viewport.Value;

            // render to fullsize texture
            MyRender.PushRenderSetupAndApply(m_setup, ref m_backup);
            MyRender.Draw(false);
            MyRender.PopRenderSetupAndRevert(m_backup);

            //MySession.PlayerShip.Weapons.Visible = true;
        }
예제 #2
0
        public void UpdateFace(Vector3 position, int faceIndex)
        {
            // SetRenderSetup();

            CubeMapFace face = (CubeMapFace)faceIndex;

            // New setup
            m_setup.CameraPosition   = position;
            m_setup.AspectRatio      = 1.0f;
            m_setup.Viewport         = new Viewport(0, 0, (int)m_environmentRT.GetLevelDescription(0).Width, (int)m_environmentRT.GetLevelDescription(0).Width);
            m_setup.ViewMatrix       = CreateViewMatrix(face, position);
            m_setup.Fov              = MathHelper.PiOver2;
            m_setup.ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(m_setup.Fov.Value, m_setup.AspectRatio.Value, NearClip, m_setup.LodTransitionBackgroundEnd.Value);
            m_setup.DepthToAlpha     = true;

            MyRender.GetRenderProfiler().StartProfilingBlock("Draw environmental maps");

            MyRender.PushRenderSetupAndApply(m_setup, ref m_backup);
            MyRender.Draw(false);

            MyRender.GetRenderProfiler().EndProfilingBlock();

            Surface cubeSurface = m_environmentRT.GetCubeMapSurface(face, 0);

            MyMinerGame.Static.GraphicsDevice.SetRenderTarget(0, cubeSurface);

            var screenEffect = MyRender.GetEffect(MyEffects.Screenshot) as MyEffectScreenshot;

            screenEffect.SetTechnique(MyEffectScreenshot.ScreenshotTechniqueEnum.Default);
            screenEffect.SetSourceTexture(m_fullSizeRT);
            screenEffect.SetScale(new Vector2(m_environmentRT.GetLevelDescription(0).Width / (float)m_fullSizeRT.GetLevelDescription(0).Width * 0.968f, 0.982f * m_environmentRT.GetLevelDescription(0).Width / (float)m_fullSizeRT.GetLevelDescription(0).Height));
            MyGuiManager.GetFullscreenQuad().Draw(screenEffect);
            screenEffect.SetScale(new Vector2(1, 1));

            cubeSurface.Dispose();

            MyRender.PopRenderSetupAndRevert(m_backup);
        }