Ejemplo n.º 1
0
        private bool ConvertLayerComponent(BIRPRendering.PostProcessLayer oldLayer, StringBuilder errorString)
        {
            var siblingCamera = oldLayer.GetComponent <Camera>().GetUniversalAdditionalCameraData();

            // PostProcessLayer requires a sibling Camera component, but
            // we check it here just in case something weird went happened.
            if (!siblingCamera)
            {
                errorString.AppendLine(
                    "PPv2 PostProcessLayer failed to be converted because the instance object was missing a required sibling Camera component.");
                return(false);
            }

            // The presence of a PostProcessLayer implies the Camera should render post-processes
            siblingCamera.renderPostProcessing = true;

            siblingCamera.volumeLayerMask = oldLayer.volumeLayer;
            siblingCamera.volumeTrigger   = oldLayer.volumeTrigger;
            siblingCamera.stopNaN         = oldLayer.stopNaNPropagation;

            siblingCamera.antialiasingQuality =
                (URPRendering.AntialiasingQuality)oldLayer.subpixelMorphologicalAntialiasing.quality;

            switch (oldLayer.antialiasingMode)
            {
            case BIRPRendering.PostProcessLayer.Antialiasing.None:
                siblingCamera.antialiasing = URPRendering.AntialiasingMode.None;
                break;

            case BIRPRendering.PostProcessLayer.Antialiasing.FastApproximateAntialiasing:
                siblingCamera.antialiasing = URPRendering.AntialiasingMode.FastApproximateAntialiasing;
                break;

            case BIRPRendering.PostProcessLayer.Antialiasing.SubpixelMorphologicalAntialiasing:
                siblingCamera.antialiasing = URPRendering.AntialiasingMode.SubpixelMorphologicalAntiAliasing;
                break;

            default:
                // Default to the the most performant mode, since "None" is an explicit option.
                siblingCamera.antialiasing = URPRendering.AntialiasingMode.FastApproximateAntialiasing;
                break;
            }

            if (PrefabUtility.IsPartOfPrefabAsset(oldLayer))
            {
                postConversionDestroyables.Add(oldLayer);
            }
            else
            {
                Object.DestroyImmediate(oldLayer, allowDestroyingAssets: true);
            }

            EditorUtility.SetDirty(siblingCamera.gameObject);

            return(true);
        }
Ejemplo n.º 2
0
        void UpdateStates()
        {
            if (m_PreviousPostProcessLayer != postProcessLayer)
            {
                // Remove cmdbuffer from previously set camera
                if (m_CurrentCamera != null)
                {
                    m_CurrentCamera.RemoveCommandBuffer(CameraEvent.AfterImageEffects, m_CmdAfterEverything);
                    m_CurrentCamera = null;
                }

                m_PreviousPostProcessLayer = postProcessLayer;

                // Add cmdbuffer to the currently set camera
                if (postProcessLayer != null)
                {
                    m_CurrentCamera = postProcessLayer.GetComponent <Camera>();
                    m_CurrentCamera.AddCommandBuffer(CameraEvent.AfterImageEffects, m_CmdAfterEverything);
                }
            }

            if (postProcessLayer == null || !postProcessLayer.enabled)
            {
                return;
            }

            // Monitors
            if (lightMeter)
            {
                postProcessLayer.debugLayer.RequestMonitorPass(MonitorType.LightMeter);
            }
            if (histogram)
            {
                postProcessLayer.debugLayer.RequestMonitorPass(MonitorType.Histogram);
            }
            if (waveform)
            {
                postProcessLayer.debugLayer.RequestMonitorPass(MonitorType.Waveform);
            }
            if (vectorscope)
            {
                postProcessLayer.debugLayer.RequestMonitorPass(MonitorType.Vectorscope);
            }

            // Overlay
            postProcessLayer.debugLayer.RequestDebugOverlay(debugOverlay);
        }
Ejemplo n.º 3
0
        private bool ConvertLayerInstance(BIRPRendering.PostProcessLayer oldLayer, StringBuilder errorString)
        {
            // First get a reference to the local instance of the camera (which is required by PostProcessingLayer)
            var siblingCamera = oldLayer.GetComponent <Camera>().GetUniversalAdditionalCameraData();

            if (!siblingCamera)
            {
                errorString.AppendLine(
                    "PPv2 PostProcessLayer failed to be converted because the instance object was missing a required sibling Camera component.");
                return(false);
            }

            var oldModifications = PrefabUtility.GetPropertyModifications(oldLayer);

            foreach (var oldModification in oldModifications)
            {
                if (oldModification.target is BIRPRendering.PostProcessLayer)
                {
                    if (oldModification.propertyPath.EndsWith("volumeLayer",
                                                              StringComparison.InvariantCultureIgnoreCase))
                    {
                        siblingCamera.volumeLayerMask = oldLayer.volumeLayer;
                    }
                    else if (oldModification.propertyPath.EndsWith("volumeTrigger",
                                                                   StringComparison.InvariantCultureIgnoreCase))
                    {
                        siblingCamera.volumeTrigger = oldLayer.volumeTrigger;
                    }
                    else if (oldModification.propertyPath.EndsWith("stopNaNPropagation",
                                                                   StringComparison.InvariantCultureIgnoreCase))
                    {
                        siblingCamera.stopNaN = oldLayer.stopNaNPropagation;
                    }
                    else if (oldModification.propertyPath.EndsWith("quality",
                                                                   StringComparison.InvariantCultureIgnoreCase))
                    {
                        siblingCamera.antialiasingQuality =
                            (URPRendering.AntialiasingQuality)oldLayer.subpixelMorphologicalAntialiasing.quality;
                    }
                    else if (oldModification.propertyPath.EndsWith("antialiasingMode",
                                                                   StringComparison.InvariantCultureIgnoreCase))
                    {
                        switch (oldLayer.antialiasingMode)
                        {
                        case BIRPRendering.PostProcessLayer.Antialiasing.None:
                            siblingCamera.antialiasing = URPRendering.AntialiasingMode.None;
                            break;

                        case BIRPRendering.PostProcessLayer.Antialiasing.FastApproximateAntialiasing:
                            siblingCamera.antialiasing = URPRendering.AntialiasingMode.FastApproximateAntialiasing;
                            break;

                        case BIRPRendering.PostProcessLayer.Antialiasing.SubpixelMorphologicalAntialiasing:
                            siblingCamera.antialiasing =
                                URPRendering.AntialiasingMode.SubpixelMorphologicalAntiAliasing;
                            break;

                        default:
                            // Default to the the most performant mode, since "None" is an explicit option.
                            siblingCamera.antialiasing = URPRendering.AntialiasingMode.FastApproximateAntialiasing;
                            break;
                        }
                    }

                    EditorUtility.SetDirty(siblingCamera);
                }
            }

            return(true);
        }