Unity HDRP G-Buffer for post-processing

Antoine Fortin
3 min readMay 22, 2021

--

So last summer, I was working on migrating one of my colleague SSGI idea to Unity HDRP. While learning to work with HDRP, I explored a lot on how it changes from legacy rendering pipeline. During the process, I made a Youtube tutorial on how to write post-process in HDRP, it has been on Youtube! A lot of the comments on the Youtube tutorial were about “Can we have access to this file you copy paste?”. 100% guilty, I recorded this video without thinking about the context, I had just spend a week diging into HDRP without properly noting what I was doing. Once again, thanks to Olivier Therrien for the infinite amount of coaching he brought to me while working on migrating SSRT to HDRP PostProcess.

Won’t go on how to make a PostProcess Shader in HDRP

As I want this article to be quite straight to the point, we won’t go into setting a PostProcess in HDRP.

GBuffer in HDRP

If you try to access NormalWorldspace in HDRP the same way you deal with Legacy Rendering Pipeline, you will get these kind of shit.

HDRP does not clear the GBuffer.

I found that into HDRP the function to read information from related textures are defined with this macro:
In the file GLCore.hlsl

The parameters from LOAD_TEXTURE… they require a Pixel coordinate, this is why in the PostProcess the code is like this:

We can use the positionSSRegular to find the informations example the world normals.
The G Buffer is not cleared into HDRP as mentionned.

So in a post process.
What I did is make three functions to explain how I dealt with the required informations I needed to get in my post-process.
Exemple to get the Depth I use this as a function

It gives this:

Exemple to get the Normal WorldSpace. I use this:

The function is like this:

Wich gives:

The problem you have with the normalWS are because the Gbuffer is not cleared, so a simple trick you can do is to simple check if the Depth is > 0.0f

--

--

Antoine Fortin

In between Montreal and London, I love to write, read, learn and explore.