protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (m_ModifiedResolution)
                {
                    GameViewSize.modifiedResolutionCount--;
                    if (GameViewSize.modifiedResolutionCount == 0)
                    {
                        GameViewSize.RestoreSize();
                    }
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 2
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (m_ModifiedResolution)
                {
                    if (GameViewSize.modifiedResolutionCount > 0)
                    {
                        GameViewSize.modifiedResolutionCount--; // don't allow negative if called twice
                    }
                    if (GameViewSize.modifiedResolutionCount == 0)
                    {
                        GameViewSize.RestoreSize();
                    }
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 3
0
        /// <inheritdoc/>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                m_InputStrategy.ReleaseCamera();
                UnityHelpers.Destroy(m_UICamera);

                if (m_ModifiedResolution)
                {
                    if (GameViewSize.modifiedResolutionCount > 0)
                    {
                        GameViewSize.modifiedResolutionCount--; // don't allow negative if called twice
                    }
                    if (GameViewSize.modifiedResolutionCount == 0)
                    {
                        GameViewSize.RestoreSize();
                    }
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 4
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                m_InputStrategy.ReleaseCamera();
                UnityHelpers.Destroy(m_UICamera);

                if (m_ModifiedResolution)
                {
                    GameViewSize.modifiedResolutionCount--;
                    if (GameViewSize.modifiedResolutionCount == 0)
                    {
                        GameViewSize.RestoreSize();
                    }
                }

                if (m_VFlipper != null)
                {
                    m_VFlipper.Dispose();
                }
            }

            base.Dispose(disposing);
        }
Ejemplo n.º 5
0
        public override void BeginRecording(RecordingSession session)
        {
            if (cbSettings.flipFinalOutput)
            {
                m_VFlipper = new TextureFlipper();
            }

            if (Options.useCameraCaptureCallbacks)
            {
                m_InputStrategy = new CaptureCallbackInputStrategy(cbSettings.allowTransparency);
            }
            else
            {
                m_InputStrategy = new CameraCommandBufferInputStrategy(cbSettings.allowTransparency);
            }

            switch (cbSettings.source)
            {
            case ImageSource.ActiveCamera:
            case ImageSource.MainCamera:
            case ImageSource.TaggedCamera:
            {
                outputWidth  = cbSettings.outputWidth;
                outputHeight = cbSettings.outputHeight;

                if (cbSettings.outputImageHeight != ImageHeight.Window)
                {
                    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("Requesting a resolution change while a recorder's input has already requested one! Undefined behaviour.");
                        }
                    }
                    GameViewSize.modifiedResolutionCount++;
                    m_ModifiedResolution = true;
                    GameViewSize.SelectSize(size);
                }
                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;
            }
        }
Ejemplo n.º 6
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);
            }

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

#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 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
        }
Ejemplo n.º 7
0
        /// <inheritdoc/>
        protected internal override void BeginRecording(RecordingSession session)
        {
            var encoderAlreadyFlips = session.settings.EncoderAlreadyFlips();

            NeedToFlipVertically = UnityHelpers.NeedToActuallyFlip(cbSettings.FlipFinalOutput, this, encoderAlreadyFlips);

            if (UnityHelpers.UsingLegacyRP())
            {
                m_InputStrategy = new CameraCommandBufferLegacyInputStrategy(cbSettings.RecordTransparency);
            }
            else
            {
                m_InputStrategy = new CaptureCallbackSRPInputStrategy(cbSettings.RecordTransparency);
            }

            m_InputStrategy.NeedToFlipVertically = NeedToFlipVertically.Value; // update the flag in the input strategy

            switch (cbSettings.Source)
            {
            case ImageSource.ActiveCamera:
            case ImageSource.MainCamera:
            case ImageSource.TaggedCamera:
            {
                OutputWidth  = cbSettings.OutputWidth;
                OutputHeight = cbSettings.OutputHeight;

                if (cbSettings.outputImageHeight != ImageHeight.Window)
                {
                    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($"Requesting a resolution change (to {OutputWidth}x{OutputHeight}) while a recorder's input has already requested one! Undefined behaviour. Count: {GameViewSize.modifiedResolutionCount}");
                        }
                    }
                    GameViewSize.modifiedResolutionCount++;
                    m_ModifiedResolution = true;
                    GameViewSize.SelectSize(size);
                }
                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 = OutputRenderTexture;
                m_UICamera.enabled       = false;
            }
        }
Ejemplo n.º 8
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;
            }
        }