Search Unity

Camera.SetTargetBuffers Multiple Depth Buffers?

Discussion in 'General Graphics' started by Chimera3D, May 9, 2015.

  1. Chimera3D

    Chimera3D

    Joined:
    Jan 27, 2012
    Posts:
    73
    I have a setup where I'm essentially rendering a custom geometry buffer via multiple render targets which works quite well except for one problem, I can only set the depth for the depth texture's depth buffer while the other ones (diffuse and normal textures) don't get any depth information and thus parts of objects render over themselves and the result just isn't pretty (there's no workaround this issue except to just have depth info). I use the camera.settargetbuffers function and pass in an array of my color buffers and the depth texture's depth buffer but only the depth texture has depth information and is rendered properly while the other two textures aren't. Is there anyway that I can set the depth buffer of the diffuse and normal texture using camera.settargetbuffers or will I have to render each texture separately which will result in having to render the same geometry three times (which can get really costly). Is it at all possible to emulate passing an array of depth buffers into camera.settargetbuffers without having to re-render the geometry like you can with the color buffers or is this impossible (and if so, why?).