void GenerateGaussianMips(CustomPassContext ctx) { RTHandle source = (targetColorBuffer == TargetBuffer.Camera) ? ctx.cameraColorBuffer : ctx.customColorBuffer.Value; // Save the non blurred color into a copy if the mask is enabled: if (useMask) { ctx.cmd.CopyTexture(source, colorCopy); } var targetBuffer = (useMask) ? downSampleBuffer : source; CustomPassUtils.GaussianBlur(ctx, source, targetBuffer, blurBuffer, radius: radius); if (useMask) { // Merge the non blur copy and the blurred version using the mask buffers using (new ProfilingScope(ctx.cmd, new ProfilingSampler("Compose Mask Blur"))) { var compositingProperties = new MaterialPropertyBlock(); compositingProperties.SetFloat(ShaderID._Radius, radius / 4f); // The blur is 4 pixel wide in the shader compositingProperties.SetTexture(ShaderID._Source, downSampleBuffer); compositingProperties.SetTexture(ShaderID._ColorBufferCopy, colorCopy); compositingProperties.SetTexture(ShaderID._Mask, maskBuffer); compositingProperties.SetTexture(ShaderID._MaskDepth, maskDepthBuffer); compositingProperties.SetFloat(ShaderID._InvertMask, invertMask ? 1 : 0); SetViewPortSize(ctx.cmd, compositingProperties, source); HDUtils.DrawFullScreen(ctx.cmd, compositeMaterial, source, compositingProperties, shaderPassId: 0); // Do not forget the shaderPassId: ! or it won't work } } }
protected override void Execute(CustomPassContext ctx) { float radius = 8.0f; // make radius screen size dependent to have blur size consistent accross dimensions. radius *= ctx.cameraColorBuffer.rtHandleProperties.rtHandleScale.x; CustomPassUtils.GaussianBlur( ctx, ctx.cameraColorBuffer, ctx.cameraColorBuffer, halfResTarget, new Vector4(0.5f, 0.5f, 0, 0), new Vector4(0.5f, 0.5f, 0, 0), 4, radius / 2, 0, 0, true ); CustomPassUtils.GaussianBlur( ctx, ctx.cameraColorBuffer, ctx.cameraColorBuffer, halfResTarget, new Vector4(0.5f, 0.5f, 0.5f, 0), new Vector4(0.5f, 0.5f, 0.5f, 0), 16, radius, 0, 0, false ); CustomPassUtils.GaussianBlur( ctx, ctx.cameraColorBuffer, ctx.cameraColorBuffer, ctx.customColorBuffer.Value, new Vector4(0.5f, 0.5f, 0.5f, 0.5f), new Vector4(0.5f, 0.5f, 0.5f, 0.5f), 16, radius * 2, 0, 0, false ); CustomPassUtils.GaussianBlur( ctx, ctx.cameraColorBuffer, ctx.cameraColorBuffer, ctx.customColorBuffer.Value, new Vector4(0.5f, 0.5f, 0, 0.5f), new Vector4(0.5f, 0.5f, 0, 0.5f), 64, radius * 4, 0, 0, true ); }
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); }
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); }
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); ShaderTagId[] litForwardTags = { HDShaderPassNames.s_ForwardOnlyName, HDShaderPassNames.s_ForwardName, HDShaderPassNames.s_SRPDefaultUnlitName }; var result = new RendererListDesc(litForwardTags, ctx.cullingResults, ctx.hdCamera.camera) { rendererConfiguration = PerObjectData.None, renderQueueRange = RenderQueueRange.transparent, sortingCriteria = SortingCriteria.CommonTransparent, excludeObjectMotionVectors = false, layerMask = uiLayer, }; CoreUtils.DrawRendererList(ctx.renderContext, ctx.cmd, RendererList.Create(result)); }