I created a Custom Pass Volume and created a FullScreenPass Shader that simply offsets the Normal for testing purpose.
I want to read & write the normal.
When I select the injection point “After Post Process” and simply return a float4 in my Pass, I see the normal COLOR. Great for debugging I guess. But I want to WRITE the normal.
How? In a normal Shader, I’d use:
EncodeIntoNormalBuffer(normalData, output.gBuffer1);
where “output” is a struct:
//FeatureName Standard
//GBuffer0 baseColor.r, baseColor.g, baseColor.b, specularOcclusion
//GBuffer1 normal.xy (1212), perceptualRoughness
//GBuffer2 f0.r, f0.g, f0.b, featureID(3) / coatMask(5)
//GBuffer3 bakedDiffuseLighting.rgb
struct FragmentOutput {
float4 gBuffer0 : SV_Target0;
float4 gBuffer1 : SV_Target1;
float4 gBuffer2 : SV_Target2;
float4 gBuffer3 : SV_Target3;
};
I think I got those comments from the Forum or the Documentation of HDRP.
Anyway, returning a float4 shows me the Color in “After Post Process” Injection Point - as it doesn’t expect any normals. But in “AfterOpaqueAndNormal” Injection Point it doesn’t show any change, not even when I return my FragmentOutput struct with the SV_Targets - I was thinking I would be targetting the gbuffer for the normal Data…
The documentation even says this for AfterOpaqueDepthAndNormal:
Buffers will contain all opaque objects. Here you can modify the normal, roughness and depth buffer, it will be taken in account in the lighting and the depth pyramid. Note that normals and roughness are in the same buffer, you can use DecodeFromNormalBuffer and EncodeIntoNormalBuffer functions to read/write normal and roughness data
- Note the last Part: “you can use … EncodeIntoNormalBuffer…” - but HOW? by returning a struct? I do I need some inout/out variable as a parameter? Or maybe a special Tag in my Pass? This is no where doucmented - or I can’t find it.
@antoinel_unity has some examples on his GitHub, but I don’t see any GBuffer Tags or similar in the code… I only see the depth being written by a “inout depth” parameter.
How do I write Normals in a Fullscreen Custom Pass in HDRP, at the “AfterOpaqueDepthAndNormal” Injection Point.
Thanks!

