-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolourblind.glsl
75 lines (66 loc) · 3.85 KB
/
colourblind.glsl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// |X| |0.4124564 0.3575761 0.1804375| |R| // --> Row 1
// |Y| = |0.2126729 0.7151522 0.0721750| |G|
// |Z| |0.0193339 0.1191920 0.9503041| |B|
mat3 M_XYZ_From_sRGB = mat3( 0.4124564, 0.2126729, 0.0193339, // --> Column 1
0.3575761, 0.7151522, 0.1191920,
0.1804375, 0.0721750, 0.9503041 );
// applies the Hunt-Pointer-Estevez transformation (normalized to D65)
// |L| | 0.4002 0.7076 -0.0808| |X|
// |M| = |-0.2263 1.1653 0.0457| |Y|
// |S| | 0 0 0.9182| |Z|
mat3 M_LMS_From_XYZ = mat3( 0.4002, -0.2263, 0, // --> Column 1
0.7076, 1.1653, 0,
-0.0808, 0.0457, 0.9182);
// M_sRGB * M_HPE
// |L| |0.3139902162 0.63951293834 0.04649754622| |R|
// |M| = |0.15537240628 0.75789446163 0.08670141862| |G|
// |S| |0.01775238698 0.1094420944 0.87256922462| |B|
mat3 M_LMS_From_RGB = mat3( 0.3139902162, 0.15537240628, 0.01775238698,
0.63951293834, 0.75789446163, 0.1094420944,
0.04649754622, 0.08670141862, 0.87256922462);
// inverse matrix of above
// |R| | 5.4722120583802 -4.6419600983546 0.16963707682798| |L|
// |G| = |-1.1252418955335 2.2931709380607 -0.16789520222371| |M|
// |B| | 0.02980165117346 -0.19318072825714 1.1636478927838 | |S|
mat3 M_sRGB_HPE_inv = mat3( 5.4722120537736, -1.1252418955335, 0.02980165117346,
-4.6419600983546, 2.2931709380607, -0.19318072825714,
0.16963707682798, -0.16789520222371, 1.1636478927838 );
// |L_P| |0 1.05118294 -0.05116099| |L|
// |M_P| = |0 1 0 | |M|
// |S_P| |0 0 1 | |S|
mat3 M_ProtanopiaLMS = mat3( 0, 0, 0,
1.05118294, 1, 0,
-0.05116099, 0, 1 );
// |L_D| |1 0 0 | |L|
// |M_D| = |0.9513092 0 0.04866992| |M|
// |S_D| |0 0 1 | |S|
mat3 M_DeuteranopiaLMS = mat3( 1, 0.9513092, 0,
0, 0, 0,
0, 0.04866992, 1 );
// |L_T| |1 0 0| |L|
// |M_T| = |0 1 0| |M|
// |S_T| |-0.86744736 1.86727089 1| |S|
mat3 M_DeuteranopiaLMS = mat3( 1, 0, -0.86744736,
0, 1, 1.86727089,
0, 0, 1 );
// M_sRGB_HPE_inv * M_ProtLMS * M_sRGB_HPE
// |R_P| | 0.17055699213417 0.82944301379913 2.91188E-9 | |R|
// |G_P| = | 0.17055699092998 0.82944300785005 -5.98679E-10| |G|
// |B_P| |-0.00451714424166 0.00451714427397 1 | |B|
mat3 M_Protanopia = mat3( 0.17055699213417, 0.17055699092998, -0.00451714424166,
0.82944301379913, 0.82944300785005, 0.00451714427397,
2.91188E-9, 5.98679E-10, 1 );
// M_sRGB_HPE_inv * M_DeutLMS * M_sRGB_HPE
// |R_D| | 0.33066007266046 0.66933992517563 3.559314E-9| |R|
// |G_D| = | 0.3306600738776 0.66933992719147 -1.758327E-9| |G|
// |B_D| |-0.02785538261323 0.02785538252318 1 | |B|
mat3 M_Deuteranopia = mat3( 0.33066007266046, 0.3306600738776, -0.02785538261323,
0.66933992517563, 0.66933992719147, 0.02785538252318,
3.559314E-9, -1.758327E-9, 1 );
// M_sRGB_HPE_inv * M_TritLMS * M_sRGB_HPE
// |R_T| | 1 0.1273988631088 -0.12739886341072| |R|
// |G_T| = |-4.486E-11 0.87390929928361 0.12609070101523| |G|
// |B_T| | 3.1113E-10 0.87390929725848 0.12609070067115| |B|
mat3 M_Tritanopia = mat3( 1, -4.486E-11, 3.1113E-10,
0.1273988631088, 0.87390929928361, 0.87390929725848,
-0.12739886341072, 0.12609070101523, 0.12609070067115 );