Search Unity

Question Custom pass to write to G-buffer (diffuse color) using a full-screen shader?

Discussion in 'High Definition Render Pipeline' started by lefteris6, May 24, 2023.

  1. lefteris6

    lefteris6

    Joined:
    May 4, 2019
    Posts:
    1
    Hi,

    I want to write to the diffuse color before the lighting calculations are done and the final frame is rendered.
    I am retrieving the diffuse color texture as a RenderTexture using a CustomPass:
    Code (CSharp):
    1. protected override void Execute(CustomPassContext ctx) {
    2.        
    3.        
    4.         // Get the diffuse color texture from the camera GBuffer
    5.         RenderTexture diffuseTexture = ctx.hdCamera.GetCurrentFrameRT((int)HDCameraFrameHistoryType.ColorBufferMipChain);
    6.  
    7.  
    8.         StylizeImage(diffuseTexture);
    I use Unity's Barracuda to manipulate the diffuse texture. Once I do this, I want to write back to the diffuse colour. Is this possible?
    @antoinel_unity I have looked at your Custom pass examples, and saw how to write to the normal buffer but I couldn't make it work for the Camera Color Buffer.
    Any help/advice would be very appreciated.
    Thank you.