Search Unity

Custom post-processing effects with new HDRP workflow

Discussion in 'Image Effects' started by themeshpotato, Jun 4, 2019.

  1. themeshpotato

    themeshpotato

    Joined:
    Apr 11, 2018
    Posts:
    48
    Last edited: Jun 4, 2019
  2. remi_unity163

    remi_unity163

    Unity Technologies

    Joined:
    Jun 19, 2018
    Posts:
    13
    Hello,

    This is a work planed for 2019.3
     
    themeshpotato likes this.
  3. mashixuan8

    mashixuan8

    Joined:
    Nov 4, 2014
    Posts:
    7
    Hi, I am in desperate need for custom post processing effect too.
    In roughly which iteration of the 2019.3a will the custom post processing be supported?
     
  4. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    667
    Hi remi,

    Given 2019.3 is already in alpha, can you please expand on how custom effects implementation will (broadly) require changes? I assume you guys already have an idea, and any information you can share would be greatly appreciated by the number of developers who create third party post-processing effects for users.
     
  5. bloodthirst69

    bloodthirst69

    Joined:
    Oct 1, 2017
    Posts:
    4
    Hi , any updates on this ? i am currently looking to implement my own custom effects but seems like the new way doesn't allow to access the classes needed due to protection level , i tried inheriting from the "VolumeComponent" class but it only adds the custom effect's name and doesn't expose a "Render" function to override to do the stuff needed , any kind of info would be appreciated
     
    themeshpotato likes this.
  6. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    24
    I am also in the desperate need of custom post processing in hdrp in 2019. Can we please get an update or some info at least?
     
    Velo222 and themeshpotato like this.
  7. Velo222

    Velo222

    Joined:
    Apr 29, 2012
    Posts:
    1,320
    Just posting to add my voice to this. I want to make a custom post-processing effect with the new HD Renderpipeline. But I don't really know where to start. Are there any tutorials on how to work with custom post-processing effects in HDRP?

    I'm guessing that is what Remi means by they are working on it for 2019.3. Unity doesn't have the "infrastructure" to customize the post-processing effects yet?
     
  8. chingwa

    chingwa

    Joined:
    Dec 4, 2009
    Posts:
    3,403
    This is currently a huge hole in HDRP and keeps it from being a serious system for game development. Without custom post-process capability HDRP will remain nothing but a shiny toybox.
     
    Last edited: Aug 7, 2019
    BrandStone and themeshpotato like this.
  9. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    223
    I posted it elsewhere but Keijiro has come up with a technique. Not sure where on the "sane" to "hacky" spectrum it sits: https://github.com/keijiro/HdrpAovTest

    Any official word from Unity on whether this is good way forward would be nice. (any official word on post processing would be nice right now)
     
  10. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    24
    manutoo, themeshpotato and themdubs like this.
  11. themeshpotato

    themeshpotato

    Joined:
    Apr 11, 2018
    Posts:
    48
  12. mutp

    mutp

    Joined:
    Oct 1, 2018
    Posts:
    4
    It doesn't look like its implemented in 2019.3b (beta). Are we sure this is coming in 2019.3? Or has it been pushed to a later release?
     
    themeshpotato likes this.
  13. themeshpotato

    themeshpotato

    Joined:
    Apr 11, 2018
    Posts:
    48
    Yeah, I would like to know as well. I dont' like the fact that it has not been mentioned in any release log yet.
     
  14. BitAssembler

    BitAssembler

    Joined:
    Jul 13, 2017
    Posts:
    62
    @remi_unity163 Any news on this one? Will custom pfx be available as the HDRP goes out of preview?
     
  15. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    223
    I managed to get it working this morning: https://github.com/IxxyXR/HDRP-Custom-Post-Processing-Test

    I had to edit manifest.json to get the next version 7.1.1 of HDRP a bit early and comment out a block of XR related code that was causing an error - but custom PP works in HDRP as of today!
     
    LIVENDA_LABS likes this.
  16. jacodavis

    jacodavis

    Joined:
    Sep 18, 2019
    Posts:
    5
    Any documentation?
     
  17. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    24
  18. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    223
    I'm not entirely clear myself at the moment (I'm writing this from memory as I'm not near my Unity laptop now) but I think Custom Passes are slightly different from Custom Post Processing Effects with the latter being slightly simpler to set up.

    Here are the three files to refer to in my repo:

    https://github.com/IxxyXR/HDRP-Custom-Post-Processing-Test/blob/master/Packages/manifest.json

    https://github.com/IxxyXR/HDRP-Custom-Post-Processing-Test/blob/master/Assets/NewPostProcessVolume.cs

    https://github.com/IxxyXR/HDRP-Custom-Post-Processing-Test/blob/master/Assets/New Post Process Shader.shader

    Procedure was something like:

    1. Edit manifest.json to reference 7.1.1 of "com.unity.render-pipelines.high-definition" and "com.unity.shadergraph" as that version doesn't currently show up in the package manager UI. After Unity finishes loaded those packages find there is an #if block in one of the scripts that might throw an error - I just commented it out for now as it was XR related

    2. Right click and create a new Post processing script (it's a specific option in the create menu) and a PP shader (or use the scripts in my repo as an example). Check the shader references the script name correctly (see line 21 in mine)

    3. Go to Project Settings/HDRP Defaults and scroll down to the bottom. Add the effect to the section (
    Before Rendering/Before Transparent/Before PostProcess) that corresponds to what you put in your cs script (see line 16 in mine)

    4. Add a Volume in your scene. Your effect should now appear in "Add overrides" as a new item under Post Processing/Custom

    I think this should work on 2019.3 but I used the 2020 alpha.

    I'll try and remember check this later for accuracy and edit if I've missed a step.
     
    eric_delappe and themeshpotato like this.
  19. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    223
  20. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    7,889
    Great news, is this same as custom forward render structure in LWRP ?
     
  21. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    223
    Don't think so. This is very specific to post-processing. The custom renderer stuff in URP/LWRP seems broader (although to be fair I don't currently quite understand what it's capable of)
     
    nasos_333 likes this.
  22. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    7,889
    Ok, thanks for the info, i hope porting effects will not be hard
     
  23. rizu

    rizu

    Joined:
    Oct 8, 2013
    Posts:
    1,226
    There is separate Custom Pass on HDRP now as well.
     
  24. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    578
    @andybak is there anything specific this setup needs? I just started digging more into HDRP and dl'ed your example, which seemed to work fine, saw the depth step effect. However, now that I created a new shader and post effect via the menu in a new Unity project in 2019.3.0b6, nothing seems to happen. I've been looking at your scene and settings but so far I haven't managed to figure out what is the reason that nothing happens. Copied your files over to the project and the same result, nothing happens. I wonder if it's the HDRP version, HDRenderPipelineAsset settings or what exactly that causes this to fail.
     
  25. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    578
    Ok, now I got it. The very last place where I checked was the solution. You have to add the custom effect in the "Custom Post Process Orders" in HDRP Default Settings. I'd imagined if such list exists, they would go there automagically as they did with Stack v2 in 2018. Oh well. 1.5 hours wasted...
     
  26. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    223
    Yeah. That was the bit that held me up for the longest time too. (I did mention it in my post above as point 3.)
     
  27. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    578
    Too bad I missed it.
     
  28. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    578
    It was surprisingly painless to convert a few Stack v2 effects to this new setup, but still quite frustrating as too many things require using new this and that... I spent hours just trying out stuff to see what works. And that HDRP documentation is somewhat lacking for novices like myself. Hard to guess if I've done something totally wrong or not.
     
  29. nehvaleem

    nehvaleem

    Joined:
    Dec 13, 2012
    Posts:
    24
    have you maybe ported v2 bloom using new setup?
     
  30. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    578
    To avoid confusion, meant my own effects. But I don't think it would be that hard to create almost similar/clone of the old bloom. That new one does not look good.
     
  31. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    223
    Olmi likes this.
  32. LIVENDA_LABS

    LIVENDA_LABS

    Joined:
    Sep 23, 2013
    Posts:
    234
    These are very simple effects and there is a tone of stuff missing! Where are the DOCS? How do we generate 'World space normals! ' , how to access motion vectors, These are all rudimentary to say the least.
     
  33. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    578
    You can find HDRP documentation at:
    https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@6.5/manual/index.html
    And scripting API documentation here:
    https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@6.5/api/index.html

    Yes I know, they are not leading you by the hand but I think you can already find some solid information there, if you want to get started with HDRP. At least you see what methods are available and so on, if not clearly stated purpose for each thing (which is something I too would like to see.)
     
  34. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    223
    @LIVENDA_LABS was specifically talking about custom post-processing - and he's right - there is currently no documentation on that.

    Although to be fair it's only been out for a couple of weeks. (Not sure that's really an excuse. For most software "not having docs" is a blocker for release)
     
  35. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    578
    Well yes, but the entry point is probably the issue if you want to get started (i.e. how to get your stuff to screen, even if it's just an invert color effect.) And I too am wondering why the documentation is what it is...
     
  36. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    578
    Spent this afternoon converting the old bloom to HDRP, it's definitely doable, got it working already. I think I got a few small glitches still as I really don't know what all the macros do that existed in that v2 version.
     
  37. LIVENDA_LABS

    LIVENDA_LABS

    Joined:
    Sep 23, 2013
    Posts:
    234
    Can anyone help us get worldspace normals (not normals generated from depth) and motion vectors with the new HDRP PP pipeline would be greatly appreciated
     
  38. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    578
    @LIVENDA_LABS I did some digging last night... Just in case you still need help with this issue. I'm interested in developing HDRP content too so I thought I'd take a look.

    I did some source code reading, looks like DebugViewMaterialGBuffer.shader file has interesting information and same goes for ScreenSpaceReflections.compute. I just used Notepad++ and did file search in the HDRP package folder for words like 'normal'. Very handy. Then just search for these files inside HDRP package folder. Anyway;

    When you got your default volume effect and shader templates ready, include:
    Code (HLSL):
    1. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Material.hlsl"
    2. #include "Packages/com.unity.render-pipelines.high-definition/Runtime/Material/Lit/Lit.hlsl"
    Then, you find GetNormalAndPerceptualRoughness method in the ScreenSpaceReflections.compute.
    You can rip out the stuff you don't need but now you should be able to access normals.

    Just tried it out and I got the normals on screen.

    The motion vectors are then the next thing to tackle... Hope this helps?
     
    Last edited: Oct 11, 2019
    LIVENDA_LABS likes this.
  39. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    578
    @LIVENDA_LABS ScreenSpaceReflections.compute has also a section:
    Code (HLSL):
    1. float2 motionVectorNDC;
    2. DecodeMotionVector(SAMPLE_TEXTURE2D_X_LOD(_CameraMotionVectorsTexture, s_linear_clamp_sampler, min(hitPositionNDC, 1.0f - 0.5f * _ScreenSize.zw) * _RTHandleScale.xy, 0), motionVectorNDC);
    It looks like this provides motion vector data? I got something to my screen when I set camera to spin around an obj.

    I'm not sure if I did it correctly, but I can't invest more time into this at the moment. Anyway, I just replaced hitPositionNDC with input.texcoord and then I got this blue/cyan and purple thing on the screen which I suspect might look correct.

    And depth (even if you didn't need it atm) you can get with:
    Code (HLSL):
    1. // Get depth
    2. float depth = LOAD_TEXTURE2D_X(_CameraDepthTexture, positionSS).r;
     
    Last edited: Oct 11, 2019
    LIVENDA_LABS likes this.