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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Bug Camera, depth and screen space texture name suffixes added in URP 13

Discussion in 'Universal Render Pipeline' started by jjxtra, Dec 27, 2022.

  1. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,455
    Can someone from Unity please chime in and give the reason why a long suffix was added to key textures starting in URP 13?

    Two examples:

    - Camera target texture: used to be _CameraColorAttachmentA, now is _CameraColorAttachmentA_[long suffix].
    - Screenspace shadow texture: used to be _ScreenSpaceShadowmapTexture, now is _ScreenSpaceShadowmapTexture_[long suffix].

    It was very convenient to read / write with these textures using these names, now the suffix is full of format and resolution and makes it impossible to determine the texture.

    How does one access these textures properly in URP 13+ using command buffers?
     
  2. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,455
  3. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,455
    Example of RenderDoc showing URP 13 texture with suffix...

    upload_2022-12-26_21-6-5.png
     
  4. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    219
    It's a result of URP using the RTHandle API. Use e.g.
    Code (CSharp):
    1. RTHandle ColorTarget = renderingData.cameraData.renderer.cameraColorTargetHandle;
    2.             RTHandle cameraDepthTarget = renderingData.cameraData.renderer.cameraDepthTargetHandle;
    for color and depth, not sure about shadow map I'm afraid as I don't use it myself
     
  5. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,455
    I don’t understand why moving to rthandle would require a name change for the textures. Utterly baffling.
     
    arkano22 and OUTTAHERE like this.
  6. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,455
    Having all this done silently and without warning is what really gets me. It’s not mentioned in the migration guides and there is no solution for the screen space shadow texture. It seems like SRP is a constant beta for years.
     
    revolute, Unifikation and ElliotB like this.
  7. ManueleB

    ManueleB

    Unity Technologies

    Joined:
    Jul 6, 2020
    Posts:
    98
    Hi, RTHandles added some extra suffix information for debug purposes only, that shouldn't affect the usage and should work like before as expected.

    As an example, _ScreenSpaceShadowmapTexture is set as global texture with the "old" name:
    The RTHandle name is _ScreenSpaceShadowmapTexture, the RenderTexture "inside" the RTHandle (the one the frame debugger displays eventually) has the name_suffix

    SetGlobalTexture(rtHandle.name, rtHandle.nameID);

    where rtHandle.name = "_ScreenSpaceShadowmapTexture"

    so shaders will still use that naming.

    If this is causing any issues with your projects can you please show an example of your problematic code?
     
  8. ManueleB

    ManueleB

    Unity Technologies

    Joined:
    Jul 6, 2020
    Posts:
    98
    Just to show an example, I am attaching a debugger screenshot of m_DepthTexture. As you can see the RTHandle name is still _CameraDepthTexture. The underlying RenderTexture name is _CameraDepthTexture_[suffix]. RTHandles are implemented on top of low level RenderTextures which don't necessarily have the same dimension of the RTHandle, to allow features like dynamic scaling to work.
    Currently the FrameDebugger, RenderDoc and other debugging tools show the underlying RenderTexture name, this has no implications in terms of usage though.

    If this is causing any issues in your code though it might be a bug and we could use more details please

    RTHandleName.png
     
  9. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    681
    This could be made a lot less confusing and frustrating for users if the name used by shaders was also displayed in the frame debugger. It would be nice if it showed both, and the fact that a RTHandle is affecting it at all.
     
  10. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,068
    This kind of casual disregard for users is more like an alpha.
     
    arkano22 and OUTTAHERE like this.
  11. ManueleB

    ManueleB

    Unity Technologies

    Joined:
    Jul 6, 2020
    Posts:
    98
    The frame debugger is showing the low level RenderTarget information, which is the same info displayed by RenderDoc, so there is value in that as potentially the same handles with different scaling could write to different textures, in complex scenarios.

    I agree that being able to see the resource name, as it is bound to the shader, could be useful as extra information and in one of the next releases URP will start using the RenderGraph viewer which will show the passes dependencies and the texture name as they are bound to the shaders. More info on that as we'll get close to releasing it
     
  12. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    681
    It's great that URP is getting more debugging tools. However, is it too much to ask that, in the meantime, the Frame Debugger could have a single extra line of information displaying the bound shader name of textures?

    It seems like the information shown is mostly useless to 99% of Unity users, at the moment. Why do we need the low level texture name, unless we're writing low level graphics code? We want the high level name that our shaders actually use to access it.
     
    OUTTAHERE and Unifikation like this.
  13. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    158
    Heyhey!
    Was just pointed to this thread as I've been working on several improvements for the Frame Debugger recently.

    Just to clarify here, are you referring to the Shader Property name that the Shaders use?
    Because that's what's displayed the in the first column (See screenshot) and then the texture name in the last column. I'm probably misunderstanding so just wanted to clarify before adding it to our backlog.
    Screenshot 2023-01-18 at 16.32.28.png
     
    funkyCoty likes this.
  14. funkyCoty

    funkyCoty

    Joined:
    May 22, 2018
    Posts:
    681
    What Unity version is this? If that's the case, then that's great! This Frame Debugger looks miles better now, compared to what I'm currently using in production (Unity 2021 LTS).
     
  15. Elvar_Orn

    Elvar_Orn

    Unity Technologies

    Joined:
    Dec 9, 2019
    Posts:
    158
    This is actually from 2023.1 alpha but the new look for the Frame Debugger is also on 2022.2.

    But I'm 99% certain that the same applies to the older versions of the Frame Debugger, that is, that the property name used by the shaders is shown as well.
     
    funkyCoty likes this.
  16. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,455
    Hmmm. Something is still off. I’m using the same names for screen space and depth texture but upon upgrade to urp 13 from urp 12 I get errors that those texture names are not found. Do you have a guide on how to write to the screen space shadow texture in urp 13?
     
    ElliotB likes this.
  17. Francium

    Francium

    Joined:
    Oct 8, 2013
    Posts:
    2
    @jjxtra, did you find out a proper way to call the texture on urp 13? I am thinking if I should start a new project and migrate my assets in case this a bug due to an urp/editor upgrade.
     
  18. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,455
    I wouldn’t use URP under any circumstance.
     
    Unifikation likes this.
  19. Francium

    Francium

    Joined:
    Oct 8, 2013
    Posts:
    2
    So stubborn as I am, I continued looking into this. I was able to get the "_CameraColorTexture" that used to work in Unity 2020. This value was apparently updated in urp 12 to "_CameraColorAttachmentA" and then I was unable to access it in urp 14 via its name. It seems every release introduces a change in behavior and it will most likely break in the next version again.

    Instead of using the following code to find the texture:

    Code (CSharp):
    1. static int colorCameraId = Shader.PropertyToID("_CameraColorTexture");
    I now use this one, and it works properly:

    Code (CSharp):
    1. ScriptableRenderer renderer = renderingData.cameraData.renderer;
    I can then call renderer.cameraColorTargetHandle to get the color target. This class is documented here https://docs.unity3d.com/Packages/c...e.Rendering.Universal.ScriptableRenderer.html

    In the scope of the ScriptableRenderPass you can call both cameraColorTargetHandle and cameraDepthTargetHandle for color and depth.
     
    Unifikation likes this.
  20. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,455
    What about in shaders themselves, is the texture still called _CameraColorTexture?
     
  21. ElliotB

    ElliotB

    Joined:
    Aug 11, 2013
    Posts:
    219
    This is the intended method, but it does have issues across different editor versions. For instance, in 2020 it is not possible to get the camera color target for inspector previews. The depth buffer is much more deranged, see this thread for more detail: https://forum.unity.com/threads/scr...consistently-access-the-depth-buffer.1263044/