1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 16:49:55 +00:00
openmw-tes3mp/files/shaders/alpha.glsl
AnyOldName3 a4f32a469e Work around Nvidia driver bug
https://www.khronos.org/registry/OpenGL/specs/gl/GLSLangSpec.1.20.pdf
Section 4.1.3 says that hexadecimal integer literals are supported, but
Nvidia have never read a specification since their founding, so their
engineers didn't know that hexadecimal integer literals are requires to
be supported to advertise support OpenGL versions with GLSL support.
2020-12-18 01:36:20 +00:00

38 lines
No EOL
1.2 KiB
GLSL

#define FUNC_NEVER 512 // 0x0200
#define FUNC_LESS 513 // 0x0201
#define FUNC_EQUAL 514 // 0x0202
#define FUNC_LEQUAL 515 // 0x0203
#define FUNC_GREATER 516 // 0x0204
#define FUNC_NOTEQUAL 517 // 0x0205
#define FUNC_GEQUAL 518 // 0x0206
#define FUNC_ALWAYS 519 // 0x0207
#if @alphaFunc != FUNC_ALWAYS && @alphaFunc != FUNC_NEVER
uniform float alphaRef;
#endif
void alphaTest()
{
#if @alphaFunc == FUNC_NEVER
discard;
#elif @alphaFunc == FUNC_LESS
if (gl_FragData[0].a > alphaRef)
discard;
#elif @alphaFunc == FUNC_EQUAL
if (gl_FragData[0].a != alphaRef)
discard;
#elif @alphaFunc == FUNC_LEQUAL
if (gl_FragData[0].a >= alphaRef)
discard;
#elif @alphaFunc == FUNC_GREATER
if (gl_FragData[0].a < alphaRef)
discard;
#elif @alphaFunc == FUNC_NOTEQUAL
if (gl_FragData[0].a == alphaRef)
discard;
#elif @alphaFunc == FUNC_GEQUAL
if (gl_FragData[0].a <= alphaRef)
discard;
#endif
}