Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

请教: 深度缓存记录 1/w #6

Open
lvjiahui opened this issue Sep 18, 2021 · 3 comments
Open

请教: 深度缓存记录 1/w #6

lvjiahui opened this issue Sep 18, 2021 · 3 comments

Comments

@lvjiahui
Copy link

请问深度缓存为什么不是 z/w 呢?
是我理解有误,还是有什么讲究呢?

@Mr-Rainbow-777
Copy link

我也想问

@whl33886
Copy link

whl33886 commented Oct 8, 2022

请问深度缓存为什么不是 z/w 呢? 是我理解有误,还是有什么讲究呢?

按照我的理解,z/w和1/w是线性关系,在做深度测试的时候是等效的。

@skywind3000
Copy link
Owner

Depth buffer 的实现有 z-buffer,还有 w-buffer:

https://learn.microsoft.com/en-us/windows-hardware/drivers/display/w-buffering

各有各的实现吧,不少软件实现用这个,用 1/w 的好处有几个:

1)同 z/w 是等效的。
2)最远处是 0,比较好清零。
3)屏幕空间插值时,1/w 最先被计算出来,不必算其他的就能直接判断。
4)不用特殊处理 z。

我觉得用起来更清爽。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants