Пример #1
0
    // This function is called from the custom post process at the before post process injection point, just after TAA
    public void RenderVideoObjects(CommandBuffer cmd)
    {
        // Fix depth buffer jittering
        if (fixDepthBufferJittering)
        {
            using (new ProfilingScope(cmd, new ProfilingSampler("Render Depth Buffer without jittering")))
            {
                // We need to re-render everything to get the non-jittered depth buffer :/
                CoreUtils.SetRenderTarget(cmd, videoDepthBuffer);
                CoreUtils.ClearRenderTarget(cmd, ClearFlag.Depth, Color.black);
                var tags   = new ShaderTagId[] { new ShaderTagId("DepthForwardOnly"), new ShaderTagId("DepthOnly") };
                var result = new RendererListDesc(tags, context.cullingResults, context.hdCamera.camera)
                {
                    rendererConfiguration      = PerObjectData.None,
                    renderQueueRange           = RenderQueueRange.all,
                    sortingCriteria            = SortingCriteria.CommonOpaque,
                    excludeObjectMotionVectors = false,
                    layerMask = fixDepthBufferJitteringMask,
                    // stateBlock = overrideRenderState,
                };
                CoreUtils.DrawRendererList(context.renderContext, context.cmd, RendererList.Create(result));
            }
        }

        // TODO: add an option to render the "frame" objects in the unjittered depth-buffer to avoid flickering
        CoreUtils.SetRenderTarget(cmd, videoColorBuffer, fixDepthBufferJittering ? videoDepthBuffer : context.cameraDepthBuffer, ClearFlag.Color);
        var renderState = new RenderStateBlock(RenderStateMask.Depth)
        {
            depthState = new DepthState(false, CompareFunction.LessEqual)
        };

        CustomPassUtils.DrawRenderers(context, videoObjectMask, overrideRenderState: renderState);
    }
Пример #2
0
    protected override void Execute(CustomPassContext ctx)
    {
        // This pass doesn't work with scene views
        if (ctx.hdCamera.camera.cameraType == CameraType.SceneView)
        {
            return;
        }

        CustomPassUtils.GaussianBlur(ctx, ctx.cameraColorBuffer, ctx.cameraColorBuffer, downSampleBuffer, radius: blurRadius);

        CoreUtils.SetRenderTarget(ctx.cmd, ctx.cameraColorBuffer, ctx.customDepthBuffer.Value, ClearFlag.DepthStencil, Color.clear);
        CustomPassUtils.DrawRenderers(ctx, uiLayer, RenderQueueType.Transparent, sorting: SortingCriteria.CommonOpaque);
    }
Пример #3
0
        protected override void Execute(CustomPassContext customPassContext)
        {
            if (targetLayer.value > 0)
            {
                CoreUtils.SetRenderTarget(customPassContext.cmd, rtBuffer);
                CustomPassUtils.DrawRenderers(customPassContext, targetLayer);
            }

            customPassContext.propertyBlock.SetTexture(BUFFER_TEXTURE, rtBuffer);
            ShaderProperty(customPassContext.propertyBlock);

            CoreUtils.SetRenderTarget(customPassContext.cmd, customPassContext.cameraColorBuffer);
            CoreUtils.DrawFullScreen(customPassContext.cmd, material, customPassContext.propertyBlock, shaderPassId: 0);
        }
Пример #4
0
    protected override void Execute(CustomPassContext ctx)
    {
        // Render meshes we want to outline in the outline buffer
        CoreUtils.SetRenderTarget(ctx.cmd, outlineBuffer, ClearFlag.Color);
        CustomPassUtils.DrawRenderers(ctx, outlineLayer);

        // Setup outline effect properties
        ctx.propertyBlock.SetColor("_OutlineColor", outlineColor);
        ctx.propertyBlock.SetTexture("_OutlineBuffer", outlineBuffer);
        ctx.propertyBlock.SetFloat("_Threshold", Mathf.Max(0.000001f, threshold * 0.01f));

        // Render the outline as a fullscreen alpha-blended pass on top of the camera color
        CoreUtils.DrawFullScreen(ctx.cmd, fullscreenOutline, ctx.cameraColorBuffer, shaderPassId: 0, properties: ctx.propertyBlock);
    }
Пример #5
0
    protected override void Execute(CustomPassContext ctx)
    {
        if (compositingMaterial == null)
        {
            Debug.LogError("Failed to load Liquid Pass Shaders");
            return;
        }

        CustomPassUtils.DrawRenderers(ctx, layerMask);

        // Blur the custom buffer:
        var resRadius = radius * ctx.cameraColorBuffer.rtHandleProperties.rtHandleScale.x;

        CustomPassUtils.GaussianBlur(ctx, ctx.customColorBuffer.Value, ctx.customColorBuffer.Value, blurBuffer, 25, resRadius);

        HandmadeFullscreenShaderGraphPass(ctx);
    }
Пример #6
0
    protected override void Execute(CustomPassContext ctx)
    {
        AllocateMaskBuffersIfNeeded();

        if (compositeMaterial != null && radius > 0)
        {
            if (useMask)
            {
                CoreUtils.SetRenderTarget(ctx.cmd, maskBuffer, maskDepthBuffer, ClearFlag.All);
                CustomPassUtils.DrawRenderers(ctx, maskLayer, overrideRenderState: new RenderStateBlock(RenderStateMask.Depth)
                {
                    depthState = new DepthState(true, CompareFunction.LessEqual)
                });
                // DrawMaskObjects(renderContext, cmd, hdCamera, cullingResult);
            }

            GenerateGaussianMips(ctx);
        }
    }
    protected override void Execute(CustomPassContext ctx)
    {
        CoreUtils.SetRenderTarget(ctx.cmd, temp, ClearFlag.Color);

        RenderStateBlock overrideDepth = new RenderStateBlock(RenderStateMask.Depth)
        {
            depthState = new DepthState(true, CompareFunction.LessEqual)
        };

        using (new CustomPassUtils.DisableSinglePassRendering(ctx))
        {
            using (new CustomPassUtils.OverrideCameraRendering(ctx, override1))
            {
                CustomPassUtils.DrawRenderers(ctx, overrideMask1a, overrideRenderState: overrideDepth);
                using (new CustomPassUtils.OverrideCameraRendering(ctx, override2))
                {
                    CustomPassUtils.DrawRenderers(ctx, overrideMask2);
                }
                CustomPassUtils.DrawRenderers(ctx, overrideMask1b);
            }
        }

        CustomPassUtils.Copy(ctx, temp, ctx.cameraColorBuffer, CustomPassUtils.fullScreenScaleBias, new Vector4(0.5f, 0.5f, 0.0f, 0.0f));
    }