Search Unity

Feature Request Initialize and manage the RTHandles system

Discussion in 'Universal Render Pipeline' started by ShiftedClock, Nov 23, 2021.

  1. ShiftedClock

    ShiftedClock

    Joined:
    Sep 12, 2012
    Posts:
    18
    The RTHandles static instance in the CoreRP library requires initialization and management to use. HDRP does this for the user, so it requires no extra effort to use in your own CustomPasses.

    In contrast URP doesn't initialize the RTHandles static instance, making it require extra effort to use.

    If URP also initialized and managed the RTHandles static instance it would make porting passes between the two pipelines easier. It also results in less code for the user to manage, reducing the maintenance burden.

    I ran into this in the past week while evaluating both pipelines for a project, and it surprised me that URP doesn't use the RTHandles system in the same way that HDRP does.
     
  2. ManueleB

    ManueleB

    Unity Technologies

    Joined:
    Jul 6, 2020
    Posts:
    110
    Last edited: Nov 23, 2021
    ekakiya, ShiftedClock and daneobyrd like this.
  3. burningmime

    burningmime

    Joined:
    Jan 25, 2014
    Posts:
    845
    That sounds like 2 days of work for me to update every pass to use that :-(. Other than making it easier to port passes to HDRP, is there any advantage to this over RenderTargetHandles? Seems like just a different name for the same thing.
     
  4. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    from PR description:
    Also.. this change isn't removing the previous API just yet, but it will happen in some future version:
     
    burningmime likes this.
  5. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    As extra note, I've been using URP version with this change merged from Graphics repo directly and none of my existing custom Renderer Features broke because of it, so at least for now the backwards compatibility seems to work just fine.

    For my own uses, I don't actually expect the refactoring work to be that big though. If you look at the changes that RTHandle PR did for URP's own renderer features or PP, it's typically few lines change for making it use the new setup.
     
  6. daneobyrd

    daneobyrd

    Joined:
    Mar 29, 2018
    Posts:
    101
    I really want this to come to URP before URP 13.0. Bring RTHandles to URP 12!
     
  7. daneobyrd

    daneobyrd

    Joined:
    Mar 29, 2018
    Posts:
    101
    Could you walk me through the steps you took to merge this change from the graphics repo directly? Did you have to use reflection to change the packages?

    I see they've created a directory for urp.testing that has this change:
    https://github.com/Unity-Technologies/Graphics/tree/master/com.unity.testing.urp
     
  8. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    @daneobyrd considering RTHandle change is now included on Unity 2022.1.0b1's URP, that's the easiest way to give this a go today, no need for custom packages, just install the beta and install urp package from it.

    If you really want this to 2021.2, I guess easiest way would be to just see if one can mod current master branch from github to run on 2021.2. There are few API changes but once you find the PRs that did those changes, it's fairly simple to revert those individual commits.

    Also worth noting that Unity is still working on this transition, they have more changes coming in regarding this all the time now, would expect that to keep on going throughout 2022 cycle.
     
    daneobyrd likes this.
  9. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    I also have to correct this a bit. Noticed that CopyDepthPass.Setup() now only has RTHandle approach which breaks backwards compatibility if one used this before the change, not sure if this is an oversight or by design, I've filed bug report on this (case #1387300).
     
  10. ManueleB

    ManueleB

    Unity Technologies

    Joined:
    Jul 6, 2020
    Posts:
    110
    This "breakage" should be as intended, so as stated in the upgrade guide RenderFeatures that used to call SomePass.Setup() in AddRenderPasses() should be fixed by moving those Setup calls in the new SetupRenderPasses override. Does this help in your specific case?
     
    Kirsche and rz_0lento like this.
  11. rz_0lento

    rz_0lento

    Joined:
    Oct 8, 2013
    Posts:
    2,361
    Ah that was a good point, I'll take a better look at the official upgrade guide (https://docs.unity3d.com/Packages/c...iversal@13.1/manual/upgrade-guide-2022-1.html).

    I was just surprised that the remaining backwards compatibility didn't actually cover whole systems, just the old rt handles... ..which alone kinda makes the backwards compatibility less useful in general.

    This will have a side effect of many 3rd party URP assets breaking yet again when people move to Unity 2022.
     
  12. lingdu_y

    lingdu_y

    Joined:
    Apr 15, 2021
    Posts:
    11
    Hi, now I just use version 2022.2b, I faced a really awesome problem that I can't use RenderTargetIdentifier to send "_CameraDepthTexture" into my computer shader, because now there are some format strings behind the original identifier strings just like the picture down.
    upload_2022-9-26_16-22-58.png
    So how can I get RenderTargetIdentifier from RTHandles, I have read the code in UniversalRender.cs, but I have no idea. I really need your help, thanks.
     
  13. ManueleB

    ManueleB

    Unity Technologies

    Joined:
    Jul 6, 2020
    Posts:
    110

    looks like you are using RTHandle.rt.name instead of RTHandle.name


    Code (CSharp):
    1. RenderTargetIdentifier test = cameraDepthHandle.name;  //_CameraDepthTexture
    2. RenderTargetIdentifier test2 = cameraDepthHandle.rt.name;  // _CameraDepthTExture_1348x439_R32_SFloat_Tex2D
     
    UbiBenKenobi likes this.