OpenGL transparency not working properly

牧云@^-^@ 提交于 2019-12-02 01:40:33

Although the color of the fragments you generate is transparent, they are still written to the depth buffer so that some of the triangles of your tree obscure the others, despite not affecting the color buffer.

To properly render transparent object you must

  1. Draw all the opaque objects first
  2. Disable depth buffer writes
  3. Sort the transparent triangles
  4. Render the transparent triangles from back to front.

There is a trick to avoid the above complexity though. If you are OK with only two alpha values (zero and one), then you can enable alpha test (glAlphaFunc) to discard the transparent fragments completely.

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