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

关于8.1开篇zwrite关闭的问题 #22

Closed
qiyuedunk opened this issue Jul 28, 2016 · 3 comments
Closed

关于8.1开篇zwrite关闭的问题 #22

qiyuedunk opened this issue Jul 28, 2016 · 3 comments

Comments

@qiyuedunk
Copy link

经测试发现,透明物体在前,不透明物体在后的情况中,只有先绘制透明物体,再绘制不透明物体,才会出现透明物体完全挡住不透明物体的情况,与zwrite开关无关。
透明shader配置:Tags { "Queue" = "Transparent" } ZWrite On/Off Blend SrcAlpha OneMinusSrcAlpha
不透明shader配置:Tags { "Queue" = "Transparent+/-100" } ZWrite On
也就是说,几遍alpha blend时,即便打开了zwrite,只要保证不透明物体先绘制,是可以正常混合的。

@candycat1992
Copy link
Owner

如果你打开了zwrite,透明和透明物体之间就会出现问题。试想两个透明物体A和B,A在前B在后,那么必须是B先渲染A后渲染才会得到正确的结果。但问题是,你无法保证所有的透明物体之间都由完全正确的排序关系,如果A和B互相遮挡,那么无论谁先绘制都会发现有一部分是只有一个物体的颜色,而没有发生混合。

当前的半透明解决方法是保证在不透明物体后面、并按从前往后顺序、关闭zwrite,这种方法当然也不是万能的,例如上面说到的A和B互相遮挡下也会出现问题,但出现的错误是“混合错误”,而不是“完全没有进行混合”。而且关闭了zwrite可以保证一定不会妨碍不透明物体的渲染,这是非常重要的,即便游戏引擎没有保证先绘制不透明物体,半透明也不会影响游戏里不透明物体的渲染。我认为这是优先级最高的需求。

@qiyuedunk
Copy link
Author

感谢回复,对于zwrite 关闭的正确性没有疑问,只是看到书中的举例感到困惑,所以这里提了一下。书很赞,快看完了,持续关注中.

@candycat1992
Copy link
Owner

感谢支持呀,会争取在下一次印刷时添加更多的说明。

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

No branches or pull requests

2 participants