Im new to Unity3D, but I can already say that this is an amazing tool. Im currently working on a personal project on unity, and I have a question.
Is it possible to create a camera that would retrieve the depth buffer of the current frame when I send a request to it?
As I said before, I'm totally new to unity and even if I have already done a bunch of tutos I can't really see were to begin with this pb.
Im French and my English is far from perfect, if my question is not clear, feel free to say it ^^.
asked Apr 22 '11 at 08:43 AM
Yes it's totally possible.
One thing to know is that the depth texture must be 'drawn' by Unity before you can use it as a texture in your shaders/post processes/whatever.
However, as you might know, Unity has two modes of rendering : forward and deferred. If you choose deferred rendering, Unity already needs this depth texture for it's own internal use so it's already available.
In forward rendering though, you'll have to tell Unity to drawn this texture or it won't be available. You can use this to tell your main camera to draw it. You'll notice that here you can ask Unity to render the Normals texture as well. The same goes with the Normals texture concerning deferred rendering.
Once your texture is drawn, you can use it as a global shader property: _CameraDepthTexture
Et te biles pas pour ton anglais, il est des annes-lumires de bien des gens ici! ^^
EDIT: Eric's link to the Documentation is full of good stuff, covering what I just said ^_^ Go read it now!
answered Apr 22 '11 at 09:35 AM