Exemple #1
0
        public override void BeginRecording(RecordingSession session)
        {
            outputWidth  = scSettings.outputWidth;
            outputHeight = scSettings.outputHeight;

            int w, h;

            GameViewSize.GetGameRenderSize(out w, out h);
            if (w != outputWidth || h != outputHeight)
            {
                var size = GameViewSize.SetCustomSize(outputWidth, outputHeight) ?? GameViewSize.AddSize(outputWidth, outputHeight);
                if (GameViewSize.modifiedResolutionCount == 0)
                {
                    GameViewSize.BackupCurrentSize();
                }
                else
                {
                    if (size != GameViewSize.currentSize)
                    {
                        Debug.LogError("Requestion a resultion change while a recorder's input has already requested one! Undefined behaviour.");
                    }
                }
                GameViewSize.modifiedResolutionCount++;
                m_ModifiedResolution = true;
                GameViewSize.SelectSize(size);
            }
        }
Exemple #2
0
        protected internal override void BeginRecording(RecordingSession session)
        {
            OutputWidth  = scSettings.OutputWidth;
            OutputHeight = scSettings.OutputHeight;

            int w, h;

            GameViewSize.GetGameRenderSize(out w, out h);
            if (w != OutputWidth || h != OutputHeight)
            {
                var size = GameViewSize.SetCustomSize(OutputWidth, OutputHeight) ?? GameViewSize.AddSize(OutputWidth, OutputHeight);
                if (GameViewSize.modifiedResolutionCount == 0)
                {
                    GameViewSize.BackupCurrentSize();
                }
                else
                {
                    if (size != GameViewSize.currentSize)
                    {
                        Debug.LogError("Requesting a resolution change while a recorder's input has already requested one! Undefined behaviour.");
                    }
                }
                GameViewSize.modifiedResolutionCount++;
                m_ModifiedResolution = true;
                GameViewSize.SelectSize(size);
            }

#if !UNITY_2019_1_OR_NEWER
            // Before 2019.1, we capture synchronously into a Texture2D, so we don't need to create
            // a RenderTexture that is used for reading asynchronously.
            return;
#else
            m_CaptureTexture = new RenderTexture(OutputWidth, OutputHeight, 0, RenderTextureFormat.ARGB32)
            {
                wrapMode = TextureWrapMode.Repeat
            };
            m_CaptureTexture.Create();

            var  movieRecorderSettings = session.settings as MovieRecorderSettings;
            bool needToFlip            = scSettings.FlipFinalOutput;
            if (movieRecorderSettings != null)
            {
                bool encoderAlreadyFlips = movieRecorderSettings.encodersRegistered[movieRecorderSettings.encoderSelected].PerformsVerticalFlip;
                needToFlip &= encoderAlreadyFlips;
            }

            if (needToFlip)
            {
                m_VFlipper = new TextureFlipper(false);
                m_VFlipper.Init(m_CaptureTexture);
                OutputRenderTexture = m_VFlipper.workTexture;
            }
            else
            {
                OutputRenderTexture = m_CaptureTexture;
            }
#endif
        }
        public override void BeginRecording(RecordingSession session)
        {
            switch (scSettings.outputHeight)
            {
            case ImageHeight.Window:
            {
                int screenWidth;
                int screenHeight;

                GameViewSize.GetGameRenderSize(out screenWidth, out screenHeight);
                outputWidth  = screenWidth;
                outputHeight = screenHeight;

                if (scSettings.forceEvenSize)
                {
                    outputWidth  = (outputWidth + 1) & ~1;
                    outputHeight = (outputHeight + 1) & ~1;
                }
                break;
            }

            default:
            {
                outputHeight = (int)scSettings.outputHeight;
                outputWidth  = (int)(outputHeight * AspectRatioHelper.GetRealAspect(scSettings.outputAspect));

                if (scSettings.forceEvenSize)
                {
                    outputWidth  = (outputWidth + 1) & ~1;
                    outputHeight = (outputHeight + 1) & ~1;
                }

                break;
            }
            }

            int w, h;

            GameViewSize.GetGameRenderSize(out w, out h);
            if (w != outputWidth || h != outputHeight)
            {
                var size = GameViewSize.SetCustomSize(outputWidth, outputHeight) ?? GameViewSize.AddSize(outputWidth, outputHeight);
                if (GameViewSize.modifiedResolutionCount == 0)
                {
                    GameViewSize.BackupCurrentSize();
                }
                else
                {
                    if (size != GameViewSize.currentSize)
                    {
                        Debug.LogError("Requestion a resultion change while a recorder's input has already requested one! Undefined behaviour.");
                    }
                }
                GameViewSize.modifiedResolutionCount++;
                m_ModifiedResolution = true;
                GameViewSize.SelectSize(size);
            }
        }
Exemple #4
0
        protected internal override void BeginRecording(RecordingSession session)
        {
            OutputWidth  = scSettings.OutputWidth;
            OutputHeight = scSettings.OutputHeight;

            if (OutputWidth <= 0 || OutputHeight <= 0)
            {
                return; // error will be handled by ImageInputSettings.CheckForErrors. Otherwise we get a failure at RenderTexture.GetTemporary()
            }
            int w, h;

            GameViewSize.GetGameRenderSize(out w, out h);
            if (w != OutputWidth || h != OutputHeight)
            {
                var size = GameViewSize.SetCustomSize(OutputWidth, OutputHeight) ?? GameViewSize.AddSize(OutputWidth, OutputHeight);
                if (GameViewSize.modifiedResolutionCount == 0)
                {
                    GameViewSize.BackupCurrentSize();
                }
                else
                {
                    if (size != GameViewSize.currentSize)
                    {
                        Debug.LogError("Requesting a resolution change while a recorder's input has already requested one! Undefined behaviour.");
                    }
                }
                GameViewSize.modifiedResolutionCount++;
                m_ModifiedResolution = true;
                GameViewSize.SelectSize(size);
            }

            // Initialize the temporary texture for forcing opacity
            m_TempCaptureTextureOpaque = RenderTexture.GetTemporary(OutputWidth, OutputHeight);

#if !UNITY_2019_1_OR_NEWER
            // Before 2019.1, we capture synchronously into a Texture2D, so we don't need to create
            // a RenderTexture that is used for reading asynchronously.
            return;
#else
            m_CaptureTexture = new RenderTexture(OutputWidth, OutputHeight, 0, RenderTextureFormat.ARGB32)
            {
                wrapMode = TextureWrapMode.Repeat
            };
            m_CaptureTexture.Create();
            m_CaptureTexture.name = "GameViewInput_mCaptureTexture";

            var  movieRecorderSettings = session.settings as MovieRecorderSettings;
            bool encoderAlreadyFlips   = false;
            if (movieRecorderSettings != null)
            {
                encoderAlreadyFlips = movieRecorderSettings.encodersRegistered[movieRecorderSettings.encoderSelected].PerformsVerticalFlip;
            }

            NeedToFlipVertically = UnityHelpers.NeedToActuallyFlip(false, this, encoderAlreadyFlips);
            OutputRenderTexture  = m_CaptureTexture;
#endif
        }
Exemple #5
0
        public override void BeginRecording(RecordingSession session)
        {
            outputWidth  = scSettings.outputWidth;
            outputHeight = scSettings.outputHeight;

            int w, h;

            GameViewSize.GetGameRenderSize(out w, out h);
            if (w != outputWidth || h != outputHeight)
            {
                var size = GameViewSize.SetCustomSize(outputWidth, outputHeight) ?? GameViewSize.AddSize(outputWidth, outputHeight);
                if (GameViewSize.modifiedResolutionCount == 0)
                {
                    GameViewSize.BackupCurrentSize();
                }
                else
                {
                    if (size != GameViewSize.currentSize)
                    {
                        Debug.LogError("Requestion a resultion change while a recorder's input has already requested one! Undefined behaviour.");
                    }
                }
                GameViewSize.modifiedResolutionCount++;
                m_ModifiedResolution = true;
                GameViewSize.SelectSize(size);
            }

#if !UNITY_2019_1_OR_NEWER
            // Before 2019.1, we capture syncrhonously into a Texture2D, so we don't need to create
            // a RenderTexture that is used for reading asynchronously.
            return;
#else
            m_CaptureTexture = new RenderTexture(outputWidth, outputHeight, 0, RenderTextureFormat.ARGB32)
            {
                wrapMode = TextureWrapMode.Repeat
            };
            m_CaptureTexture.Create();

            if (scSettings.flipFinalOutput)
            {
                m_VFlipper = new TextureFlipper(false);
                m_VFlipper.Init(m_CaptureTexture);
                outputRT = m_VFlipper.workTexture;
            }
            else
            {
                outputRT = m_CaptureTexture;
            }
#endif
        }
Exemple #6
0
        public override void BeginRecording(RecordingSession session)
        {
            if (cbSettings.flipFinalOutput)
            {
                m_VFlipper = new TextureFlipper();
            }

            m_quad = CreateFullscreenQuad();
            switch (cbSettings.source)
            {
            case ImageSource.ActiveCamera:
            case ImageSource.MainCamera:
            case ImageSource.TaggedCamera:
            {
                switch (cbSettings.outputHeight)
                {
                case ImageHeight.Window:
                {
                    int screenWidth;
                    int screenHeight;
                    GameViewSize.GetGameRenderSize(out screenWidth, out screenHeight);
                    outputWidth  = screenWidth;
                    outputHeight = screenHeight;

                    if (cbSettings.forceEvenSize)
                    {
                        outputWidth  = (outputWidth + 1) & ~1;
                        outputHeight = (outputHeight + 1) & ~1;
                    }

                    break;
                }

                default:
                {
                    outputHeight = (int)cbSettings.outputHeight;
                    outputWidth  = (int)(outputHeight * AspectRatioHelper.GetRealAspect(cbSettings.outputAspect));

                    if (cbSettings.forceEvenSize)
                    {
                        outputWidth  = (outputWidth + 1) & ~1;
                        outputHeight = (outputHeight + 1) & ~1;
                    }

                    var size = GameViewSize.SetCustomSize(outputWidth, outputHeight);
                    if (size == null)
                    {
                        size = GameViewSize.AddSize(outputWidth, outputHeight);
                    }

                    if (GameViewSize.modifiedResolutionCount == 0)
                    {
                        GameViewSize.BackupCurrentSize();
                    }
                    else
                    {
                        if (size != GameViewSize.currentSize)
                        {
                            Debug.LogError("Requestion a resultion change while a recorder's input has already requested one! Undefined behaviour.");
                        }
                    }
                    GameViewSize.modifiedResolutionCount++;
                    m_ModifiedResolution = true;
                    GameViewSize.SelectSize(size);
                    break;
                }
                }
                break;
            }

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (cbSettings.captureUI)
            {
                var uiGO = new GameObject();
                uiGO.name             = "UICamera";
                uiGO.transform.parent = session.recorderGameObject.transform;

                m_UICamera               = uiGO.AddComponent <Camera>();
                m_UICamera.cullingMask   = 1 << 5;
                m_UICamera.clearFlags    = CameraClearFlags.Depth;
                m_UICamera.renderingPath = RenderingPath.DeferredShading;
                m_UICamera.targetTexture = outputRT;
                m_UICamera.enabled       = false;
            }
        }