public override void NewFrameReady(RecordingSession session)
        {
            PerformSubSampling();

            if (rtsSettings.renderHeight == rtsSettings.outputHeight)
            {
                // Blit with normalization if sizes match.
                m_normalizeMaterial.SetFloat("_NormalizationFactor", 1.0f / (float)rtsSettings.superSampling);
                m_normalizeMaterial.SetInt("_ApplyGammaCorrection", QualitySettings.activeColorSpace == ColorSpace.Linear && rtsSettings.colorSpace == ColorSpace.Gamma ? 1 : 0);
                Graphics.Blit(m_renderRT, outputRT, m_normalizeMaterial);
            }
            else
            {
                // Ideally we would use a separable filter here, but we're massively bound by readback and disk anyway for hi-res.
                m_superMaterial.SetVector("_Target_TexelSize", new Vector4(1f / outputWidth, 1f / outputHeight, outputWidth, outputHeight));
                m_superMaterial.SetFloat("_KernelCosPower", rtsSettings.superKernelPower);
                m_superMaterial.SetFloat("_KernelScale", rtsSettings.superKernelScale);
                m_superMaterial.SetFloat("_NormalizationFactor", 1.0f / (float)rtsSettings.superSampling);
                m_superMaterial.SetInt("_ApplyGammaCorrection", QualitySettings.activeColorSpace == ColorSpace.Linear && rtsSettings.colorSpace == ColorSpace.Gamma ? 1 : 0);
                Graphics.Blit(m_renderRT, outputRT, m_superMaterial);
            }

            if (rtsSettings.flipFinalOutput)
            {
                m_VFlipper.Flip(outputRT);
            }
        }
示例#2
0
        protected internal override void NewFrameReady(RecordingSession session)
        {
            PerformSubSampling();

            if (rtsSettings.RenderHeight == rtsSettings.OutputHeight)
            {
                // Blit with normalization if sizes match.
                m_normalizeMaterial.SetFloat("_NormalizationFactor", 1.0f / (float)rtsSettings.SuperSampling);
                m_normalizeMaterial.SetInt("_ApplyGammaCorrection", QualitySettings.activeColorSpace == ColorSpace.Linear && rtsSettings.ColorSpace == ColorSpace.Gamma ? 1 : 0);
                Graphics.Blit(m_renderRT, OutputRenderTexture, m_normalizeMaterial);
            }
            else
            {
                // Ideally we would use a separable filter here, but we're massively bound by readback and disk anyway for hi-res.
                m_superMaterial.SetVector("_Target_TexelSize", new Vector4(1f / OutputWidth, 1f / OutputHeight, OutputWidth, OutputHeight));
                m_superMaterial.SetFloat("_KernelCosPower", rtsSettings.superKernelPower);
                m_superMaterial.SetFloat("_KernelScale", rtsSettings.superKernelScale);
                m_superMaterial.SetFloat("_NormalizationFactor", 1.0f / (float)rtsSettings.SuperSampling);
                m_superMaterial.SetInt("_ApplyGammaCorrection", QualitySettings.activeColorSpace == ColorSpace.Linear && rtsSettings.ColorSpace == ColorSpace.Gamma ? 1 : 0);
                Graphics.Blit(m_renderRT, OutputRenderTexture, m_superMaterial);
            }

            bool needToFlip            = rtsSettings.FlipFinalOutput; // whether or not the recorder settings have the flip box checked
            var  movieRecorderSettings = session.settings as MovieRecorderSettings;

            if (movieRecorderSettings != null)
            {
                bool encoderAlreadyFlips = movieRecorderSettings.encodersRegistered[movieRecorderSettings.encoderSelected].PerformsVerticalFlip;
                needToFlip = needToFlip ? encoderAlreadyFlips : !encoderAlreadyFlips;
            }
            if (needToFlip)
            {
                m_VFlipper.Flip(OutputRenderTexture);
            }
        }
        protected internal override void NewFrameReady(RecordingSession session)
        {
            if (cbSettings.FlipFinalOutput)
            {
                m_VFlipper.Flip(OutputRenderTexture);
            }

            base.NewFrameReady(session);
        }
示例#4
0
        public override void NewFrameReady(RecordingSession session)
        {
            if (cbSettings.flipFinalOutput)
            {
                m_VFlipper.Flip(outputRT);
            }

            base.NewFrameReady(session);
        }
示例#5
0
        public override void NewFrameReady(RecordingSession session)
        {
            Profiler.BeginSample("GameViewInput.NewFrameReady");
#if UNITY_2019_1_OR_NEWER
            ScreenCapture.CaptureScreenshotIntoRenderTexture(m_CaptureTexture);
            m_VFlipper?.Flip(m_CaptureTexture);
#else
            readbackTexture = ScreenCapture.CaptureScreenshotAsTexture();
#endif
            Profiler.EndSample();
        }
示例#6
0
        public override void NewFrameReady(RecordingSession session)
        {
            if (cbSettings.captureUI)
            {
                // Find canvases
                var canvases = UnityObject.FindObjectsOfType <Canvas>();
                if (m_CanvasBackups == null || m_CanvasBackups.Length != canvases.Length)
                {
                    m_CanvasBackups = new CanvasBackup[canvases.Length];
                }

                // Hookup canvase to UI camera
                for (var i = 0; i < canvases.Length; i++)
                {
                    var canvas = canvases[i];
                    if (canvas.isRootCanvas && canvas.renderMode == RenderMode.ScreenSpaceOverlay)
                    {
                        m_CanvasBackups[i].camera = canvas.worldCamera;
                        m_CanvasBackups[i].canvas = canvas;
                        canvas.renderMode         = RenderMode.ScreenSpaceCamera;
                        canvas.worldCamera        = m_UICamera;
                    }
                    else
                    {
                        // Mark this canvas as null so we can skip it when restoring.
                        // The array might contain invalid data from a previous frame.
                        m_CanvasBackups[i].canvas = null;
                    }
                }

                m_UICamera.Render();

                // Restore canvas settings
                for (var i = 0; i < m_CanvasBackups.Length; i++)
                {
                    // Skip those canvases that are not roots canvases or are
                    // not using ScreenSpaceOverlay as a render mode.
                    if (m_CanvasBackups[i].canvas == null)
                    {
                        continue;
                    }

                    m_CanvasBackups[i].canvas.renderMode  = RenderMode.ScreenSpaceOverlay;
                    m_CanvasBackups[i].canvas.worldCamera = m_CanvasBackups[i].camera;
                }
            }

            if (cbSettings.flipFinalOutput)
            {
                m_VFlipper.Flip(outputRT);
            }
        }
示例#7
0
        protected internal override void NewFrameReady(RecordingSession session)
        {
            Profiler.BeginSample("GameViewInput.NewFrameReady");
#if UNITY_2019_1_OR_NEWER
            ScreenCapture.CaptureScreenshotIntoRenderTexture(m_CaptureTexture);
            var  movieRecorderSettings = session.settings as MovieRecorderSettings;
            bool needToFlip            = scSettings.FlipFinalOutput;
            if (movieRecorderSettings != null)
            {
                bool encoderAlreadyFlips = movieRecorderSettings.encodersRegistered[movieRecorderSettings.encoderSelected].PerformsVerticalFlip;
                needToFlip &= encoderAlreadyFlips;
            }

            if (needToFlip)
            {
                OutputRenderTexture = m_VFlipper?.Flip(m_CaptureTexture);
            }

            // Force opaque alpha channel
            MakeFullyOpaque(OutputRenderTexture);
#else
            ReadbackTexture = ScreenCapture.CaptureScreenshotAsTexture();
            var movieRecorderSettings = session.settings as MovieRecorderSettings;
            if (movieRecorderSettings != null)
            {
                var currEncoder    = movieRecorderSettings.encodersRegistered[movieRecorderSettings.encoderSelected];
                var requiredFormat = currEncoder.GetTextureFormat(movieRecorderSettings);
                var isGameView     = movieRecorderSettings.ImageInputSettings is GameViewInputSettings;
                if (!currEncoder.PerformsVerticalFlip)
                {
                    ReadbackTexture = UnityHelpers.FlipTextureVertically(ReadbackTexture, movieRecorderSettings.CaptureAlpha);
                }
                if (requiredFormat != ReadbackTexture.format)
                {
                    if (requiredFormat == TextureFormat.RGB24 && ReadbackTexture.format == TextureFormat.RGBA32)
                    {
                        ReadbackTexture = UnityHelpers.RGBA32_to_RGB24(ReadbackTexture);
                    }
                    else
                    {
                        throw new Exception($"Unexpected conversion requested: from {ReadbackTexture.format} to {requiredFormat}.");
                    }
                }
            }

            // Force opaque alpha channel
            MakeFullyOpaque(ReadbackTexture);
#endif
            Profiler.EndSample();
        }
示例#8
0
        protected internal override void NewFrameReady(RecordingSession session)
        {
            var eyesEyeSepBackup = targetCamera.stereoSeparation;
            var eyeMaskBackup    = targetCamera.stereoTargetEye;

            var sRGBWrite = GL.sRGBWrite;

            GL.sRGBWrite = PlayerSettings.colorSpace == ColorSpace.Linear;

            if (settings360.RenderStereo)
            {
                targetCamera.stereoSeparation = settings360.StereoSeparation;
                targetCamera.stereoTargetEye  = StereoTargetEyeMask.Both;
                targetCamera.RenderToCubemap(m_Cubemap1, 63, Camera.MonoOrStereoscopicEye.Left);
                targetCamera.stereoSeparation = settings360.StereoSeparation;
                targetCamera.stereoTargetEye  = StereoTargetEyeMask.Both;
                targetCamera.RenderToCubemap(m_Cubemap2, 63, Camera.MonoOrStereoscopicEye.Right);

                m_Cubemap1.ConvertToEquirect(OutputRenderTexture, Camera.MonoOrStereoscopicEye.Left);
                m_Cubemap2.ConvertToEquirect(OutputRenderTexture, Camera.MonoOrStereoscopicEye.Right);
            }
            else
            {
                targetCamera.RenderToCubemap(m_Cubemap1, 63, Camera.MonoOrStereoscopicEye.Mono);
                m_Cubemap1.ConvertToEquirect(OutputRenderTexture);
            }

            var  movieRecorderSettings = session.settings as MovieRecorderSettings;
            bool needToFlip            = settings360.FlipFinalOutput; // whether or not the recorder settings have the flip box checked

            if (movieRecorderSettings != null)
            {
                bool encoderAlreadyFlips = movieRecorderSettings.encodersRegistered[movieRecorderSettings.encoderSelected].PerformsVerticalFlip;
                needToFlip = needToFlip ? encoderAlreadyFlips : !encoderAlreadyFlips;
            }

            if (needToFlip)
            {
                m_VFlipper.Flip(OutputRenderTexture);
            }

            targetCamera.stereoSeparation = eyesEyeSepBackup;
            targetCamera.stereoTargetEye  = eyeMaskBackup;

            GL.sRGBWrite = sRGBWrite;
        }
        protected internal override void NewFrameReady(RecordingSession session)
        {
            bool needToFlip            = cbSettings.FlipFinalOutput; // whether or not the recorder settings have the flip box checked
            var  movieRecorderSettings = session.settings as MovieRecorderSettings;

            if (movieRecorderSettings != null)
            {
                bool encoderAlreadyFlips = movieRecorderSettings.encodersRegistered[movieRecorderSettings.encoderSelected].PerformsVerticalFlip;
                needToFlip = needToFlip ? encoderAlreadyFlips : !encoderAlreadyFlips;
            }
            if (needToFlip)
            {
                OutputRenderTexture = m_VFlipper.Flip(OutputRenderTexture);
            }

            base.NewFrameReady(session);
        }
示例#10
0
        public override void NewFrameReady(RecordingSession session)
        {
            if (cbSettings.m_CaptureUI)
            {
                // Find canvases
                var canvases = Object.FindObjectsOfType <Canvas>();
                if (m_CanvasBackups == null || m_CanvasBackups.Length != canvases.Length)
                {
                    m_CanvasBackups = new CanvasBackup[canvases.Length];
                }

                // Hookup canvase to UI camera
                for (var i = 0; i < canvases.Length; i++)
                {
                    var canvas = canvases[i];
                    if (canvas.isRootCanvas && canvas.renderMode == RenderMode.ScreenSpaceOverlay)
                    {
                        m_CanvasBackups[i].camera = canvas.worldCamera;
                        m_CanvasBackups[i].canvas = canvas;
                        canvas.renderMode         = RenderMode.ScreenSpaceCamera;
                        canvas.worldCamera        = m_UICamera;
                    }
                }

                m_UICamera.Render();

                // Restore canvas settings
                for (var i = 0; i < m_CanvasBackups.Length; i++)
                {
                    m_CanvasBackups[i].canvas.renderMode  = RenderMode.ScreenSpaceOverlay;
                    m_CanvasBackups[i].canvas.worldCamera = m_CanvasBackups[i].camera;
                }
            }

            if (cbSettings.m_FlipFinalOutput)
            {
                m_VFlipper.Flip(outputRT);
            }
        }
        protected internal override void NewFrameReady(RecordingSession session)
        {
            Profiler.BeginSample("GameViewInput.NewFrameReady");
            ScreenCapture.CaptureScreenshotIntoRenderTexture(m_CaptureTexture);
            var  movieRecorderSettings = session.settings as MovieRecorderSettings;
            bool needToFlip            = scSettings.FlipFinalOutput;

            if (movieRecorderSettings != null)
            {
                bool encoderAlreadyFlips = movieRecorderSettings.encodersRegistered[movieRecorderSettings.encoderSelected].PerformsVerticalFlip;
                needToFlip &= encoderAlreadyFlips;
            }

            if (needToFlip)
            {
                OutputRenderTexture = m_VFlipper?.Flip(m_CaptureTexture);
            }

            // Force opaque alpha channel
            MakeFullyOpaque(OutputRenderTexture);
            Profiler.EndSample();
        }
示例#12
0
        protected internal override void NewFrameReady(RecordingSession session)
        {
            var eyesEyeSepBackup = targetCamera.stereoSeparation;
            var eyeMaskBackup    = targetCamera.stereoTargetEye;

            var sRGBWrite = GL.sRGBWrite;

            GL.sRGBWrite = PlayerSettings.colorSpace == ColorSpace.Linear;

            if (settings360.renderStereo)
            {
                targetCamera.stereoSeparation = settings360.stereoSeparation;
                targetCamera.stereoTargetEye  = StereoTargetEyeMask.Both;
                targetCamera.RenderToCubemap(m_Cubemap1, 63, Camera.MonoOrStereoscopicEye.Left);
                targetCamera.stereoSeparation = settings360.stereoSeparation;
                targetCamera.stereoTargetEye  = StereoTargetEyeMask.Both;
                targetCamera.RenderToCubemap(m_Cubemap2, 63, Camera.MonoOrStereoscopicEye.Right);

                m_Cubemap1.ConvertToEquirect(outputRT, Camera.MonoOrStereoscopicEye.Left);
                m_Cubemap2.ConvertToEquirect(outputRT, Camera.MonoOrStereoscopicEye.Right);
            }
            else
            {
                targetCamera.RenderToCubemap(m_Cubemap1, 63, Camera.MonoOrStereoscopicEye.Mono);
                m_Cubemap1.ConvertToEquirect(outputRT);
            }

            if (settings360.flipFinalOutput)
            {
                m_VFlipper.Flip(outputRT);
            }

            targetCamera.stereoSeparation = eyesEyeSepBackup;
            targetCamera.stereoTargetEye  = eyeMaskBackup;

            GL.sRGBWrite = sRGBWrite;
        }
        public override void NewFrameReady(RecordingSession session)
        {
            var eyesEyeSepBackup = targetCamera.stereoSeparation;
            var eyeMaskBackup    = targetCamera.stereoTargetEye;

            if (settings360.renderStereo)
            {
                targetCamera.stereoSeparation = settings360.stereoSeparation;
                targetCamera.stereoTargetEye  = StereoTargetEyeMask.Both;
                targetCamera.RenderToCubemap(m_Cubemap1, 63, Camera.MonoOrStereoscopicEye.Left);
                targetCamera.stereoSeparation = settings360.stereoSeparation;
                targetCamera.stereoTargetEye  = StereoTargetEyeMask.Both;
                targetCamera.RenderToCubemap(m_Cubemap2, 63, Camera.MonoOrStereoscopicEye.Right);
            }
            else
            {
                targetCamera.RenderToCubemap(m_Cubemap1, 63, Camera.MonoOrStereoscopicEye.Mono);
            }

            if (settings360.renderStereo)
            {
                m_Cubemap1.ConvertToEquirect(outputRT, Camera.MonoOrStereoscopicEye.Left);
                m_Cubemap2.ConvertToEquirect(outputRT, Camera.MonoOrStereoscopicEye.Right);
            }
            else
            {
                m_Cubemap1.ConvertToEquirect(outputRT, Camera.MonoOrStereoscopicEye.Mono);
            }

            if (settings360.flipFinalOutput)
            {
                m_VFlipper.Flip(outputRT);
            }

            targetCamera.stereoSeparation = eyesEyeSepBackup;
            targetCamera.stereoTargetEye  = eyeMaskBackup;
        }