Search Unity

setting an additional SV_TARGET for Deferred

Discussion in 'General Graphics' started by zachlindblad, Jun 18, 2019.

  1. zachlindblad

    zachlindblad

    Joined:
    Sep 29, 2016
    Posts:
    39
    So after a bunch of research I'm a bit stumped on how to add an additional rendertarget in Unity.
    The setup I'm looking for is, during the Gbuffer pass I store the local (object space) normal of the surface in SV_TARGET5, then via commandBuffer, before lighting I use this value in a compute shader.

    Using CommandBuffer.SetRenderTargets won't work because unity reverts the values after your command buffer executes.
    Using Graphics.SetRenderTarget does not work because unity sets the rendertargets after OnPreRender
    Both these seem to only be intended for explicit Graphics.Draw calls, where I need this additional channel for all scene objects.
    Using Camera.SetTargetBuffers does not work with deferred shading (https://issuetracker.unity3d.com/is...endertextures-dont-work-with-deferred-shading)

    I can hypothetically write to this channel in my custom shaders, I can read from it in my compute shader, but the one thing I can't figure out is how to set it.

    Is there a way to do this in unity's deferred?
    I assume there's a way to do it in SRP's, but I really am trying to avoid opening that can of worms right now.

    Thanks!
    -Zach
     
    Last edited: Jun 18, 2019
  2. zachlindblad

    zachlindblad

    Joined:
    Sep 29, 2016
    Posts:
    39
    Sorry if I wasn't clear, to ask the same question in far less words:
    Is there any way to add an additional rendertarget to unity's deferred rendering pipeline?
    Still have found no way to do this. I know it's possible technically, so I imagine there's some solution.
     
  3. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,338
    Can be done with SRP, can’t be done with the built in deferred.
     
  4. zachlindblad

    zachlindblad

    Joined:
    Sep 29, 2016
    Posts:
    39
    Thanks, that's all I needed, guess I'll keep my duct tape solution for now until I have time to transfer over to SRP.