OpenGl alpha test - How to replace AlphaFunc deprecated?
我试图用alpha绘制球体,但是我的Z缓冲区有问题。一些像素是透明的,但是写入Zbuffer中,因此隐藏在后面的不透明像素。
这是我的设置:
1 2 3 4 5 | gl Enable: gl DEPTH_TEST. gl DepthFunc: gl LEQUAL. gl Disable: gl CULL_FACE. gl Enable: gl BLEND. gl BlendFunc: gl SRC_ALPHA with: gl ONE_MINUS_SRC_ALPHA. |
我知道函数
这在片段着色器中非常容易实现:
1 2 3 4 5 6 7 8 9 10 | uniform float alpha_threshold; void main() { vec4 color = ...; if(color.a <= alpha_threshold) // Or whichever comparison here discard; gl_FragColor = color; } |