RGB XYZ Conversion in OpenGL - tonykwok/made-mistakes-again GitHub Wiki

//
// Gamut conversion
//
const mat3 M_SRGB_TO_XYZ = mat3(
     0.4123907992659595, 0.2126390058715103,  0.01933081871559185,
     0.3575843393838779, 0.7151686787677559,  0.1191947797946259,
     0.1804807884018343, 0.07219231536073372, 0.9505321522496606
);

const mat3 M_XYZ_TO_SRGB = mat3(
     3.240969941904521, -0.9692436362808798,  0.05563007969699361,
    -1.537383177570093,  1.87596750150772,   -0.2039769588889765,
    -0.4986107602930033, 0.04155505740717561, 1.056971514242878
);

const mat3 M_DISPLAY_P3_TO_XYZ = mat3(
     0.4865709486482162, 0.2289745640697488, 0.0,
     0.2656676931690929, 0.6917385218365062, 0.04511338185890257,
     0.1982172852343625, 0.079286914093745,  1.04394436890097500
);

const mat3 M_XYZ_TO_DISPLAY_P3 = mat3(
     2.493496911941424, -0.829488969561575,   0.03584583024378433,
    -0.9313836179191236, 1.762664060318346,  -0.07617238926804171,
    -0.4027107844507168, 0.02362468584194359, 0.9568845240076873
);

const mat3 M_BT2020_TO_XYZ = mat3(
     0.6369580483012913, 0.262700212011267,   0.0,
     0.1446169035862083, 0.677998071518871,   0.0280726930490875,
     0.168880975164172,  0.05930171646986194, 1.06098505771079
);

const mat3 M_XYZ_TO_BT2020 = mat3(
     1.716651187971267, -0.666684351832489,   0.01763985744531091,
    -0.3556707837763924, 1.616481236634939,  -0.04277061325780865,
    -0.2533662813736598, 0.01576854581391113, 0.942103121235474
);

sRGB-XYZ.mac (Maxima Algebra System)