Esempio n. 1
0
        // Renders everything not opaque-only
        //
        // Current order of operation is as following:
        //     1. Pre-stack
        //     2. Built-in stack
        //     3. Post-stack
        //     4. Built-in final pass
        //
        // Final pass should be skipped when outputting to a HDR display.
        public void Render(PostProcessRenderContext context)
        {
            SetupContext(context);
            TextureLerper.instance.BeginFrame(context);

            // Update & override layer settings first (volume blending) if the opaque only pass
            // hasn't been called this frame.
            UpdateSettingsIfNeeded(context);

            // Do temporal anti-aliasing first
            int lastTarget = -1;

            if (context.IsTemporalAntialiasingActive() && !context.isSceneView)
            {
                temporalAntialiasing.SetProjectionMatrix(context.camera);

                lastTarget = m_TargetPool.Get();
                var finalDestination = context.destination;
                context.command.GetTemporaryRT(lastTarget, context.width, context.height, 24, FilterMode.Bilinear, context.sourceFormat);
                context.destination = lastTarget;
                temporalAntialiasing.Render(context);
                context.source      = lastTarget;
                context.destination = finalDestination;
            }

            // Right before the builtin stack
            lastTarget = RenderInjectionPoint(PostProcessEvent.BeforeStack, context, "BeforeStack", lastTarget);

            // Builtin stack
            lastTarget = RenderBuiltins(context, lastTarget);

            // After the builtin stack but before the final pass (before FXAA & Dithering)
            if (!breakBeforeColorGrading)
            {
                lastTarget = RenderInjectionPoint(PostProcessEvent.AfterStack, context, "AfterStack", lastTarget);
            }

            // And close with the final pass
            RenderFinalPass(context, lastTarget);

            TextureLerper.instance.EndFrame();
            m_SettingsUpdateNeeded = true;
        }
Esempio n. 2
0
        // Renders before-stack, builtin stack and after-stack effects
        // TODO: Refactor this, it's a mess and it's hard to maintain
        public void Render(PostProcessRenderContext context)
        {
            // Update & override layer settings first (volume blending) if the opaque only pass
            // hasn't been called this frame.
            UpdateSettingsIfNeeded(context);

            SetupContext(context);
            var finalDestination = context.destination;
            var cmd = context.command;

            // Do temporal anti-aliasing first
            if (context.IsTemporalAntialiasingActive() && !m_IsRenderingInSceneView)
            {
                temporalAntialiasing.SetProjectionMatrix(context.camera);

                cmd.GetTemporaryRT(Uniforms._AATemp, context.width, context.height, 24, FilterMode.Bilinear, context.sourceFormat);
                context.destination = Uniforms._AATemp;
                temporalAntialiasing.Render(context);
                context.source      = Uniforms._AATemp;
                context.destination = Uniforms._TempTargetPool[4];
            }

            bool hasBeforeStack = HasActiveEffects(m_SortedBundles[PostProcessEvent.BeforeStack]);
            bool hasAfterStack  = HasActiveEffects(m_SortedBundles[PostProcessEvent.AfterStack]);

            // Render builtin stack and user effects
            if (hasBeforeStack)
            {
                cmd.GetTemporaryRT(Uniforms._TempTargetPool[2], context.width, context.height, 24, FilterMode.Bilinear, context.sourceFormat);
                context.destination = Uniforms._TempTargetPool[2];
                RenderList(m_SortedBundles[PostProcessEvent.BeforeStack], context, "BeforeStack");
                context.source      = Uniforms._TempTargetPool[2];
                context.destination = Uniforms._TempTargetPool[4];
            }

            if (hasAfterStack)
            {
                cmd.GetTemporaryRT(Uniforms._TempTargetPool[3], context.width, context.height, 24, FilterMode.Bilinear, context.sourceFormat);
                context.destination = Uniforms._TempTargetPool[3];
                RenderBuiltins(context);

                if (hasBeforeStack)
                {
                    cmd.ReleaseTemporaryRT(Uniforms._TempTargetPool[2]);
                }

                context.source      = Uniforms._TempTargetPool[3];
                context.destination = Uniforms._TempTargetPool[4];
                cmd.GetTemporaryRT(Uniforms._TempTargetPool[4], context.width, context.height, 24, FilterMode.Bilinear, context.sourceFormat);
                RenderList(m_SortedBundles[PostProcessEvent.AfterStack], context, "AfterStack");
                cmd.ReleaseTemporaryRT(Uniforms._TempTargetPool[3]);
            }
            else // Should be skippable if nothing's enabled in builtins
            {
                context.destination = Uniforms._TempTargetPool[4];
                cmd.GetTemporaryRT(Uniforms._TempTargetPool[4], context.width, context.height, 24, FilterMode.Bilinear, context.sourceFormat);
                RenderBuiltins(context);

                if (hasBeforeStack)
                {
                    cmd.ReleaseTemporaryRT(Uniforms._TempTargetPool[2]);
                }
            }

            context.source      = Uniforms._TempTargetPool[4];
            context.destination = finalDestination;
            RenderFinalPass(context);
            cmd.ReleaseTemporaryRT(Uniforms._TempTargetPool[4]);

            m_SettingsUpdateNeeded = true;
        }