   Deferred R.: Z-Buffer for pixel-position reconstr. - no z-/stencil opt. for lights?
  Hi,I am making a new post, because I got another idea I want to ask about.When I use the depth-stencil-buffer to reconstruct pixel position during the lighting passes I don't get depth and stencil bases optimization for the light volumes as the z-buffer already is bound to the shader, right?Would it be useful/possible to copy the z-buffer to another one, so that I can bind one z-buffer to the shader and use the other one for to check against depth/stencil.EDIT: Or what about this: 1.) render the scene to the z-buffer and all the other g-buffers2.) bind the z-buffer to a shader and render the depthvalues to another texture.3.) Use the z-buffer as the depth/stencil surface again and use the newly acquired texture for pixel position reconstruction.The reason I am asking is that I want those optimizations on the one hand, on the other hand I had to add a 2x32/4x16 Rendertarget just to free up the z-buffer which in itself became quite a performance hit because of the additional required bandwidth.I might be able to free up 16bit for depth in my 2 already existing rendertargets but I'm curious about how people usually go about this.   
  If you are using OpenGL, then you can use z-buffer texture both for input and as actual depth buffer as long as it is read-only.For DirectX - if you use DX10, then instead of using shader to copy z-values you can use device->CopyResource() method.   ;Quote:Original post by bubu LVIf you are using OpenGL, then you can use z-buffer texture both for input and as actual depth buffer as long as it is read-only.Oh, thats nice! I am using DX10 though.Quote:Original post by bubu LVFor DirectX - if you use DX10, then instead of using shader to copy z-values you can use device->CopyResource() method.Ok, that should work I suppose. Do you think its a good idea? On the other hand I don't have a linear buffer then, which also seems to have its benefits.;Quote:Original post by bubu LVIf you are using OpenGL, then you can use z-buffer texture both for input and as actual depth buffer as long as it is read-only.Sorry to steal the thread for a moment...How would that look in terms of FBO attachments? Would you use a separate depth attachment along with a normal texture attachment?   ;  It would look like this - you have some GLuint depth_texture. You have it attached to depth attachment to use it as depth buffer:glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depth_texture, 0);And also bind it to texture unit for use in shader:glActiveTexture(GL_TEXTUREn);glBindTexture(GL_TEXTURE_2D, depth_texure);