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.

Question Passing Render Texture Between URP Shader Passes

Discussion in 'Shaders' started by Madalaski, May 13, 2020.

  1. Madalaski

    Madalaski

    Joined:
    Apr 16, 2013
    Posts:
    6
    So I'm trying to streamline this effect I have here: https://twitter.com/Madalaski/status/1259961256087355392

    I'm currently using two extra cameras and render textures, and placing the result on a UI in order to achieve it. It's a bit messy and I'm trying to learn more shader stuff so I figured I'd learn how to add custom render passes to URP in order to streamline the effect better. My plan was to have two new render features, one Render Objects feature to render the objects on the "Pixel Objects" Layer to a specific temporary render texture and then an altered Blit feature that would take that temporary render texture and apply the pixelated post processing effect on it.

    However, instead the Blit pass produces a warning saying that the temporary render texture "_PixelTexture" doesn't exist, even though the unchanged Render Objects feature has this for its list of Shader Passes:

    upload_2020-5-13_2-4-33.png

    which, from what I can research, should generate that temporary render texture. Though, it's a little unclear I can't see to find much API documentation on the subject. Furthermore, the Render Objects feature disappears from the Frame Debug list when I add this Shader Pass, though I have a feeling that's because it's not being used anymore.

    I changed the Blit.cs file so that it initialises and RenderTargetHandler with the name "_PixelTexture" and passes that a source to the BlitPass class instead of the RenderTargetIdentifier of cameraColorTarget and then calling .Identifier() within the BlitPass class whenever I needed to. I'm pretty confident that this should work, and the warning is even showing me that the pass is looking for the right temporary render texture, so my guess is that I'm misinterpreting how the Render Objects feature works. From what I can gather from the code, it's render targets are handled by the CreateDrawingSettings method that I can't find any information on.

    If anyone can help me, or direct me to some crash course on how to manage these Custom Shader Passes on Unity's new SRP, I would greatly appreciate it. I've look at Catlike Coding's set of tutorials and while they have shone a light on a few things, I haven't found anything that would help fix my problem. If I can't figure this out then I've either got to carry on with my current messy method and it's lack of control or completely build up my Rendering Pipeline which... sounds fun but challenging.

    Also I apologise for any incorrect etiquette or terminology. If there's one immutable law about Computer Science it's that we need at least 4 names for every 3 things and a couple of them have to be interchangeable.

    TLDR: How do you pass a temporary render texture between custom render features in URP?
     
    Circool likes this.