34 lines
1.1 KiB
GLSL
34 lines
1.1 KiB
GLSL
// Protanopia -- red-blind.
|
|
//
|
|
// Panama's accessibility color filters. Selected by the `colorFilter`
|
|
// preference; hypr/looks.lua maps the enum to this path at config time and
|
|
// services/SystemSettings.qml does the same live.
|
|
//
|
|
// The matrix is the feColorMatrix set the mock uses, which is the widely
|
|
// carried HCIRN-derived one: it redistributes the red channel into the two the
|
|
// eye can still separate, so a red/green pair that was one colour becomes two
|
|
// distinguishable ones. It is a CORRECTION, not a simulation -- the point is to
|
|
// make the screen readable, not to show what protanopia looks like.
|
|
//
|
|
// Row-major here, column-major to GLSL: mat3 takes its arguments column by
|
|
// column, so the transpose below is the matrix as written in the SVG.
|
|
|
|
#version 300 es
|
|
|
|
precision mediump float;
|
|
in vec2 v_texcoord;
|
|
layout(location = 0) out vec4 fragColor;
|
|
uniform sampler2D tex;
|
|
|
|
const mat3 protanopia = mat3(
|
|
0.567, 0.558, 0.000,
|
|
0.433, 0.442, 0.242,
|
|
0.000, 0.000, 0.758
|
|
);
|
|
|
|
void main() {
|
|
vec4 pixColor = texture(tex, v_texcoord);
|
|
|
|
fragColor = vec4(clamp(protanopia * pixColor.rgb, 0.0, 1.0), pixColor.a);
|
|
}
|