Пример #1
0
 private void OnEnable()
 {
     Init(null);
     if (!haveBundlesBeenInited)
     {
         InitBundles();
     }
     m_LogHistogram         = new LogHistogram();
     m_PropertySheetFactory = new PropertySheetFactory();
     m_TargetPool           = new TargetPool();
     debugLayer.OnEnable();
     if (!RuntimeUtilities.scriptableRenderPipelineActive)
     {
         InitLegacy();
     }
 }
Пример #2
0
        void OnEnable()
        {
            Init(null);

            if (!haveBundlesBeenInited)
            {
                InitBundles();
            }

            m_LogHistogram         = new LogHistogram();
            m_PropertySheetFactory = new PropertySheetFactory();
            m_TargetPool           = new TargetPool();

            debugLayer.OnEnable();

            // Scriptable render pipelines handle their own command buffers
            if (RuntimeUtilities.scriptableRenderPipelineActive)
            {
                return;
            }

            m_LegacyCmdBufferBeforeReflections = new CommandBuffer {
                name = "Deferred Ambient Occlusion"
            };
            m_LegacyCmdBufferBeforeLighting = new CommandBuffer {
                name = "Deferred Ambient Occlusion"
            };
            m_LegacyCmdBufferOpaque = new CommandBuffer {
                name = "Opaque Only Post-processing"
            };
            m_LegacyCmdBuffer = new CommandBuffer {
                name = "Post-processing"
            };

            m_Camera = GetComponent <Camera>();
            m_Camera.forceIntoRenderTexture = true; // Needed when running Forward / LDR / No MSAA
            m_Camera.AddCommandBuffer(CameraEvent.BeforeReflections, m_LegacyCmdBufferBeforeReflections);
            m_Camera.AddCommandBuffer(CameraEvent.BeforeLighting, m_LegacyCmdBufferBeforeLighting);
            m_Camera.AddCommandBuffer(CameraEvent.BeforeImageEffectsOpaque, m_LegacyCmdBufferOpaque);
            m_Camera.AddCommandBuffer(CameraEvent.BeforeImageEffects, m_LegacyCmdBuffer);

            // Internal context used if no SRP is set
            m_CurrentContext = new PostProcessRenderContext();
        }
Пример #3
0
        void OnEnable()
        {
            if (!haveBundlesBeenInited)
            {
                InitBundles();
            }

            m_LogHistogram         = new LogHistogram();
            m_PropertySheetFactory = new PropertySheetFactory();
            m_TargetPool           = new TargetPool();

            if (monitors == null)
            {
                monitors = new PostProcessMonitors();
            }

            monitors.OnEnable();

            // Scriptable render pipelines handle their own command buffers
            if (RuntimeUtilities.scriptableRenderPipelineActive)
            {
                return;
            }

            m_LegacyCmdBufferBeforeReflections = new CommandBuffer {
                name = "Deferred Ambient Occlusion"
            };
            m_LegacyCmdBufferOpaque = new CommandBuffer {
                name = "Opaque Only Post-processing"
            };
            m_LegacyCmdBuffer = new CommandBuffer {
                name = "Post-processing"
            };

            m_Camera = GetComponent <Camera>();
            m_Camera.AddCommandBuffer(CameraEvent.BeforeReflections, m_LegacyCmdBufferBeforeReflections);
            m_Camera.AddCommandBuffer(CameraEvent.BeforeImageEffectsOpaque, m_LegacyCmdBufferOpaque);
            m_Camera.AddCommandBuffer(CameraEvent.BeforeImageEffects, m_LegacyCmdBuffer);

            // Internal context used if no SRP is set
            m_CurrentContext = new PostProcessRenderContext();
        }
Пример #4
0
        internal override void Render(PostProcessRenderContext context)
        {
            CheckOutput(width, height);
            LogHistogram  logHistogram  = context.logHistogram;
            PropertySheet propertySheet = context.propertySheets.Get(context.resources.shaders.lightMeter);

            propertySheet.ClearKeywords();
            propertySheet.properties.SetBuffer(ShaderIDs.HistogramBuffer, logHistogram.data);
            Vector4 histogramScaleOffsetRes = logHistogram.GetHistogramScaleOffsetRes(context);

            histogramScaleOffsetRes.z = 1f / (float)width;
            histogramScaleOffsetRes.w = 1f / (float)height;
            propertySheet.properties.SetVector(ShaderIDs.ScaleOffsetRes, histogramScaleOffsetRes);
            if (context.logLut != null && showCurves)
            {
                propertySheet.EnableKeyword("COLOR_GRADING_HDR");
                propertySheet.properties.SetTexture(ShaderIDs.Lut3D, context.logLut);
            }
            AutoExposure autoExposure = context.autoExposure;

            if (autoExposure != null)
            {
                float x = autoExposure.filtering.value.x;
                float y = autoExposure.filtering.value.y;
                y = Mathf.Clamp(y, 1.01f, 99f);
                x = Mathf.Clamp(x, 1f, y - 0.01f);
                Vector4 value = new Vector4(x * 0.01f, y * 0.01f, RuntimeUtilities.Exp2(autoExposure.minLuminance.value), RuntimeUtilities.Exp2(autoExposure.maxLuminance.value));
                propertySheet.EnableKeyword("AUTO_EXPOSURE");
                propertySheet.properties.SetVector(ShaderIDs.Params, value);
            }
            CommandBuffer command = context.command;

            command.BeginSample("LightMeter");
            command.BlitFullscreenTriangle(BuiltinRenderTextureType.None, base.output, propertySheet, 0);
            command.EndSample("LightMeter");
        }