Files
scummvm-cursorfix/engines/freescape/shaders/freescape_triangle.fragment
2026-02-02 04:50:13 +01:00

42 lines
888 B
Plaintext

OUTPUT
uniform UBOOL useStipple;
uniform int stipple[128];
varying vec4 var_color;
void main()
{
if (UBOOL_TEST(useStipple)) {
// Calculate the 32x32 pattern coordinates
ivec2 coord = ivec2(gl_FragCoord.xy);
// Calculate the byte position and bit position within that byte
int x = int(mod(float(coord.x), 32.));
int y = int(mod(float(coord.y), 32.));
// Each row in the 32x32 pattern is represented by 4 bytes (4 * 8 bits = 32 bits)
int byteIndex = y * 4 + (x / 8);
int bitIndex = int(mod(float(x), 8.));
// Get the stipple pattern byte
int patternByte = 0;
for (int i = 0; i < 128; i++) {
if (i == byteIndex) {
patternByte = stipple[i];
break;
}
}
for (int i = 0; i < 7; i++) {
if (i >= 7 - bitIndex)
break;
patternByte = patternByte / 2;
}
if (int(mod(float(patternByte), 2.)) == 0)
discard;
}
outColor = var_color;
}