Exemplo n.º 1
0
 public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                         CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
 {
     if (context.CompareSource0ToTarget0() != false)
     {
         int temporary = pipeline.GetTemporaryRT();
         if (nextProcess == null)
         {
             commandBuffer.SetRenderTarget(
                 new RenderTargetIdentifier(temporary),
                 RenderBufferLoadAction.DontCare,
                 RenderBufferStoreAction.Store,
                 RenderBufferLoadAction.DontCare,
                 RenderBufferStoreAction.DontCare);
             commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
             pipeline.SetViewport(commandBuffer, nextProcess);
             pipeline.DrawCopy(commandBuffer);
             context.SetSource0(temporary);
         }
         else
         {
             commandBuffer.SetRenderTarget(
                 new RenderTargetIdentifier(temporary),
                 RenderBufferLoadAction.DontCare,
                 RenderBufferStoreAction.Store,
                 RenderBufferLoadAction.DontCare,
                 RenderBufferStoreAction.DontCare);
             commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.target0);
             pipeline.SetViewport(commandBuffer, nextProcess);
             pipeline.DrawCopy(commandBuffer);
             context.SetTarget0(temporary);
         }
     }
     else
     {
         commandBuffer.SetRenderTarget(
             context.target0,
             RenderBufferLoadAction.DontCare,
             RenderBufferStoreAction.Store,
             RenderBufferLoadAction.DontCare,
             RenderBufferStoreAction.DontCare);
         commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
         pipeline.SetViewport(commandBuffer, nextProcess);
         pipeline.DrawCopy(commandBuffer);
     }
     commandBuffer.SetRenderTarget(
         context.target0,
         (Properties.StencilCompare != CompareFunction.Always)?
         RenderBufferLoadAction.Load    :
         RenderBufferLoadAction.DontCare,
         RenderBufferStoreAction.Store,
         pipeline.DepthStencilBuffer,
         RenderBufferLoadAction.Load,
         RenderBufferStoreAction.DontCare);
     commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
     pipeline.SetViewport(commandBuffer, nextProcess);
     pipeline.DrawFill(commandBuffer, material, 0);
     context.duplicated = false;
     return(true);
 }
Exemplo n.º 2
0
 public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                         CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
 {
     if (context.CompareSource0ToTarget0() != false)
     {
         int temporary = pipeline.GetTemporaryRT();
         if (nextProcess == null)
         {
             commandBuffer.Blit(context.source0, temporary);
             context.SetSource0(temporary);
         }
         else
         {
             context.SetTarget0(temporary);
         }
     }
     commandBuffer.SetRenderTarget(
         context.target0,
         RenderBufferLoadAction.DontCare,
         RenderBufferStoreAction.Store,
         RenderBufferLoadAction.DontCare,
         RenderBufferStoreAction.DontCare);
     commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
     pipeline.SetViewport(commandBuffer, nextProcess);
     pipeline.DrawFill(commandBuffer, material, 0);
     context.duplicated = false;
     return(true);
 }
Exemplo n.º 3
0
 public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                         CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
 {
     commandBuffer.ClearRenderTarget(
         Properties.ClearDepth,
         Properties.ClearColor,
         Properties.Color,
         Properties.Depth);
     context.duplicated = false;
     return(false);
 }
 void RecycleTemporaryRT(TargetContext context)
 {
     foreach (var userdTemporary in usedTemporaries.Values)
     {
         if (context.ConfirmUsePropertyId(userdTemporary.propertyId) == false)
         {
             if (recycleTemporaries.ContainsKey(userdTemporary.propertyId) == false)
             {
                 recycleTemporaries.Add(userdTemporary.propertyId, userdTemporary);
             }
         }
     }
 }
Exemplo n.º 5
0
 public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                         CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
 {
     commandBuffer.SetRenderTarget(
         Properties.GetInternalStripLut(),
         RenderBufferLoadAction.DontCare,
         RenderBufferStoreAction.Store,
         RenderBufferLoadAction.DontCare,
         RenderBufferStoreAction.DontCare);
     commandBuffer.SetGlobalTexture("_Curves", Properties.GetCurveTexture(false));
     pipeline.SetViewport(commandBuffer, nextProcess);
     pipeline.DrawFill(commandBuffer, material, 0);
     context.duplicated = false;
     return(true);
 }
Exemplo n.º 6
0
        public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                                CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
        {
            if (context.CompareSource0ToTarget0() != false)
            {
                int temporary = pipeline.GetTemporaryRT();
                if (nextProcess == null)
                {
                    commandBuffer.Blit(context.source0, temporary);
                    context.SetSource0(temporary);
                }
                else
                {
                    context.SetTarget0(temporary);
                }
            }
            /**/
            var blurTarget = new RenderTargetIdentifier(kShaderTargetBlur);

            commandBuffer.GetTemporaryRT(kShaderTargetBlur, descriptor, FilterMode.Point);

            commandBuffer.SetRenderTarget(
                blurTarget,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.Store,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.DontCare);
            commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
            pipeline.DrawFill(commandBuffer, material, 0);

            /**/
            commandBuffer.SetRenderTarget(
                context.target0,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.Store,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.DontCare);
            commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
            commandBuffer.SetGlobalTexture(kShaderPropertyBlurTex, blurTarget);
            pipeline.SetViewport(commandBuffer, nextProcess);
            pipeline.DrawFill(commandBuffer, material, 1);

            commandBuffer.ReleaseTemporaryRT(kShaderTargetBlur);
            context.duplicated = false;
            return(true);
        }
Exemplo n.º 7
0
 public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                         CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
 {
     return(false);
 }
Exemplo n.º 8
0
        public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                                CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
        {
            if (context.CompareSource0ToTarget0() != false)
            {
                int temporary = pipeline.GetTemporaryRT();
                if (nextProcess == null)
                {
                    commandBuffer.Blit(context.source0, temporary);
                    context.SetSource0(temporary);
                }
                else
                {
                    context.SetTarget0(temporary);
                }
            }
            var brightnessExtractionTarget = new RenderTargetIdentifier(kShaderPropertyBrightnessExtractionTarget);

            commandBuffer.GetTemporaryRT(kShaderPropertyBrightnessExtractionTarget, brightnessExtractionDescriptor, FilterMode.Bilinear);

            commandBuffer.SetRenderTarget(
                brightnessExtractionTarget,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.Store,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.DontCare);
                #if WITH_CLEARRENDERTARGET
            commandBuffer.ClearRenderTarget(false, true, Color.clear, 0);
                #endif
            commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
            commandBuffer.DrawMesh(brightnessExtractionMesh, Matrix4x4.identity, material, 0, 0);

            var gaussianBlurHorizontalTarget = new RenderTargetIdentifier(kShaderPropertyGaussianBlurHorizontalTarget);
            commandBuffer.GetTemporaryRT(kShaderPropertyGaussianBlurHorizontalTarget, blurDescriptor, FilterMode.Bilinear);

            commandBuffer.SetRenderTarget(
                kShaderPropertyGaussianBlurHorizontalTarget,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.Store,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.DontCare);
                #if WITH_CLEARRENDERTARGET
            commandBuffer.ClearRenderTarget(false, true, Color.clear, 0);
                #endif
            commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, brightnessExtractionTarget);
            commandBuffer.DrawMesh(blurHorizontalMesh, Matrix4x4.identity, material, 0, 1);

            var gaussianBlurVerticalTarget = new RenderTargetIdentifier(kShaderPropertyGaussianBlurVerticalTarget);
            commandBuffer.GetTemporaryRT(kShaderPropertyGaussianBlurVerticalTarget, blurDescriptor, FilterMode.Bilinear);

            commandBuffer.SetRenderTarget(
                gaussianBlurVerticalTarget,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.Store,
                RenderBufferLoadAction.DontCare,
                RenderBufferStoreAction.DontCare);
                #if WITH_CLEARRENDERTARGET
            commandBuffer.ClearRenderTarget(false, true, Color.clear, 0);
                #endif
            commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, kShaderPropertyGaussianBlurHorizontalTarget);
            commandBuffer.DrawMesh(blurVerticalMesh, Matrix4x4.identity, material, 0, 1);

            if (combinePassCount > 1)
            {
                commandBuffer.SetRenderTarget(
                    gaussianBlurHorizontalTarget,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.Store,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.DontCare);
                        #if WITH_CLEARRENDERTARGET
                commandBuffer.ClearRenderTarget(false, true, Color.clear, 0);
                        #endif
                commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, gaussianBlurVerticalTarget);
                commandBuffer.DrawMesh(combineMesh, Matrix4x4.identity, material, 0, 2);
                commandBuffer.SetGlobalTexture(kShaderPropertyBloomTex, gaussianBlurVerticalTarget);
                commandBuffer.SetGlobalTexture(kShaderPropertyBloomCombinedTex, kShaderPropertyGaussianBlurHorizontalTarget);
            }
            else
            {
                commandBuffer.SetGlobalTexture(kShaderPropertyBloomCombinedTex, gaussianBlurVerticalTarget);
            }
            commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);

            if (((nextProcess as PostProcess)?.DuplicateMRT() ?? false) != false)
            {
                int temporary = pipeline.GetTemporaryRT();
                context.SetTarget1(temporary);
                commandBuffer.SetRenderTarget(
                    new RenderTargetBinding(
                        new [] { context.target0, context.target1 },
                        new [] { RenderBufferLoadAction.DontCare, RenderBufferLoadAction.DontCare },
                        new [] { RenderBufferStoreAction.Store, RenderBufferStoreAction.Store },
                        context.depthBuffer,
                        RenderBufferLoadAction.DontCare,
                        RenderBufferStoreAction.DontCare));
                pipeline.SetViewport(commandBuffer, nextProcess);
                pipeline.DrawFill(commandBuffer, material, 4);
                context.duplicated = true;
            }
            else
            {
                commandBuffer.SetRenderTarget(
                    context.target0,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.Store,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.DontCare);
                pipeline.SetViewport(commandBuffer, nextProcess);
                pipeline.DrawFill(commandBuffer, material, 3);
                context.duplicated = false;
            }
            commandBuffer.ReleaseTemporaryRT(kShaderPropertyGaussianBlurVerticalTarget);
            commandBuffer.ReleaseTemporaryRT(kShaderPropertyGaussianBlurHorizontalTarget);
            commandBuffer.ReleaseTemporaryRT(kShaderPropertyBrightnessExtractionTarget);
            return(true);
        }
Exemplo n.º 9
0
 public abstract bool BuildCommandBuffer(RenderPipeline pipeline,
                                         CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess);
Exemplo n.º 10
0
        public override bool BuildCommandBuffer(RenderPipeline pipeline,
                                                CommandBuffer commandBuffer, TargetContext context, IPostProcess nextProcess)
        {
            if (context.CompareSource0ToTarget0() != false)
            {
                int temporary = pipeline.GetTemporaryRT();
                if (nextProcess == null)
                {
                    commandBuffer.Blit(context.source0, temporary);
                    context.SetSource0(temporary);
                }
                else
                {
                    context.SetTarget0(temporary);
                }
            }
            if (Properties.DebugMode != false)
            {
                commandBuffer.SetRenderTarget(
                    context.target0,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.Store,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.DontCare);
                commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
                pipeline.SetViewport(commandBuffer, nextProcess);
                pipeline.DrawFill(commandBuffer, material, 0);
            }
            else
            {
                /**/
                var shadeTarget = new RenderTargetIdentifier(kShaderTargetShade);
                commandBuffer.GetTemporaryRT(kShaderTargetShade, shadeDescriptor, FilterMode.Bilinear);

                commandBuffer.SetRenderTarget(
                    shadeTarget,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.Store,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.DontCare);
                if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal)
                {
                    commandBuffer.ClearRenderTarget(false, true, Color.black, 0);
                }
                commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
                pipeline.DrawFill(commandBuffer, material, 0);

                /**/
                var halfTarget = new RenderTargetIdentifier(kShaderTargetHalf);
                commandBuffer.GetTemporaryRT(kShaderTargetHalf, halfDescriptor, FilterMode.Bilinear);

                commandBuffer.SetRenderTarget(
                    halfTarget,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.Store,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.DontCare);
                if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal)
                {
                    commandBuffer.ClearRenderTarget(false, true, Color.black, 0);
                }
                commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, shadeTarget);
                pipeline.DrawFill(commandBuffer, material, 1);

                /**/
                var quarterTarget = new RenderTargetIdentifier(kShaderTargetQuarter);
                commandBuffer.GetTemporaryRT(kShaderTargetQuarter, quarterDescriptor, FilterMode.Bilinear);

                commandBuffer.SetRenderTarget(
                    quarterTarget,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.Store,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.DontCare);
                if (SystemInfo.graphicsDeviceType == GraphicsDeviceType.Metal)
                {
                    commandBuffer.ClearRenderTarget(false, true, Color.black, 0);
                }
                commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, halfTarget);
                pipeline.DrawFill(commandBuffer, material, 1);

                /**/
                commandBuffer.SetRenderTarget(
                    context.target0,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.Store,
                    RenderBufferLoadAction.DontCare,
                    RenderBufferStoreAction.DontCare);
                commandBuffer.SetGlobalTexture(ShaderProperty.MainTex, context.source0);
                commandBuffer.SetGlobalTexture(kShaderPropertyBlurTex, quarterTarget);
                pipeline.DrawFill(commandBuffer, material, 2);

                commandBuffer.ReleaseTemporaryRT(kShaderTargetShade);
                commandBuffer.ReleaseTemporaryRT(kShaderTargetHalf);
                commandBuffer.ReleaseTemporaryRT(kShaderTargetQuarter);
            }
            context.duplicated = false;
            return(true);
        }
Exemplo n.º 11
0
        void RebuildCommandBuffers()
        {
            var          depthTextureMode = defaultDepthTextureMode;
            bool         highDynamicRangeTarget = false;
            bool         forceIntoRenderTexture = false;
            IPostProcess nextProcess, process;
            int          i0;

            /* 既存のコマンドバッファを解放する */
            RemoveCommandBuffers();

            /* 有効なプロセス数を求める */
            int enabledOpaqueProcessCount = EnabledProcessCount(
                caches, PostProcessEvent.BeforeImageEffectsOpaque,
                ref depthTextureMode, ref highDynamicRangeTarget);
            int enabledProcessCount = EnabledProcessCount(
                caches, PostProcessEvent.BeforeImageEffects,
                ref depthTextureMode, ref highDynamicRangeTarget);

            /* [2019.4.1f1]
             * SetTargetBuffers の引数に Display.main.*****Buffer を渡しても実機では正しく動作しない。
             * エディタ上では動作し、SetTargetBuffers を呼び出す前と同じ状態に戻る。
             * 実機では現状元に戻す方法が存在しないと思われる。
             * そのため以下の条件文はランタイム中に切り替わることは想定しない。
             */
            if (OverrideTargetBuffers == false)
            {
                if (overrideTargetEvent.GetPersistentEventCount() > 0)
                {
                    overrideTargetEvent.Invoke(null);
                }
                forceIntoRenderTexture = true;
                        #if UNITY_EDITOR
                cacheCamera.SetTargetBuffers(Display.main.colorBuffer, Display.main.depthBuffer);
                        #endif
            }
            else
            {
                int  targetWidth        = (int)((float)Screen.width * resolutionScale);
                int  targetHeight       = (int)((float)Screen.height * resolutionScale);
                bool refreshColorBuffer = colorBuffer == null || colorBuffer.width != targetWidth || colorBuffer.height != targetHeight;
                bool refreshDepthBuffer = depthBuffer == null || depthBuffer.width != targetWidth || depthBuffer.height != targetHeight;

                if (refreshColorBuffer != false || refreshDepthBuffer != false)
                {
                    if (overrideTargetEvent.GetPersistentEventCount() > 0)
                    {
                        overrideTargetEvent.Invoke(null);
                    }
                    cacheCamera.SetTargetBuffers(Display.main.colorBuffer, Display.main.depthBuffer);

                    if (refreshColorBuffer != false)
                    {
                        if (colorBuffer != null)
                        {
                            colorBuffer.Release();
                        }
                        var colorBufferFormat = RenderTextureFormat.ARGB32;

                        if (SystemInfo.SupportsRenderTextureFormat((RenderTextureFormat)overrideTargetFormat) != false)
                        {
                            colorBufferFormat = (RenderTextureFormat)overrideTargetFormat;
                        }
                        colorBuffer            = new RenderTexture(targetWidth, targetHeight, 0, colorBufferFormat);
                        colorBuffer.filterMode = FilterMode.Point;
                        colorBuffer.name       = "CameraPipeline::ColorBuffer";
                    }
                    if (refreshDepthBuffer != false)
                    {
                        if (depthBuffer != null)
                        {
                            depthBuffer.Release();
                        }
                        depthBuffer            = new RenderTexture(targetWidth, targetHeight, 24, RenderTextureFormat.Depth);
                        depthBuffer.filterMode = FilterMode.Point;
                        depthBuffer.name       = "CameraPipeline::DepthBuffer";
                    }
                }
                cacheCamera.SetTargetBuffers(colorBuffer.colorBuffer, depthBuffer.depthBuffer);
                cacheScreenWidth     = Screen.width;
                cacheScreenHeight    = Screen.height;
                cacheResolutionScale = resolutionScale;

                if (overrideTargetEvent.GetPersistentEventCount() > 0)
                {
                    overrideTargetEvent.Invoke(colorBuffer);
                }
                if ((depthTextureMode & DepthTextureMode.Depth) != 0 && OverrideCameraDepthTexture != false)
                {
                    commandBufferDepthTexture      = new CommandBuffer();
                    commandBufferDepthTexture.name = "CameraPipeline::DepthTexture";
                    commandBufferDepthTexture.Clear();
                    commandBufferDepthTexture.SetProjectionMatrix(Matrix4x4.Ortho(0, 1, 0, 1, 0, 1));
                    commandBufferDepthTexture.SetViewMatrix(Matrix4x4.identity);

                    RenderTextureFormat format = RenderTextureFormat.R8;

                    //EDGE(WebGL)だとRFloatが使えない;
                    if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RHalf) != false)
                    {
                        format = RenderTextureFormat.RHalf;
                    }
                    if (SystemInfo.SupportsRenderTextureFormat(RenderTextureFormat.RFloat) != false)
                    {
                        format = RenderTextureFormat.RFloat;
                    }
                    var overrideDepthTexture = new RenderTargetIdentifier(ShaderProperty.OverrideDepthTexture);
                    commandBufferDepthTexture.GetTemporaryRT(ShaderProperty.OverrideDepthTexture,
                                                             -1, -1, 0, FilterMode.Bilinear, format);
                    commandBufferDepthTexture.SetRenderTarget(
                        overrideDepthTexture,
                        RenderBufferLoadAction.DontCare,
                        RenderBufferStoreAction.Store,
                        RenderBufferLoadAction.DontCare,
                        RenderBufferStoreAction.DontCare);
                    commandBufferDepthTexture.SetGlobalTexture(ShaderProperty.MainTex, depthBuffer);
                    DrawCopy(commandBufferDepthTexture);
                    commandBufferDepthTexture.SetGlobalTexture(ShaderProperty.CameraDepthTexture, overrideDepthTexture);
                    cacheCamera.AddCommandBuffer(CameraEvent.AfterForwardOpaque, commandBufferDepthTexture);
                }
            }
            /* 不透明系プロセス */
            if (enabledOpaqueProcessCount > 0)
            {
                commandBufferOpaqueProcesses      = new CommandBuffer();
                commandBufferOpaqueProcesses.name = "CameraPipeline::OpaqueProcesses";
                commandBufferOpaqueProcesses.Clear();
                commandBufferOpaqueProcesses.SetProjectionMatrix(Matrix4x4.Ortho(0, 1, 0, 1, 0, 1));
                commandBufferOpaqueProcesses.SetViewMatrix(Matrix4x4.identity);
                ResetTemporaryRT(commandBufferOpaqueProcesses);

                var context = new TargetContext();

                if (OverrideTargetBuffers == false)
                {
                    context.SetBuffers();
                    context.SetSource0(BuiltinRenderTextureType.CameraTarget);
                    context.SetTarget0(BuiltinRenderTextureType.CameraTarget);
                }
                else
                {
                    context.SetBuffers(colorBuffer, depthBuffer);
                    context.SetSource0(colorBuffer);
                    context.SetTarget0(colorBuffer);
                }
                for (i0 = 0, process = null; i0 < caches.Length; ++i0)
                {
                    nextProcess = caches[i0];

                    if (nextProcess?.GetPostProcessEvent() != PostProcessEvent.BeforeImageEffectsOpaque)
                    {
                        continue;
                    }
                    if (nextProcess.Valid() != false)
                    {
                        if (nextProcess is IUbarProcess ubarProcess)
                        {
                            if (ubarProcess.Independent() == false)
                            {
                                continue;
                            }
                        }
                        if (process != null)
                        {
                            RecycleTemporaryRT(context);

                            if (process.BuildCommandBuffer(this, commandBufferOpaqueProcesses, context, nextProcess) != false)
                            {
                                context.Next();
                            }
                        }
                        process = nextProcess;
                    }
                }
                if (process != null)
                {
                    RecycleTemporaryRT(context);

                    if (OverrideTargetBuffers == false)
                    {
                        context.SetTarget0(BuiltinRenderTextureType.CameraTarget);
                    }
                    else
                    {
                        context.SetTarget0(colorBuffer);
                    }
                    process.BuildCommandBuffer(this, commandBufferOpaqueProcesses, context, null);
                }
                ReleaseTemporaryRT();
                cacheCamera.AddCommandBuffer(CameraEvent.BeforeImageEffectsOpaque, commandBufferOpaqueProcesses);
            }
            /* 半透明系プロセス+FinalPass */
            if (enabledProcessCount > 0 || OverrideTargetBuffers != false)
            {
                commandBufferPostProcesses      = new CommandBuffer();
                commandBufferPostProcesses.name = "CameraPipeline::PostProcesses";
                commandBufferPostProcesses.Clear();
                commandBufferPostProcesses.SetProjectionMatrix(Matrix4x4.Ortho(0, 1, 0, 1, 0, 1));
                commandBufferPostProcesses.SetViewMatrix(Matrix4x4.identity);
                ResetTemporaryRT(commandBufferPostProcesses);

                if (enabledProcessCount > 0)
                {
                    var context = new TargetContext();

                    if (OverrideTargetBuffers == false)
                    {
                        context.SetBuffers();
                        context.SetSource0(BuiltinRenderTextureType.CameraTarget);
                        context.SetTarget0(BuiltinRenderTextureType.CameraTarget);
                    }
                    else
                    {
                        context.SetBuffers(colorBuffer, depthBuffer);
                        context.SetSource0(colorBuffer);
                        context.SetTarget0(colorBuffer);
                    }
                    for (i0 = 0, process = null; i0 < caches.Length; ++i0)
                    {
                        nextProcess = caches[i0];

                        if (nextProcess?.GetPostProcessEvent() != PostProcessEvent.BeforeImageEffects)
                        {
                            continue;
                        }
                        if (nextProcess.Valid() != false)
                        {
                            if (nextProcess is IUbarProcess ubarProcess)
                            {
                                if (ubarProcess.Independent() == false)
                                {
                                    continue;
                                }
                            }
                            if (process != null)
                            {
                                RecycleTemporaryRT(context);

                                if (process.BuildCommandBuffer(this, commandBufferPostProcesses, context, nextProcess) != false)
                                {
                                    context.Next();
                                }
                            }
                            process = nextProcess;
                        }
                    }
                    if (process != null)
                    {
                        RecycleTemporaryRT(context);

                        if (OverrideTargetBuffers != false && overrideTargetEvent.GetPersistentEventCount() > 0)
                        {
                            context.SetTarget0(colorBuffer);
                        }
                        else
                        {
                            context.SetTarget0(BuiltinRenderTextureType.CameraTarget);
                        }
                        process.BuildCommandBuffer(this, commandBufferPostProcesses, context, null);
                    }
                    ReleaseTemporaryRT();
                }
                else if (overrideTargetEvent.GetPersistentEventCount() == 0)
                {
                    commandBufferPostProcesses.SetRenderTarget(
                        BuiltinRenderTextureType.CameraTarget,
                        RenderBufferLoadAction.DontCare,
                        RenderBufferStoreAction.Store,
                        RenderBufferLoadAction.DontCare,
                        RenderBufferStoreAction.DontCare);
                    commandBufferPostProcesses.SetViewport(new Rect(0, 0, Screen.width, Screen.height));
                    commandBufferPostProcesses.SetGlobalTexture(ShaderProperty.MainTex, colorBuffer);
                    DrawCopy(commandBufferPostProcesses);
                }
                if (OverrideCameraDepthTexture != false)
                {
                    commandBufferPostProcesses.ClearRenderTarget(true, false, Color.clear, 1.0f);

                    if ((depthTextureMode & DepthTextureMode.Depth) != 0)
                    {
                        commandBufferPostProcesses.ReleaseTemporaryRT(ShaderProperty.OverrideDepthTexture);
                        depthTextureMode &= ~DepthTextureMode.Depth;
                    }
                }
                cacheCamera.AddCommandBuffer(CameraEvent.BeforeImageEffects, commandBufferPostProcesses);
            }
            cacheCamera.allowHDR               = highDynamicRangeTarget;
            cacheCamera.depthTextureMode       = depthTextureMode;
            cacheCamera.forceIntoRenderTexture = forceIntoRenderTexture;
            isRebuildCommandBuffers            = false;
        }