Skip to content

Commit 83f9380

Browse files
authored
Add DisplayP3 colorspaces (#1368)
This PR adds support for the [DisplayP3](https://www.color.org/chardata/rgb/DisplayP3.xalter) colorspace, a wider gamut range for computer displays that is standard in the Apple ecosystem and elsewhere. More information can be found in this [developer video](https://developer.apple.com/videos/play/wwdc2017/821/). DisplayP3 uses the DCI-P3 gamut with a D65 white point and an sRGB transfer curve. In keeping with discussions with the OCIO group, we've opted to name it in the form `<transfer_curve>_<gamut>` for consistency. Hence we add the following two colorspaces: * srgb_displayp3 * lin_displayp3
1 parent a9e06a4 commit 83f9380

5 files changed

Lines changed: 132 additions & 2 deletions

File tree

documents/Specification/inprog_v1.39/MaterialX.Specification.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,8 @@ By default, MaterialX supports the following color spaces as defined in ACES 1.2
339339
* `lin_srgb`
340340
* `adobergb`
341341
* `lin_adobergb`
342+
* `srgb_displayp3`
343+
* `lin_displayp3`
342344

343345
The working color space of a MaterialX document is defined by the `colorspace` attribute of its root &lt;materialx> element, and it is strongly recommended that all &lt;materialx> elements define a specific `colorspace` if they wish to use a color-managed workflow rather than relying on a default colorspace setting from an external configuration file.
344346

libraries/README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,18 @@ This folder contains the standard data libraries for MaterialX, providing declar
4242
- [lama](bxdf/lama) : Graph definitions of the [MaterialX Lama](https://rmanwiki.pixar.com/display/REN24/MaterialX+Lama) node set.
4343

4444
## Color Management Library
45-
- MaterialX shader generation natively supports a small set of common spaces for input colors, with all color transforms implemented as language-independent MaterialX graphs. The canonical definitions of these color transforms may be found in the OpenColorIO configuration for [ACES 1.2](https://github.com/colour-science/OpenColorIO-Configs/tree/feature/aces-1.2-config/aces_1.2).
46-
- lin_rec709, g18_rec709, g22_rec709, rec709_display, acescg (lin_ap1), g22_ap1, srgb_texture, lin_adobergb, adobergb
45+
- MaterialX shader generation natively supports a small set of common spaces for input colors, with all color transforms implemented as language-independent MaterialX graphs.The canonical definitions of these color transforms may be found in the OpenColorIO configuration for [ACES 1.2](https://github.com/colour-science/OpenColorIO-Configs/tree/feature/aces-1.2-config/aces_1.2).
46+
- lin_rec709
47+
- g18_rec709
48+
- g22_rec709
49+
- rec709_display
50+
- acescg (lin_ap1)
51+
- g22_ap1
52+
- srgb_texture
53+
- lin_adobergb
54+
- adobergb
55+
- srgb_displayp3
56+
- lin_displayp3
4757
- [cmlib](cmlib)
4858
- [cmlib_defs.mtlx](cmlib/cmlib_defs.mtlx) : Nodedef declarations.
4959
- [cmlib_ng.mtlx](cmlib/cmlib_ng.mtlx) : Nodegraph definitions.

libraries/cmlib/cmlib_defs.mtlx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,24 @@
8787
<output name="out" type="color4" />
8888
</nodedef>
8989

90+
<nodedef name="ND_srgb_displayp3_to_lin_rec709_color3" node="srgb_displayp3_to_lin_rec709" nodegroup="colortransform">
91+
<input name="in" type="color3" value="0.0, 0.0, 0.0" />
92+
<output name="out" type="color3" />
93+
</nodedef>
94+
95+
<nodedef name="ND_srgb_displayp3_to_lin_rec709_color4" node="srgb_displayp3_to_lin_rec709" nodegroup="colortransform">
96+
<input name="in" type="color4" value="0.0, 0.0, 0.0, 1.0" />
97+
<output name="out" type="color4" />
98+
</nodedef>
99+
100+
<nodedef name="ND_lin_displayp3_to_lin_rec709_color3" node="lin_displayp3_to_lin_rec709" nodegroup="colortransform">
101+
<input name="in" type="color3" value="0.0, 0.0, 0.0" />
102+
<output name="out" type="color3" />
103+
</nodedef>
104+
105+
<nodedef name="ND_lin_displayp3_to_lin_rec709_color4" node="lin_displayp3_to_lin_rec709" nodegroup="colortransform">
106+
<input name="in" type="color4" value="0.0, 0.0, 0.0, 1.0" />
107+
<output name="out" type="color4" />
108+
</nodedef>
109+
90110
</materialx>

libraries/cmlib/cmlib_ng.mtlx

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,4 +294,74 @@
294294
<output name="out" type="color4" nodename="asColor4" />
295295
</nodegraph>
296296

297+
<nodegraph name="NG_srgb_displayp3_to_lin_rec709_color3" nodedef="ND_srgb_displayp3_to_lin_rec709_color3">
298+
<constant name="mat" type="matrix33">
299+
<input name="value" type="matrix33" value="1.22493029, -0.22492968, 0.00000006, -0.04205868, 1.04205894, -0.00000001, -0.01964128, -0.07864794, 1.09828925" />
300+
</constant>
301+
<!-- Use srgb_texture_to_lin_rec709 to convert from sRGB to Lin before passing to the mat conversion -->
302+
<srgb_texture_to_lin_rec709 name="srgb_transform" type="color3">
303+
<input name="in" type="color3" interfacename="in" />
304+
</srgb_texture_to_lin_rec709>
305+
<convert name="asVec" type="vector3">
306+
<input name="in" type="color3" nodename="srgb_transform" />
307+
</convert>
308+
<transformmatrix name="transform" type="vector3">
309+
<input name="in" type="vector3" nodename="asVec" />
310+
<input name="mat" type="matrix33" nodename="mat" />
311+
</transformmatrix>
312+
<convert name="asColor" type="color3">
313+
<input name="in" type="vector3" nodename="transform" />
314+
</convert>
315+
<output name="out" type="color3" nodename="asColor" />
316+
</nodegraph>
317+
318+
<nodegraph name="NG_srgb_displayp3_to_lin_rec709_color4" nodedef="ND_srgb_displayp3_to_lin_rec709_color4">
319+
<convert name="asColor3" type="color3">
320+
<input name="in" type="color4" interfacename="in" />
321+
</convert>
322+
<srgb_displayp3_to_lin_rec709 name="transform" type="color3">
323+
<input name="in" type="color3" nodename="asColor3" />
324+
</srgb_displayp3_to_lin_rec709>
325+
<combine4 name="asColor4" type="color4">
326+
<input name="in1" type="float" nodename="transform" channels="r" />
327+
<input name="in2" type="float" nodename="transform" channels="g" />
328+
<input name="in3" type="float" nodename="transform" channels="b" />
329+
<input name="in4" type="float" interfacename="in" channels="a" />
330+
</combine4>
331+
<output name="out" type="color4" nodename="asColor4" />
332+
</nodegraph>
333+
334+
<nodegraph name="NG_lin_displayp3_to_lin_rec709_color3" nodedef="ND_lin_displayp3_to_lin_rec709_color3">
335+
<constant name="mat" type="matrix33">
336+
<input name="value" type="matrix33" value="1.22493029, -0.22492968, 0.00000006, -0.04205868, 1.04205894, -0.00000001, -0.01964128, -0.07864794, 1.09828925" />
337+
</constant>
338+
<convert name="asVec" type="vector3">
339+
<input name="in" type="color3" interfacename="in" />
340+
</convert>
341+
<transformmatrix name="transform" type="vector3">
342+
<input name="in" type="vector3" nodename="asVec" />
343+
<input name="mat" type="matrix33" nodename="mat" />
344+
</transformmatrix>
345+
<convert name="asColor" type="color3">
346+
<input name="in" type="vector3" nodename="transform" />
347+
</convert>
348+
<output name="out" type="color3" nodename="asColor" />
349+
</nodegraph>
350+
351+
<nodegraph name="NG_lin_displayp3_to_lin_rec709_color4" nodedef="ND_lin_displayp3_to_lin_rec709_color4">
352+
<convert name="asColor3" type="color3">
353+
<input name="in" type="color4" interfacename="in" />
354+
</convert>
355+
<lin_displayp3_to_lin_rec709 name="transform" type="color3">
356+
<input name="in" type="color3" nodename="asColor3" />
357+
</lin_displayp3_to_lin_rec709>
358+
<combine4 name="asColor4" type="color4">
359+
<input name="in1" type="float" nodename="transform" channels="r" />
360+
<input name="in2" type="float" nodename="transform" channels="g" />
361+
<input name="in3" type="float" nodename="transform" channels="b" />
362+
<input name="in4" type="float" interfacename="in" channels="a" />
363+
</combine4>
364+
<output name="out" type="color4" nodename="asColor4" />
365+
</nodegraph>
366+
297367
</materialx>

resources/Materials/TestSuite/stdlib/color_management/color_management.mtlx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,20 @@
6464
<input name="base_color" type="color3" value="1, 1, 1" nodename="image_lin_adobergb" />
6565
</standard_surface>
6666
<output name="image_lin_adobergb_output" type="surfaceshader" nodename="image_lin_adobergb_standard_surface8" />
67+
<image name="image_srgb_displayp3" type="color3">
68+
<input name="file" type="filename" value="resources/Images/grid.png" colorspace="srgb_displayp3" />
69+
</image>
70+
<standard_surface name="image_srgb_displayp3_standard_surface9" type="surfaceshader">
71+
<input name="base_color" type="color3" nodename="image_srgb_displayp3" />
72+
</standard_surface>
73+
<output name="image_srgb_displayp3_output" type="surfaceshader" nodename="image_srgb_displayp3_standard_surface9" />
74+
<image name="image_lin_displayp3" type="color3">
75+
<input name="file" type="filename" value="resources/Images/grid.png" colorspace="lin_displayp3" />
76+
</image>
77+
<standard_surface name="image_lin_displayp3_standard_surface10" type="surfaceshader">
78+
<input name="base_color" type="color3" nodename="image_lin_displayp3" />
79+
</standard_surface>
80+
<output name="image_lin_displayp3_output" type="surfaceshader" nodename="image_lin_displayp3_standard_surface10" />
6781
<constant name="color_lin_rec709" type="color4">
6882
<input name="value" type="color4" value="0.5, 0.0, 0.0, 1.0" colorspace="lin_rec709" />
6983
</constant>
@@ -127,5 +141,19 @@
127141
<input name="base_color" type="color3" value="1, 1, 1" nodename="color_lin_adobergb" channels="rgb" />
128142
</standard_surface>
129143
<output name="color_lin_adobergb_output" type="surfaceshader" nodename="color_lin_adobergb_standard_surface8" />
144+
<constant name="color_srgb_displayp3" type="color4">
145+
<input name="value" type="color4" value="0.5, 0.0, 0.0, 1.0" colorspace="srgb_displayp3" />
146+
</constant>
147+
<standard_surface name="color_srgb_displayp3_standard_surface5" type="surfaceshader">
148+
<input name="base_color" type="color3" nodename="color_srgb_displayp3" channels="rgb" />
149+
</standard_surface>
150+
<output name="color_srgb_displayp3_output" type="surfaceshader" nodename="color_srgb_displayp3_standard_surface5" />
151+
<constant name="color_lin_displayp3" type="color4">
152+
<input name="value" type="color4" value="0.5, 0.0, 0.0, 1.0" colorspace="lin_displayp3" />
153+
</constant>
154+
<standard_surface name="color_lin_displayp3_standard_surface5" type="surfaceshader">
155+
<input name="base_color" type="color3" nodename="color_lin_displayp3" channels="rgb" />
156+
</standard_surface>
157+
<output name="color_lin_displayp3_output" type="surfaceshader" nodename="color_lin_displayp3_standard_surface5" />
130158
</nodegraph>
131159
</materialx>

0 commit comments

Comments
 (0)