As OpenGL 3.3 Core does not have this feature anymore, we have to implement it in GLSL.
I've only seen the game use the D3DCMP_NOTEQUAL mode, so it's hardcoded in the shader.
The alpha-ref is also never set, so it's also the default (0x00) and hardcoded in the shader.
Further modes and the alpha-ref will be implemented as they are encountered.
I assumed an alpha value of 0x00 = 0.0 and 1.0 = 0xFF; with proper rounding (so it's not biased towards 0x00 (floor) or 0xFF (ceil))
Threfore, the round() in the shader is necessary because the GLSL spec says "When constructors are used to convert any floating-point type to an integer type, the fractional part of the floating-point value is dropped." (floor).
Actually, doing a floor() (or simply removing the round()) would make it more likely that pixels get discarded. This would make the following glitch disappear completly:
For accuracy, I recreated the expected original behaviour (using round()). We should test how this behaves on original 90'ies hardware and consider changing it in our D3D implementation. For now, it is assumed that the pictured glitch is just a glitch in the PC version of the original game.
This implements alpha testing.
As OpenGL 3.3 Core does not have this feature anymore, we have to implement it in GLSL. I've only seen the game use the
D3DCMP_NOTEQUAL
mode, so it's hardcoded in the shader. The alpha-ref is also never set, so it's also the default (0x00) and hardcoded in the shader. Further modes and the alpha-ref will be implemented as they are encountered.I assumed an alpha value of 0x00 = 0.0 and 1.0 = 0xFF; with proper rounding (so it's not biased towards 0x00 (
floor
) or 0xFF (ceil
)) Threfore, theround()
in the shader is necessary because the GLSL spec says "When constructors are used to convert any floating-point type to an integer type, the fractional part of the floating-point value is dropped." (floor
). Actually, doing afloor()
(or simply removing theround()
) would make it more likely that pixels get discarded. This would make the following glitch disappear completly:(Click here to see how severe the issue is on master, without any alpha-testing)
For accuracy, I recreated the expected original behaviour (using
round()
). We should test how this behaves on original 90'ies hardware and consider changing it in our D3D implementation. For now, it is assumed that the pictured glitch is just a glitch in the PC version of the original game.Closes #41