White Pixels With GL_POLYGON_SMOOTH

时光毁灭记忆、已成空白 提交于 2020-01-14 05:21:11

问题


I had a problem where white pixels appeared randomly (sort of) on objects in OpenGL. This is an example of what was going on. While searching Stack Overflow for other people who may have had this problem, I found that GL_POLYGON_SMOOTH wasn't worth enabling. I disabled it, and the spots disappeared (this was lucky of me). This was very lucky, but I still don't understand why enabling GL_POLYGON_SMOOTH creates these artifact-thingies. Can someone explain why they appear? Also note I had glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) going on.


回答1:


GL_POLYGON_SMOOTH is selective anti-aliasing, as opposed to fullscene anti-aliasing (such as MSAA or SSAA).

The real problem here is basically that this works by blending the silhouette edges of rasterized polygons with pixels already in the frame buffer. It is order-dependent, so unless your polygons are perfectly depth sorted (in which case you would not need a depth buffer) it is not going to generate perfect results. And even if you did have everything perfectly sorted, in many scenes the amount of overdraw this would require would be ridiculous.

Multisample anti-aliasing is preferred these days, it avoids the issues of order dependence, you have much better control over the quality vs. performance and you can actually implement it yourself using multisample texturing. GL_POLYGON_SMOOTH has a quality hint (fast/nice) and that is it.



来源:https://stackoverflow.com/questions/18433560/white-pixels-with-gl-polygon-smooth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!