HDRP PostProcess StdLib include issues

Hi, I’m trying to write post process compatible with the HDRP post process stack. But I’m running into issues with my includes. I was rewriting an experimental SSGI that I did for built-in pipeline forward rendering in the past, where I use stuff from “UnityCG.cginc”. Which I as I understand now have to substitude with functionality provided in “StdLib.hlsl”.
For now, the whole shader code is pretty much empty, just returns a float4(1, 0, 0, 1); in the frag function, so the code overall shouldn’t be important at all, apart for the includes.

My minimal that I’m working with for now are:

    #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
    #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
    #include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"

But the include of StdLib.hlsl results in

Shader error in 'Hidden/Shader/SSGI': redefinition of 'Min3' at /Projekty/TestProject/UnityProject/TestProject/Library/PackageCache/com.unity.postprocessing@2.3.0/PostProcessing/Shaders/StdLib.hlsl(72) (on d3d11)

Compiling Vertex program
Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR

Unity 2019.3.15f1
HDRP 7.3.1
Post Processing 2.3.0

(Edit: is the same with Unity 2020.1.0b14 + HDRP 8.1.0 + PostProcessing 2.3.0)

Can someone help me with what should I do to be able to use StdLib.hlsl functionality here? Honestly feels like a bug to me that this is happening, though I’m still hoping for some stupid error on my part. Getting very desperate with the whole HDRP+PostProcessing+Deferred rendering approach after just 2 days of testing it out.


On a related note, is there -any- resource on what I can even work with in regards of shaders functionality? Documentation how to read depth and normal buffers, transfer depth to world space, anything actually documenting functionality available to us? I’m just trying to decipher some random codes I stumble upon for other effects, but that’s not really how programming should ideally work (though it sadly does more often than not). Some shader+postprocessing API overview at least really for the new postprocessing stack/pipelines/rendering paths.
Anything describing what “includes” are available to us, and what funcs they have?

I forget which one I use, but you shouldn’t need to use both. Probably just stick to PostProcessing StdLib.

Welcome to the world of making PostFX in SRPs :slight_smile: Lovely isn’t it? My personal favourite is how there’s no longer even a forum for PostPro.

Short answer: No. Unity have some ‘heres how to blit’ documentation, the rest you have to reverse-engineer off the (few) effects that actually work or waste time playing around.

Thanks for the response. Regarding the original question, for some reason I’m sticking to using the Common.hlsl and other similarly situated includes. Turned out functionality I wanted from the StdLib one can be found under a different name in the others I guess. I honestly don’t even know what I’m using from where, but I ditched the StdLib for now :confused:

Besides that, yeah… yesterday+today was about finding out, how to work with lower resolution passes so I don’t have to calculate the SSGI in full 4k when I even get to it later on… What a total mess.

For some reason, the “source” RTHandle I get passed in the Render() func, I have to send to the shader/material as a “TEXTURE2D_X”, and sample from it using “LOAD_TEXTURE2D_X”.
While any other RTHandle I’m working with in lower resolution, I have to pass as “TEXTURE2D”, and not sample using “LOAD_TEXTURE2D” which I would expect, but must use “SAMPLE_TEXTURE2D”.
Literally sweating blood over here, reading some older forum posts and trying out individual lines from Keijiro’s repository. Totally blindly at this point, because even from the syntax I’d expect so many things to behave so differently than they do.

Not only there’s no documentation of what’s possible, but even behavior of 2 almost identical things like reading a texture doesn’t behave consistently in any way.

HOW IS THIS WHOLE THING NOT AN ALPHA VERSION

I’d do anything for at least a list of commands/macros, even without full description tbh. Searching any .hlsl or .shader file in Unity folders to suss the little hints I can get is not really helping anything anymore.

At least got working the blitting to lower resolution, getting worldspace normals and reconstructing worldspace coords from various buffers somehow. Not all working together yet but hopefully it will in a while. That alone I consider a miracle at this point.

1 Like