Search Unity

Grab Data from G-Buffer

Discussion in 'Shaders' started by TrollHachem, Mar 8, 2015.

  1. TrollHachem

    TrollHachem

    Joined:
    Dec 25, 2012
    Posts:
    65
    Hello ,
    So i'm trying to get the view-space normals texture from the g-buffer.
    Is there anyway to grab it (since i don't want to re-render them).
    Thanks
     
  2. TrollHachem

    TrollHachem

    Joined:
    Dec 25, 2012
    Posts:
    65
    Found them : They are stored in :
    CameraGBufferTexture0 , CameraGBufferTexture1 ,CameraGBufferTexture2 and CameraGBufferTexture3...

    CameraGBufferTexture2
    holds the normals.
     
    khaled24 likes this.
  3. RyanFavale

    RyanFavale

    Joined:
    May 30, 2014
    Posts:
    28
    If I read and write the exact values I get from the normals, the lighting turns out wrong. Not sure if that's because I am reading "and" writing to the buffer or if Unity is actually smart enough to give me a temp buffer to write to that it applies back into the main gBuffers after the render pass. I'm trying to read gBuffer data and write back modified gBuffer data in screen-space "before" lighting is applied (ie. not a post lighting effect).
     
    Last edited: May 19, 2015
  4. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    Remember that it's NOT view space normals in the g-buffer, it's world space!
     
  5. RyanFavale

    RyanFavale

    Joined:
    May 30, 2014
    Posts:
    28
    Yes, but if I read and write the exact same value into the gBuffer normals, shouldn't I get the exact same result as if I had done nothing?
     
  6. Zicandar

    Zicandar

    Joined:
    Feb 10, 2014
    Posts:
    388
    You can't read and write to the same texture at the same time.
     
unityunity