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

Official Post-processing and URP - The plan

Discussion in 'Universal Render Pipeline' started by Chman, Dec 17, 2019.

  1. liiir1985

    liiir1985

    Joined:
    Jul 30, 2014
    Posts:
    147
    Hello phil_lira, thanks for the reply, and I sent you the case id via DM. It contains the most common usage of UI particles in the project, and you can see how terrible it is with post processing enabled on UI
     
    phil_lira likes this.
  2. BattleAngelAlita

    BattleAngelAlita

    Joined:
    Nov 20, 2016
    Posts:
    400
    Basically nobody needs a camera shacking itself, everybody need a way to render something on top of UGUI.
     
    Ferazel and JesOb like this.
  3. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    Then my current understanding is that you can do it now with URP and builtin by using an additional camera. We have work planned to be able to do this without another camera in URP.
     
  4. liiir1985

    liiir1985

    Joined:
    Jul 30, 2014
    Posts:
    147
    If you make it possible to let ugui render particle and 3d objects, then we won't need camera stacking at all. The problem is, when. Before that, we have to stick with camera stacking which currently doesn't work well with post processing enabled(Like the bug I sent you vai private message)
     
  5. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    3,513
    I will still need camera stacking for other things, for example rendering a orthographic camera on top of a 3d camera
     
    Thygrrr, awesomedata and lloydhooson like this.
  6. liiir1985

    liiir1985

    Joined:
    Jul 30, 2014
    Posts:
    147
    This can be achieved with Render Feature. But we don't have other choices with UI SFX but camera stacking
     
  7. Arfus

    Arfus

    Joined:
    Mar 12, 2013
    Posts:
    29
    Although my implementation is not the greatest. Over the past couple days I've ported the Custom Post Processing Volume Components from HDRP to URP using v7.1.7. This seems to work ish, there are some issues with it, that I cannot get around all that well. But overall it's achieving what we want to achieve. I'm not sure how you guys (unity devs) are going to approach the Custom Post Processing support, but I cannot wait to see it added in.
     
    Lars-Steenhoff likes this.
  8. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    Our idea is to expose a template for custom post that uses the ScriptableRenderPass/Feature this way we consolidate one custom rendering API for all custom rendering in URP.

    By template I mean also an option in the editor that creates a script for you and all that you have to do is to write the Execute() method and add it to the renderer.

    What are your thoughts on this?
     
    noio and MadeFromPolygons like this.
  9. goncalo09

    goncalo09

    Joined:
    Oct 26, 2017
    Posts:
    9
    Can you give us more details about this?
    My use case is drawing custom UI (not IMGUI, UGUI, or elements).
    The UI is built in a CommandBuffer by assigning draw mesh commands.
    When using the builtin renderer, I would just add this command buffer to the camera with CameraEvent.AfterEverything.

    Now with URP I haven't been able to find a satisfying solution.
    - Adding a new ScriptableRenderFeature kinda works, but requires setup on the project scenes (not just adding a script like before), and renders UI on all cameras when I just wanted it on a specific one (e.g. renders UI on material preview cameras, etc).
    - RenderPipelineManager.endCameraRendering doesn't seem to work.
    - I'm waiting for camera stacking, but am not sure it helps either.
    - Tried looking for how UICanvas does it, but it seems like this is handled on the native side of Unity.

    Is there a better solution for this? From previous Unity developer comments I get the idea that I should just be using ScriptableRenderFeature, but couldn't find a way to do it without feeling 'hacky'.
    Currently I'm doing something like this:
    Code (CSharp):
    1. using UnityEngine.Rendering;
    2. using UnityEngine.Rendering.Universal;
    3.  
    4. public class RenderCommandBuffer : ScriptableRendererFeature
    5. {
    6.     class RenderPass : ScriptableRenderPass
    7.     {
    8.         public CommandBuffer cmd;
    9.  
    10.         public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
    11.         {
    12.             context.ExecuteCommandBuffer(cmd);
    13.         }
    14.     }
    15.  
    16.     public CommandBuffer CommandBuffer => _cmd ?? (_cmd = new CommandBuffer() { name = name });
    17.     CommandBuffer _cmd;
    18.     RenderPass _renderPass;
    19.  
    20.     public RenderPassEvent @event = RenderPassEvent.AfterRenderingPostProcessing;
    21.  
    22.     public override void Create()
    23.     {
    24.         _renderPass = new RenderPass()
    25.         {
    26.             cmd = CommandBuffer,
    27.             renderPassEvent = @event,
    28.         };
    29.     }
    30.  
    31.     public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    32.     {
    33.         _renderPass.renderPassEvent = @event;
    34.         renderer.EnqueuePass(_renderPass);
    35.     }
    36. }
    And modifying the CommandBuffer outside the RenderFeature.
     
  10. liiir1985

    liiir1985

    Joined:
    Jul 30, 2014
    Posts:
    147
    Will that then be rendered in 1 pp stack? Or it'll just be an extra blit pass for every custom PP? The later one will reduce the performance quite a lot
     
  11. Arfus

    Arfus

    Joined:
    Mar 12, 2013
    Posts:
    29
    From my understanding this will depend on how you yourself set things up. If all of your custom PP effects make use of the same shader, you can reduce it to just one blit. If each custom PP has a different shader AND requires the output from the previous PP, you'll have to blit each time.

    But obviously this is just my guess, it'll highly depend on how the URP team decides to set things up.
     
  12. Arfus

    Arfus

    Joined:
    Mar 12, 2013
    Posts:
    29
    I'm guessing you're going to use a similar template as the one used by the HDRP. I personally don't see any issues with that template, and I think the approach is fine.
     
  13. lostminds

    lostminds

    Joined:
    Jan 17, 2019
    Posts:
    51
    How do you disable post processing on URP? I have a URP project where I don't use any post processing, but it seems that a lot of post-processing resources are still compiled and added to the build (https://forum.unity.com/threads/urp-uberpost-included-in-build-even-if-no-prostprocessing.789320/). I'm guessing this is because it's not an integrated part of URP. Will disabling post processing in some more explicit way mean these unused shaders and textures are properly stripped when building?
     
  14. Arfus

    Arfus

    Joined:
    Mar 12, 2013
    Posts:
    29
    I think the only way to disable Post-processing on URP, is by extracting the post processing pass from the scriptable render pipeline. You can do this by placing the URP package in a package folder. This will allow you to make changes to the code of the package.
     
  15. Noisecrime

    Noisecrime

    Joined:
    Apr 7, 2010
    Posts:
    2,035
    I'm not entire sure what you mean/consider 3d objects for UI on a real world project, but i'm running into a somewhat frustrating issue with the legacy rendering system a world space canvas and Post Process Stack( 2.1.7 ) affecting the UI in my current client project.

    I've currently implemented the simplest and most direct workaround I could think of but have a few more complex alternatives that would be better solutions long term. However I am concerned with all that i'v read about URP and HDRP previously that these workarounds/solutions might not be possible. For this reason i'm outlining the issue here and my proposed solutions in order to check that these will be possible in URP + PPS or if not that perhaps they might influence future design to facilitate a solution.


    So I have a simple scene, an animated humanoid avatar in the middle of the screen, but with a complex lighting setup and a full Post Process Stack. The UI is a carousel of images that is centered on and orbit around the avatar, meaning I need to have images behind the avatar obscured ( i.e images in world space), but at the same time it cannot be affected by PPS!

    So without PPS the solution should be a two camera system, with second camera set to 'don't clear' to retain the depth buffer between rendering the scene then rendering the world space UI. However it appears that PPS actively clears all the buffers before its final blit, and maybe even again afterwards ( its a little hard to track everything in framedebugger ). Thus by the time I render my second camera for UI all depth information is lost.

    My current quick workaround is to add a 'depth only' rendered cylinder around the avatar that is only rendered by the second camera to act as a blocker in the depth buffer to obscure images when they are roughly behind the avatar. A more exact approach would be to render the avatar again as 'depth only', but that's more complex in terms of coding and performance. An alternative might be to make a copy of the depthbuffer before the PPS and then copy it over to the world Space camera before rendering the carousel.

    So while I understand and agree with the calls for a supported 'Screen Space - Camera' Ui mode, I just want to confirm/ensure that the combination of URP + Camera Stacking + PPS can still facilitate the solutions to the world space camera requiring depth information as I outlined above.
     
    phil_lira likes this.
  16. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    Warframe. There are world-space screens in some places with readable text, and many of the game's UI are world-space, with the camera just zooming into them.



    Just keep the depth buffer around after post processing, so world-space UI only needs to be drawn directly to the framebuffer after the final blit with depth-testing on.
     
  17. Ferazel

    Ferazel

    Joined:
    Apr 18, 2010
    Posts:
    517
    Sorry that this thread has turned into yet another camera stacking thread. However, I keep seeing Unity folks bring up using a RT with another camera to handle the Camera space UI. I want to stress that for mobile projects the memory/rendering overhead for a per-pixel render texture is relatively large price on high-res devices that we didn't pay for on the legacy renderer. Thus why I feel it is a regression in URP functionality/features.

    I am not sure if the solution you mentioned is waiting for UIElements to add mesh/particles or if there is a URP solution in the pipe. Fundamentally, I'm in agreement that UI camera stacking was primarily done on projects I've worked on for particles or effects on the UI that UGUI doesn't support outside of this camera stacking behavior, and it sounds like there isn't a great solution for it now in URP when you have post-processing on your scene.
     
  18. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    For the past two weeks we have been discussing how to support the scenarios you need to make camera stacking, UI and post-processing.

    Rethinking about the problems it all boils down to the fact that we need to allow to run post-processing stack at different parts of the camera stack.

    Allowing to run multiple post-processing stacks on the camera stack is not trivial feat, but it seems running post-processing once and allowing to chose where in the camera stack to run it would cover majority of scenarios, including the world space UI above. Depth can already be optionally preserved with Overlay cameras, so the UI carrousel above should work in the new version. Also once custom post-processing is supported you will also be able to inject any of these in any part for the stack as they are essentially a render pass.

    So we are prototyping this solution: expose in the stack a post-processing event you can choose where to inject.

    I would like to ask to keep this thread focused on post-processing and move the camera stack feedback here: https://forum.unity.com/threads/camera-stacking-for-urp.736277/
     
  19. ClayChi

    ClayChi

    Joined:
    Mar 30, 2018
    Posts:
    7
    I imagine a solution like shader graph nodes to connect necessary parts of the rendering stack as a flow graph. Is it too irrelevant to think this? We could see which pass, which camera connects for which post process or custom post processor.
     
  20. Mese96

    Mese96

    Joined:
    Jul 23, 2013
    Posts:
    40
    So with 2019.3 officially released now, what is the status of PPV2 ?
     
  21. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    159
    The plan is to release 7.2 next week which contains the support for PPv2.
     
    Alex_TNT, Kronnect, cxode and 5 others like this.
  22. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    What is that status on Ambient occlusion for URP, I am considering going back to standard pipeline but would really prefer to skip all that work. Seems like such a basic feature.
     
    cxode and Lars-Steenhoff like this.
  23. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    159
    So... That task got on my desk late last week.
    The plan was use this week to work on it and if ready, try to publish it in 7.2.0.

    Unfortunately Camera Stacking + implementing/reviewing/approving/merging other features & bugfixes for 7.2 has taken almost all of my time so that wasn't possible.

    After we release 7.2.0, this will be one of my most important tasks to get done for URP.
     
    Last edited: Jan 30, 2020
    Alex_TNT, fherbst, fxlange and 8 others like this.
  24. mrCharli3

    mrCharli3

    Joined:
    Mar 22, 2017
    Posts:
    976
    Really nice to know that its on the way :)
     
  25. sebsmax

    sebsmax

    Joined:
    Sep 8, 2015
    Posts:
    118
    Someone went very far with the _CameraColorTexture, _CameraDepthTexture, _CameraDepthNormalsTexture

    This are essential features for AO, I hope that link can help:
    https://alexanderameye.github.io/outlineshader
     
    cxode and Elvar_Orn like this.
  26. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,269
    Hi, thanks for the heads up.

    This seems like a very bad idea and will only confuse more, if there is something to be added would be best to be a plan to remain and not know that will be removed from the start.

    Generally all decisions about the pipelines seems extremely fragmented, rushed and confusing at this point, there is no way to know what to use and how safe will be.
     
  27. ekakiya

    ekakiya

    Joined:
    Jul 25, 2011
    Posts:
    79
    Currently, Inserting a custom renderer feature to RenderPassEvent.AfterRendering breaks Postprocessing effects.

    It seems like ForwardRenderer.Setup() must do m_FinalBlitPass.Setup(cameraTargetDescriptor, m_AfterPostProcessColor) instead of m_FinalBlitPass.Setup(cameraTargetDescriptor, m_ActiveCameraColorAttachment), in the case if( afterRenderExists && applyPostProcessing && !requiresFinalPostProcessPass).
     
    goncalo-vasconcelos likes this.
  28. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    159
    Hey,
    I've been able to reproduce this and have made a fix that's in testing right now and will be a part of 7.2.
     
    Last edited: Feb 2, 2020
  29. sebas77

    sebas77

    Joined:
    Nov 4, 2011
    Posts:
    1,639
    can I add post process passes using a ScriptableRendererFeature? And if so, why isn't anyone mentioning it?
     
  30. ShockpointGames

    ShockpointGames

    Joined:
    Jul 19, 2018
    Posts:
    26
    What are the expected features of 7.2.0?
     
    cxode likes this.
  31. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,893
    It’s nice to have around here the guy coding this stuff. Is PPSv2 support already available in some GitHub branch?
     
  32. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    159
    sebsmax likes this.
  33. Kronnect

    Kronnect

    Joined:
    Nov 16, 2014
    Posts:
    2,893
  34. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    159
    cxode and Kronnect like this.
  35. Tim-C

    Tim-C

    Unity Technologies

    Joined:
    Feb 6, 2010
    Posts:
    2,219
    Just a heads up, package release may be delayed until early next week due to some critical XR bugs :( will let everyone know.
     
    cxode and phil_lira like this.
  36. sebsmax

    sebsmax

    Joined:
    Sep 8, 2015
    Posts:
    118
    I still don't understand why you keep the XR stuffs all over unity, when it should be in a separate package, the same way consoles, iOS and Android are in separate packages.

    It's pretty common to have XR compilation errors on a Xbox or Nintendo switch.

    Is there any reason for keeping XR in the main code?
     
  37. noio

    noio

    Joined:
    Dec 17, 2013
    Posts:
    226
    That sounds great! I appreciate the symmetry between custom render pass and custom post processing. Looking forward.
     
  38. JesOb

    JesOb

    Joined:
    Sep 3, 2012
    Posts:
    1,096
  39. andybak

    andybak

    Joined:
    Jan 14, 2017
    Posts:
    563
    In general: "code generation is a red flag". The API should be concise and simple making code generation unnecessary.
     
    Ruslank100 and cxode like this.
  40. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    You can already do it now if you want without any template. The template we want to provide is optional to use and is just a helper to make everyone life easier by not having to repeat the same boiler plate code. This pattern is also used in other places in Unity like when you create a new unlit or lit shader. It's a template that writes most of the shader boiler plate code for you.
     
  41. Arfus

    Arfus

    Joined:
    Mar 12, 2013
    Posts:
    29
    @phil_lira Is there an update on the 7.2.0 release? Are you still struggling with the critical XR issues? Or will the release happen later today? If not, is an official release day known? Preferably something a bit more specific than "early next week".
     
  42. ShockpointGames

    ShockpointGames

    Joined:
    Jul 19, 2018
    Posts:
    26
    How do I go about installing the 7.2 version from github?
     
  43. Arfus

    Arfus

    Joined:
    Mar 12, 2013
    Posts:
    29
    It's not released yet.
     
  44. ShockpointGames

    ShockpointGames

    Joined:
    Jul 19, 2018
    Posts:
    26
    It is on GitHub.
     
  45. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    268
    Last edited: Feb 8, 2020
  46. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    268
  47. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    cxode likes this.
  48. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    You can get the release branch posted above. Easiest way to install is to drop the com.unity.* folders into Packages folder of your project.

    Be aware that there's currently a crash in WMR. This is the shipstopper issue that needs to be addressed before we publish.
     
    cxode likes this.
  49. ShockpointGames

    ShockpointGames

    Joined:
    Jul 19, 2018
    Posts:
    26
    Thanks for the info!

    Changelogs mention that PPV2 works in URP now, but I can't seem to get the effects to display at all.
     
    cxode likes this.
  50. Admin_Friend_Factory

    Admin_Friend_Factory

    Joined:
    Oct 23, 2018
    Posts:
    41
    Neither can I. I use the Post Processing 2.3.0 package with URP 7.2.0, Core RP 7.2.0 and ShaderGraph 7.2.0 (all 3 folders put in manually under the Packages folder, all seems to load correctly). Do you need the Lightweight 7.2.0 installed as well?

    Can you use URP build in post processing at the same time as PPV2?

    Can we get som instructions how to activate, please?

    Thanks
     
    cxode likes this.