<p>The discrepancy comes from chromatic adaptation, which is included in the matrix from shadertoy. If you combine XYZ->AP1 with D65->D60 from the aces page you end up with the same matrix that I got by chaining XYZ->sRGB and sRGB->AP1 (with chromatic adaptation) together.</p>

CC BY-SA 4.0
2020-05-15T08:31:06.117Z
2020-05-15T08:31:06.117Z
B_old
<p>I'm confused about how to properly convert from sRGB or XYZ color space to ACEScg. Specifically whether I have to account for differences in white point explicitly.</p>

<p>The <a href="https://github.com/ampas/aces-dev/blob/master/transforms/ctl/README-MATRIX.md" rel="nofollow noreferrer">aces github page</a> gives the following matrix to convert from XYZ to AP1:</p>

<pre><code> 1.6410233797, -0.3248032942, -0.2364246952,
-0.6636628587,  1.6153315917,  0.0167563477,
 0.0117218943, -0.0082844420,  0.9883948585
</code></pre>

<p><a href="http://terathon.com/blog/rgb-xyz-conversion-matrix-accuracy/" rel="nofollow noreferrer">FGED2</a> gives the following matrix to convert from XYZ to sRGB with white point D65:</p>

<pre><code> 3.240970, -1.537383, -0.498611,
-0.969244,  1.875968,  0.041555,
 0.055630, -0.203977,  1.056972 
</code></pre>

<p>And <a href="https://www.shadertoy.com/view/WltSRB" rel="nofollow noreferrer">this shadertoy</a> gives the following matrix to convert from sRGB to AP1:</p>

<pre><code>0.613097, 0.339523, 0.047379,
0.070194, 0.916354, 0.013452,
0.020616, 0.109570, 0.869815
</code></pre>

<p>So I figured if I combine the XYZ->sRGB and sRGB->AP1 matrices it should be the same result as XYZ->AP1. However there is a small, but noticeable difference:</p>

<pre><code> 1.66058,    -0.315295,  -0.24151,
-0.659926,    1.60839,    0.017298,
 0.00900358, -0.00356713, 0.913644
</code></pre>

<p>I assume the difference comes from the way the white point is handled? My question is, which is "correct". I have use cases for both XYZ->AP1 and sRGB->AP1, but now I'm irritated that my matrices don't allow me to round-trip.</p>

<colorspace>
How to convert from XYZ or sRGB to ACEScg/AP1
B_old
# How to convert from XYZ or sRGB to ACEScg/AP1

(Asked by: username_0 on 2020-05-13)

I'm confused about how to properly convert from sRGB or XYZ color space to ACEScg. Specifically whether I have to account for differences in white point explicitly.

The [aces github page](https://github.com/ampas/aces-dev/blob/master/transforms/ctl/README-MATRIX.md) gives the following matrix to convert from XYZ to AP1:

```
 1.6410233797, -0.3248032942, -0.2364246952,
-0.6636628587,  1.6153315917,  0.0167563477,
 0.0117218943, -0.0082844420,  0.9883948585

```

[FGED2](http://terathon.com/blog/rgb-xyz-conversion-matrix-accuracy/) gives the following matrix to convert from XYZ to sRGB with white point D65:

```
 3.240970, -1.537383, -0.498611,
-0.969244,  1.875968,  0.041555,
 0.055630, -0.203977,  1.056972 

```

And [this shadertoy](https://www.shadertoy.com/view/WltSRB) gives the following matrix to convert from sRGB to AP1:

```
0.613097, 0.339523, 0.047379,
0.070194, 0.916354, 0.013452,
0.020616, 0.109570, 0.869815

```

So I figured if I combine the XYZ->sRGB and sRGB->AP1 matrices it should be the same result as XYZ->AP1. However there is a small, but noticeable difference:

```
 1.66058,    -0.315295,  -0.24151,
-0.659926,    1.60839,    0.017298,
 0.00900358, -0.00356713, 0.913644

```

I assume the difference comes from the way the white point is handled? My question is, which is "correct". I have use cases for both XYZ->AP1 and sRGB->AP1, but now I'm irritated that my matrices don't allow me to round-trip.

**Tags:** colorspace


---

## 1 answers

### Answer by username_0 on 2020-05-15. Score: 2 | Accepted answer

The discrepancy comes from chromatic adaptation, which is included in the matrix from shadertoy. If you combine XYZ->AP1 with D65->D60 from the aces page you end up with the same matrix that I got by chaining XYZ->sRGB and sRGB->AP1 (with chromatic adaptation) together.


---

