Search code examples
openglopengl-3opengl-4opengl-2.0

What happened to glAlphaFunc? Why was it deprecated?


I was reading about the side effects of using "discard" in OpenGL's fragment shader, such as early testing being disabled. But I could not find any alternative for alpha-testing until I stumbled upon glAlphaFunc, which seems to be deprecated since OpenGL 3.0. However I could not find any documentation on why it has been removed, and there seems to be no alternative to "discard".


Solution

  • Alpha testing has (on all implementations I know of) never been done in the early testing stage. I don't think it is even possible there because before the fragment shader has been executed there is no concept of a color or a alpha channel.

    In addition, enabling alpha testing usually disables early depth testing (see here), which means that it behaves the same as when discard is used in the shader.

    I cannot directly answer why glAlphaFunc has been removed, but since there is no real difference between discard and alpha testing, it's not really a problem.