码迷,mamicode.com
首页 > 其他好文 > 详细

Camera’s Depth Texture

时间:2014-08-02 15:05:33      阅读:202      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   http   color   os   strong   io   

Camera’s Depth Texture

  In Unity a Camera can generate a depth or depth+normals texture. This is a minimalistic G-buffer texture that can be used for post-processing effects or to implement custom lighting models (e.g. light pre-pass). Camera actually builds the depth texture using Shader Replacement feature, so it’s entirely possible to do that yourself, in case you need a different G-buffer setup.

  Camera’s depth texture can be turned on using Camera.depthTextureMode variable from script.

  There are two possible depth texture modes:

  • DepthTextureMode.Depth: a depth texture.
  • DepthTextureMode.DepthNormals: depth and view space normals packed into one texture.

  bubuko.com,布布扣

[DepthTextureMode.DepthNormals texture] 

  This builds a screen-sized 32 bit (8 bit/channel) texture, where view space normals are encoded into R&G channels, and depth is encoded in B&A channels. Normals are encoded using Stereographic projection, and depth is 16 bit value packed into two 8 bit channels. UnityCG.cginc include file has a helper function DecodeDepthNormal to decode depth and normal from the encoded pixel value. Returned depth is in 0..1 range.

参考:file:///C:/Program%20Files%20(x86)/Unity/Editor/Data/Documentation/html/en/Manual/SL-CameraDepthTexture.html

Camera’s Depth Texture,布布扣,bubuko.com

Camera’s Depth Texture

标签:des   style   blog   http   color   os   strong   io   

原文地址:http://www.cnblogs.com/tekkaman/p/3886794.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!