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

URP ShaderGraph with multiple RenderTargets?

Discussion in 'Shaders' started by zezba9000, Apr 28, 2020.

  1. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    985
    Is it possible to have a custom shader output to mulitple render targets/textures like you can in the build in renderer?
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Custom shader? Yes.
    Shader Graph? No.*
    * Apart from HDRP since that’s a deferred renderer so it’s rendering to multiple targets by default for the PBR and Lit Master nodes, but you can’t control exactly what.

    If you want a shader that renders to multiple targets you just have to write a custom vertex fragment shader, like you would have for the built in renderers before this.
     
  3. zezba9000

    zezba9000

    Joined:
    Sep 28, 2010
    Posts:
    985
    I was under the impression not using ShaderGraph in URP is likely to break with future updates (and its not documented?).
     
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    Correct.

    It’s also the only option for doing a lot of things because Shader Graph is exceptionally limited.
    And using Shader Graph isn’t a guarantee that shaders will work in future versions. They’ve already broken stuff a few times on updates...
     
  5. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Is there any example of this? (using custom shader) I did look at the post processing in urp and the shader looks simple enough, but I don't want to set up post processing, I want normal rendering to write to both main screen buffer and my other custom render texture using mrt (in URP)
     
  6. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,329
    That requires significantly modifying the URP. Existing examples of what you're looking to do are all done with custom render features, which re-render the scene with different shaders. Similar to the replacement shader system of the past. I don't know of any examples of what you're looking to do, since that falls under the realm of what amounts to about the same work as writing a custom SRP from scratch.