Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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:
    55
    Last edited: Jun 4, 2019
  2. remi_unity163

    remi_unity163

    Unity Technologies

    Joined:
    Jun 19, 2018
    Posts:
    16
    Hello,

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

    mashixuan8

    Joined:
    Nov 4, 2014
    Posts:
    22
    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:
    864
    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:
    28
    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:
    429
    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,437
    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,789
    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
  9. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    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:
    429
    manutoo, themeshpotato and themdubs like this.
  11. themeshpotato

    themeshpotato

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

    mutp

    Joined:
    Oct 1, 2018
    Posts:
    79
    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:
    55
    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:
    90
    @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:
    569
    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:
    21
    Any documentation?
     
  17. nehvaleem

    nehvaleem

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

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    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:
    569
  20. nasos_333

    nasos_333

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

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    569
    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:
    13,286
    Ok, thanks for the info, i hope porting effects will not be hard
     
  23. rz_0lento

    rz_0lento

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

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @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:
    1,553
    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:
    569
    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:
    1,553
    Too bad I missed it.
     
  28. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    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:
    429
    have you maybe ported v2 bloom using new setup?
     
  30. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    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:
    569
    Olmi likes this.
  32. LIVENDA_LABS

    LIVENDA_LABS

    Joined:
    Sep 23, 2013
    Posts:
    377
    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.
     
    GoGoGadget and Flurgle like this.
  33. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    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:
    569
    @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:
    1,553
    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:
    1,553
    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:
    377
    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:
    1,553
    @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
    Egad_McDad and LIVENDA_LABS like this.
  39. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    @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
    jister and LIVENDA_LABS like this.
  40. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    I know I'm probably talking to a wall here, but can anyone at Unity ( @remi_unity ?) actually give us developers some clarity as to how "locked" the API is at the moment?

    Right now, anyone wanting to develop a maintainable post-processing system in HDRP has Keijiro's hobby project to go off, no official documentation, no other word from Unity on what will change, when it will change, etc. And forgive me for having to ask, but for a developer such as myself who maintains a 2000+LoC full post-pro subsystem, given Unity's track record of changing their PP API every time the wind changes direction, I'd like to have some clarity, as I'm sure other asset developers would.

    I also don't see how Unity can be happy with the extensibility of HDRP post-processing in its current state, which is why I fear it will be changed again. @SebLagarde said the new post-processing allows for "better integration with PBR", "better quality", "better memory usage", "better performance" - but quite frankly, the design of the new C# effect-authoring side of post-processing is garbage. A 3000 LoC blob is Unity's idea of a modern, extensible post-processing system? How on earth does having to wade through 43 references to vignette in a C# file until you finally find the correct method 2000 lines down make sense, for those who want to tweak it? We are talking about the simplest effect in post-processing, something that could be achieved in Unity 4 or 5 in literally six lines of C# and a pixel shader, for the same quality, same memory usage, and same performance - and now it's part of this inextensible monstrosity. How is that a step forward?

    David Helgason's ethos back when he was CEO was for Unity to democratise game development, to save developers time and let us focus on actually making stuff. This new HDRP stack goes completely against that. Writing effects takes longer. Editing existing effects is source control suicide. Hell, developers can't even write one effect once and have it work on mobile (URP) and HDRP - how is that a benefit for anyone?
     
    Egad_McDad, fherbst and andybak like this.
  41. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,286
    This whole thing is one step forward in versatility and like a million steps back in every other way imaginable from what i see so far, the only hope is that they keep the standard pipeline and not force this new exponential complexity to every project, at least until is mature enough
     
    GoGoGadget likes this.
  42. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    The whole point of extending this from Unity's perspective is that they expose the injection points for custom passes and postprocessing passes. You are not meant to go tweaking existing effects unless you really can't do without. I dunno if there's ever been a game engine that would let you do what you are suggesting here (making each PP effect extendable out of the box). But even if you do need to tweak these effects, modifying the existing HDRP PP isn't THAT hard. It's just that since it's integrated, it does mean you have to mod it in the HDRP package.

    Docs for the Custom PP and Custom Passes:
    https://docs.unity3d.com/Packages/c...ml?subfolder=/manual/Custom-Post-Process.html
    https://docs.unity3d.com/Packages/c...index.html?subfolder=/manual/Custom-Pass.html
     
  43. GoGoGadget

    GoGoGadget

    Joined:
    Sep 23, 2013
    Posts:
    864
    Thanks for the docs links - if nothing else, the detail they've put into these makes me slightly more confident Unity won't throw out the current system in the very near future!
     
  44. Epic_Cube

    Epic_Cube

    Joined:
    Jul 3, 2012
    Posts:
    98
    Does custom effects work at all? I've a similar issue with LWRP and Android as described in this thread.
    Thank you in advance for your reply
     
  45. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553