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
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Question debug pass with renderer Feature

Discussion in 'Universal Render Pipeline' started by elpie89, Nov 20, 2022.

  1. elpie89

    elpie89

    Joined:
    Jun 30, 2014
    Posts:
    32
    Hi , in the scope of writing a image effects, I'm trying to write a renderer feature with a render pass
    thanks to some example I found , I can do it without big issues
    However, for the sake of learning , I would like to write a debug LightOnly Pass and a debug Albedo only pass.
    To do this I'm adding my pass after the AfterRenderingGBuffer
    here my Scriptable Render Pass
    Code (CSharp):
    1. public override void Execute(ScriptableRenderContext context, ref RenderingData renderingData)
    2.   {
    3.         // fetch a command buffer to use
    4.         CommandBuffer cmd = CommandBufferPool.Get(profilerTag);
    5.         cmd.Clear();
    6.  
    7.         // the actual content of our custom render pass!
    8.         // we apply our material while blitting to a temporary texture
    9.         cmd.Blit(this.source, tempTexture.Identifier(), materialToBlit, this.blitPassIndex);
    10.  
    11.         // ...then blit it back again
    12.         cmd.Blit(tempTexture.Identifier(), this.source);
    13.  
    14.         // don't forget to tell ScriptableRenderContext to actually execute the commands
    15.         context.ExecuteCommandBuffer(cmd);
    16.  
    17.         // tidy up after ourselves
    18.         cmd.Clear();
    19.         CommandBufferPool.Release(cmd);
    20.   }
    How can I pass the result of the GBuffer0 into a shaderGraph?
     
  2. elpie89

    elpie89

    Joined:
    Jun 30, 2014
    Posts:
    32
    well, as always I find the solution right after posting
    Code (CSharp):
    1. var gBuff = Shader.PropertyToID("GetBuff0");
    2.  
    3.         RenderTargetIdentifier rti = new RenderTargetIdentifier("_GBuffer0");
    4.         cmd.GetTemporaryRT(gBuff, Screen.width, Screen.height, 0, FilterMode.Bilinear, RenderTextureFormat.ARGB32);
    5.         cmd.Blit(rti, gBuff, materialToBlit, this.blitPassIndex);
    6.         cmd.SetGlobalTexture(0, gBuff);
    7.         cmd.ReleaseTemporaryRT(gBuff);
    8.  
    9.  
    10.         // ...then blit it back again
    11.         cmd.Blit(rti, this. Source);