how to depth_grab


    Aug 27 2006 | 11:31 am
    Hello e-family,
    I've downloaded new betas for xp,(c74:thanks for this nice summer delight!), and trying new jitter features.
    I was wondering how could one capture depth buffer into texture and then to matrix. Here's what I've come up with, but it doesn't seem to work as I expected(I would like to see gray image showing depth of each pixel, but I get rendered image(colors) as with ordinary render to texture).
    Also, captured matrix shows strange values until I turn off rectangle attribute of jit.gl.texture.
    Here's the patch:
    bye, n

    • Aug 28 2006 | 8:41 pm
      On Aug 27, 2006, at 4:31 AM, nesa wrote:
      > I was wondering how could one capture depth buffer into texture and > then to matrix. Here's what I've come up with, but it doesn't seem > to work as I expected(I would like to see gray image showing depth > of each pixel, but I get rendered image(colors) as with ordinary > render to texture).
      Hi Nesa,
      There's two problems exposed here:
      1. we don't currently support copying depth textures back to a jitter matrix directly. You'll need to render to either a char or floating point pbuffer with something like slab.
      2. sometimes when changing texture parameters which cause a texture to be recreated internally (like sending the message "rectangle 0"), the @capture_buffer is set back to the default color buffer and remains that way.
      I've included a revised version of your patch which demonstrates how you can use depth textures and read them back to host memory if necessary. However, I've discovered a texture coordinate flipping issues with reading back as char data to RAM, and an initial readback issue where the first attempt to readback of a texture which has never been bound will be all black.
      Thanks for taking the time to investigate this new (and largely undocumented) feature. Some aspects of it may be changing in the next few months as we resolve these and other issues.
      -Joshua
    • Aug 28 2006 | 9:43 pm
      Hi Nesa, Here's a patch I've been using recently to work with depth textures. Currently this stuff works best with the FBO backend (as opposed to the RTT backend). How to set this is demonstrated in the patch
      best, wes
    • Aug 29 2006 | 6:57 pm
      Thank you Joshua and Wesley, I see how it works now!
      Thanks for the ping-pong tip too!