I have been wanting to make a simple fullscreen custom pass for HDRP, with a shader made in shader graph. The custom pass would render objects to a buffer, and pass the buffer to the fullscreen material, like so:
CoreUtils.SetRenderTarget(ctx.cmd, buffer, ctx.cameraDepthBuffer, ClearFlag.Color);
for (int i = 0; i < renderer.sharedMaterials.Length; i++)
ctx.cmd.DrawRenderer(renderer, rendererMaterial, i, 6);
ctx.propertyBlock.SetTexture("_Buffer", buffer);
HDUtils.DrawFullScreen(ctx.cmd, fullscreenMaterial, ctx.cameraColorBuffer, ctx.cameraDepthBuffer, shaderPassId: pass, properties: ctx.propertyBlock);
And the shader graph samples it simply like so:
Unfortunately I ran into issues with this when changing window resolution (like Scene & Game view), where the buffer scaling is completely off:
In hlsl, this is fixed by multiplying the UVs with _RTHandleScale, as noted in the custom pass troubleshooting. But I’m not sure how to access _RTHandleScale through shader graph. I’ve tried importing "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariablesGlobal.cs.hlsl"
into a custom function, but I get an exception of "Redefinition of '_ViewMatrix' at line 20
.
Thank you for your help!