博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[转]Linear Depth Buffer(线性深度缓冲区)
阅读量:4966 次
发布时间:2019-06-12

本文共 2352 字,大约阅读时间需要 7 分钟。

The Problem with Z-Buffer

If you are a graphics programmer, you are bound to deal with the use of z-buffer for effects. For example, the depth buffer can be used for per pixel fog, soft particles, motion blur, SSAO, depth of field, etc. Using the standard depth, i.e. the value that is obtained by multiplying with World View Projection matrices followed by perspective divide, is often not enough.

The main problem with standard depth is that the depth value is not linear. Most of the time, the first 10% of the scene (the near scene) will be mapped to 0.0 to 0.9 range. In other words, 90% of the precision is used up in the first 10 percent of the viewing distance. If your algorithm relies heavily on depth comparison, you are screwed.

 

The key to handle this problem is to make the depth value linear or making it almost linear. I will describe the two approaches below:

 

Linear Depth Buffer

Notice that multilying World, View, Projection matrices with your position will make it ends up in clip space, (x, y, z, w) = (x_in_clip, y_in_clip, z_in_clip, z_in_view) except that w = z_in_view. We can exploit this fact and instead of storing the standard depth which is obtained by z/w = z_in_clip/z_in_view, we can store linear depth value. There are several variations for mapping z_in_view linearly. For example, you can do:

z_final = z_in_view / camera_far_plane

or you can also do:

z_final = (z_in_view - camera_near_plane) / (camera_far_plane - camera_near_plane)

 

W-Buffer

The idea of w-buffer is to provide a more distributed linear mapping than for z-buffers by inverting the depth value. By doing this, you effectively map the last 90% of the scene (the far scene) to 0.0 to 0.9 range. In other words, w buffer can still produce artifacts when many of the objects in the scene are close to the camera. In comparison to z-buffer, w-buffer has a lot more precision available for objects in the middle to far distance from the viewer. In code language, you would output:

z_final = 1 / z_in_view
 

In conclusion

I've discussed several techniques to alleviate the non-linearity of z-buffer. I hope it can give you light why you may have a lot of artifacts using the standard z-buffer.

 

from :

 

more flexible depth buffer control titled "quasi-linear depth buffer".

Autodesk Canada Co.

转载于:https://www.cnblogs.com/pulas/archive/2012/02/07/2341462.html

你可能感兴趣的文章
Ubuntu 12.04 the system is running in low-graphics mode
查看>>
iOS开发编码建议与编程经验(书写规范)
查看>>
gerrit使用
查看>>
C博客作业01--分支、顺序结构
查看>>
递归求任意数字之间的和
查看>>
FCC 16个初级算法解
查看>>
盒子的水平垂直居中几种方法
查看>>
团队项目简易聊天室开发NABCD分析
查看>>
[USACO4.1]麦香牛块Beef McNuggets 题解报告
查看>>
frame.origin.x 的意思和作用?
查看>>
提示系统启动关于误更改/var下诺干的权限问题,导致系统启动提示The System is running in low-graphics mode问题解决 By ACReaper...
查看>>
添加设置Android编程心得-为TextView添加各种样式
查看>>
[Oracle] Data Pump 详细使用教程(1)- 总览
查看>>
Install windows server 2008 on ESXi 5.1, add to domain and config for remote desktop
查看>>
nullnullupdate linux user or root password
查看>>
安装文件Win7 配置 Nutch 1.2
查看>>
绑定域名到JavaWeb项目,由域名直接访问到网站首页
查看>>
移动端重构实战系列3——各种等分
查看>>
产品应该努力提高用户使用的方便性
查看>>
React 附件动画API ReactCSSTransitionGroup
查看>>