Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

HDRP PostProcess StdLib include issues

Discussion in 'High Definition Render Pipeline' started by Lad-Ty, Jul 9, 2020.

  1. Lad-Ty


    May 7, 2013
    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:
    Code (CSharp):
    1.     #include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"
    2.     #include "Packages/com.unity.render-pipelines.high-definition/Runtime/ShaderLibrary/ShaderVariables.hlsl"
    3.     #include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"
    But the include of StdLib.hlsl results in
    Code (CSharp):
    1. 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)
    3. Compiling Vertex program
    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?
    Last edited: Jul 9, 2020
  2. GoGoGadget


    Sep 23, 2013
    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 :) 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.
  3. Lad-Ty


    May 7, 2013
    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 :/

    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.


    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.
    GoGoGadget likes this.