示例#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);
 }
示例#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);
 }
示例#3
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);
 }
示例#4
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);
        }
示例#5
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);
        }
示例#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);
                }
            }
            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);
        }