How to make 3D LUTs in Nuke (R´B´G´to X´Y´Z´)

In this post there are more 3D LUTS

Updated in 2016 with some clarifications

The built in SRGB TO XYZ conversion used in some DCP conversion software do not have the correct color science.

See this post for more info.

The included XYZ 3D LUTs in this post are proof that you can generate 3D LUTs using the color science math from the REC709 example on page 42 in the “SMPTE Digital Cinema White Gamut Practices Study Group Report” by Rod Bogart and Rick Sayre.

The R´G´B´ values 4095, 4095, 4095 ends up as 3883 3960 4092 in X´Y´Z´

 

 

The “SMPTE Digital Cinema White Gamut Practices Study Group Report” (Linkfrom 2009 concluded that the color science used to make some commercial DCPs around 2008 was not correct (out of gamut).

The color science is explained more in SMPTE EG 432-1:2010

They explain how to use D55, D60, D61 and D65 as mastering whites and how these white points fit inside X´Y´Z´. They explain that DCI White is not necessary the mastering white.

With SMPTE 431.2:2011 they made a new projector configuration file (PCF) standard that is called Virtual White.

The DCI specifications  says that the projectors in cinemas should follow SMPTE 431.2:2011.

 

Update 2016

The color science math do get to X´Y´Z´ in this post produces the correct values for white in X´Y´Z.

In NUKE you can make 3D LUTs for Resolve and other software that have 3×3 SMPTE RP-177 color matrix conversions, gamma conversions and multiplications baked in.

The generateLUT node is now disabled in NUKE non-commercial (formerly PKL).

Links:
Nuke

http://help.thefoundry.co.uk/nuke/content/reference_guide/color_nodes/generatelut.html

Blackmagic Davinci Resolve

Example 1:
Making a REC709/SRGB R´G´B´to DCDM X´Y´Z´ 3D LUT for Resolve:

How to make a R`G`B` to X´Y´Z´ 3D LUT in NUKE:

 

-In the CMSTestPattern node I used a Cube size of 65, alternatives are 33 or 17.

-Linearize the R´G´B´ to RGB with a gamma function in a Gamma node: Example: 2.4 simplified gamma function= 0.416667
Alternative: SRGB 2.2 simplified gamma function=0.45

-Apply the rec709/SRGB RGB XYZ to RP-177 3×3 NPM color matrix in a ColorMatrix node.

The NPM from matlab after doing the RP-177 math is:
0.412390799265959 0.357584339383878 0.180480788401834
0.212639005871510   0.715168678767756   0.072192315360734
0.019330818715592   0.119194779794626  0.950532152249661

The middle row sums to 1.

The NPM after copying and pasting into the Nuke colormatrix node:

0.4123908  0.35758434   0.18048079
0.21263901 0.71516867   0.07219232
0.01933082 0.11919478   0.95053215

This is very similar to the example.

The middle row should sum to 1 according to RP-177 so I changed 0.71516868 to 0.71516867.

-Apply the normalizing constant multiplication in a multiply node. Luminance (48) divided by the normalizing constant (52.37) = 0.91655527
After pasting it into nuke it is shorten to:
0.916555

-Apply the DCP 2.6 gamma in a Gamma node to get X´Y´Z´ values.

-In the GenerateLut node I put: .3dl, 12 bit in/out, 3dl file format
autodesk flame/smoke.
Alternative: 16 bit.

The values for 4095,4095,4095 in the resulting 3D LUT (12 bit 3dl integer file) is:
3883 3960 4092

38839604092

This is the correct result for D65 in X´Y´Z´
and it is the same result as in the example conversion.

 

With this 3D LUT you are inside the Virtual white X´Y´Z´ gamut (DCI/SMPTE 431.2:2011 compliant).

To convert this 3D LUT to a floating point .Cube 3d LUT that is compatible with Photoshop, Resolve and After Effects I used opencolorio.
In terminal on a mac I use this command to convert the 3D LUT:

ociobakelut -lut srgbtoxyz.3dl -format iridas_itx -cubesize 65 srgbtoxyz.cube

to install opencolorio/ociobakelut I used these commands on a mac:

/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

brew doctor

brew install opencolorio

Download a 7z archive with the REC709/SRGB 3D LUTS files
It includes  2.2, 2.4, 2.6 CUBE and 3DL 3D LUTS (The cube 3d luts are in float)

Usage in Resolve (updated for Resolve 11)

The CUBE LUT can be placed in a folder you call Nuke or DCP inside Resolve´s LUT folder:
On a Mac: /Library/Application Support/Blackmagic Design/Davinci Resolve/LUT
On a PC: C:\ProgramData\Blackmagic Design\DaVinci Resolve\Support\LUT\

In Resolve you can apply it to the timeline from:
Project settings – Timeline Lookup tables – 3D Output Lookup table
or you can use a corrector node

You can render DCPs directly from Resolve with the Resolve Easydcp plugin. If you choose DCI X´Y´Z´ in the timeline color space no color transform will be applied and you can use the 3D luts to DCI X´Y´Z´ from this post.
See this post for more info.

Or export to another format and use it in Fraunhofer Easydcp .

Usage in After Effects
The resulting 3D LUT converted to .CUBE can be used in a non-linear 32 bit Adobe After Effects CC project
with the apply color LUT effect
when exporting 16 BIT TIFF or similar
or DCI jpeg2000 sequences with the Fnord DCI JPEG2000 encoder.

Usage in Easydcp
The 3DL 3D LUT can be applied in Easydcp.

In Easydcp Creator 2.2 you have the option to make custom color transformations. You can modify the 3×3 matrix, gamma, normalization constant/multiplication to suit your workflow. This is better than using 3D LUTs that has these color transformations baked in.
Read more about the custom color transformations in this post.

Example 2.

P3D65 to X´Y´Z´
The same example as I used in this post.
This 3D LUT can be used with Arri Alexa material that has the
C-log to P3 D65 3D LUT applied.
Link:Arri lut generator

 

Changed the color matrix node to:

The DCI-P3 D65 NPM from matlab after doing the RP-177 math:

0.486570948648216 0.265667693169093 0.198217285234362
0.228974564069749 0.691738521836506  0.0792869140937450
0                                               0.045113381858903   1.043944368900976

The NPM after copying and pasting into the Nuke colormatrix node:

0.48657095  0.26566769  0.19821729
0.22897457  0.69173852    0.07928691
0                             0.04511338    1.04394437

The middle row sums to 1
0.22897457+0.69173852+0.07928691 = 1

It is similar to the P3 D65 NPM from SMPTE EG 432-1-10

0.48657;0.26567;0.19822
0.22897;0.69174;0.07929
0.00000;0.04511;1.04394

Changed the gamma function node to 1/2,6=0.384615385 for P3
It becomes 0.384615 after pasting into Nuke.

Example P3 D65 to X´Y´Z´3D LUTS:

Download 7z archive with the P3 D65 3D LUTS files
It includes CUBE AND 3DL 3D LUTS (The cube 3DLUTS are in float):

Easydcp player 2.0 with support for variable quality settings, Supplemental packages, SMPTE subtitles and HD-SDI

New features in Easydcp player 2.0

Link: Easydcp player tutorials

Burn in subtitles when exporting.

Drag and drop

Playlists
You can make a playlist of films. You can save playlists. You can loop playlists.

Supplemental packages,
Most localized DCPs have the subtitles as supplemental packages that adds subtitles or sound to the original DCP,
these can be loaded together with the main DCP so you can play the DCP with subtitles and different sound.

Variable quality settings
You can move a Quality slider until you get a reasonable FPS playback level.
You can lower the quality of the playback without it being noticeable. Example: It will use 10 bit processing instead of 12 bit processing.
I tried this on a Quad core Mac Mini and I could play back different DCPs without lowering the quality slider much.

SMPTE subtitles
Easydcp player 2.0 now support SMPTE subtitles.

Customizable color transforms
You can edit the color transforms to fit your monitor/projector.

HD-SDI and HDMI out

The Ultrastudio 4K has 2K HD-SDI out

Playing the DCPs through HD-SDI can get you closer to the quality of HD-SDI digital cinema servers.

With HD-SDI you can output the DCP in the same frame rate as the DCP (like 24 or 25 FPS) and in 2K resolution.
If you connect the HD-SDI to a digital cinema projector you can send it a clean signal with subtitles, but without color transform and let the projector do the color transform.

Tests:

Quad core 2.6 Ghz Mac mini
I used a quad core Mac mini to play a DCP without color transform enabled (but with subtitles) through the HD-SDI (HD) output on the Ultrastudio mini monitor.
It worked with the quality slider almost at the top. This will vary with the source. Films with film grain are more difficult to decode than video films.
With both color transform and scaling to HD enabled you need a more powerful computer/graphic card.

The Blackmagic HD-SDI device should be used as the 5.1 sound card. I got 5.1 sound from the HD-SDI output, but only 2 channels from the HDMI output connected to a receiver.

To get 5.1/7.1 sound from SDI you can use a SDI to (AES 8 channels) audio de-embedder:

Blackmagic Design Mini Converter SDI to Audio 4K

With a sync test DCP you can adjust the sync with the +/- Sound Latency settings.

Computer with CUDA GPU JPEG2000 decoder
Resources: manual and the FAQ

You can use a PC with the CUDA JPEG 2000 decoder and a Decklink HD-SDI card.

To use the CUDA GPU JPEG2000 decoder you need an extra GPU, you can use a Geforce 570 card or better.

4K?
You can watch 4K through the graphics card, but you need a powerful computer to play 4K DCPs in 4K resolutions

link: Fraunhofer Test chart

The Decklink 4K and Ultrastudio 4K support 4K through HDMI or 3G HD-SDI, but Easydcp player only support 4K output through a video card.

Easydcp Creator 2.2 with customizable color transformations and support for ALEXA/P3 workflows

Easydcp Creator 2.2 has some new features:

Support for Closed Subtitles/Closed Captions and Open Captions

Extended Pillar-/Letterboxing

Feature to preview and burning the subtitles directly into the image content

New work-flow for activating the software within minutes


link:Fraunhofer online tutorials

Extended Pillar-/Letterboxing
All the reels need to be the same resolution in a DCP. if you have a logo in HD and the film in Flat, you can choose to enable Flat pillar-boxing on the Logo.

You can choose between full container, automatic, flat or scope.

Automatic
This setting add pillar-boxing and letterboxing automatically.

You can add the original aspect ratio in the name of the DCP Digital naming convention. Example: 16/9 = F-178 or 4/3 = F-133

Most cinemas only have Flat or Scope settings for side masking, but for those cinemas that have manual side masking they can set them correctly.

Full container
If you know a cinema has a full container preset on their projector you can make a DCP with a mix of scope and flat films without scaling with this setting.

Flat
Useful when fitting scope material inside a flat DCP. Useful when making Trailers in both scope and flat format.
Also useful when combining scope and flat films inside a flat DCP.

Scope.
Does not fit flat inside scope, it crops letter-boxed sources to fit inside the scope container. This is useful when using XML subtitles that are shown 10 percent from the bottom of the container.

Burning in subtitles.
You can burn in the subtitles.
You can also see a preview of the subtitles in the preview window.
25 FPS DCPs with burned in subtitles are compatible with some old digital cinema servers.
If you are making both 25 and 24 fps versions, you can first make the 25 fps version and then use the same file in the 24 fps version.

Drag and drop
You can drag mxf files and DCPs to the asset list.

Audio silence:
You can mark audio channels with a silence button instead of using blank audio files.

Other new features

Customizable XML color transformation files
You can choose your own color transformation using custom 3×3 matrix transformation and custom gamma values.

There are two transformation XML files included:
BT.709 with 2.2 gamma
P3 DCI 2.6 gamma.

Change gamma in the rec709 transformation
You can copy the rec.709 transformation to a new file and change the gamma function value in the XML file to suit your workflow.

Here are some examples of gamma function values:

1/2,2=0,45 (simplified 2.2 gamma)
SRGB monitor gamma and commonly used on HDTV monitors.

1/2.4=0.416666666
2.4 is the recommended gamma for HDTV monitors in the new ITU-R BT-1886 recommendations Link:ITU-R BT-1886

1/2,6=0.384615385
The same gamma as DCPs.

Can video display or “emissive” monitors be used for Digital Cinema mastering? Pines touched on the Stevens effect (that perceived contrast decreases at lower luminance), Hunt effect (that perceived colorfulness also decreases at lower luminance) and display flare characteristics. “The same content has to look good in a normal surround (office), dim surround (living room) and dark surround (theatrical),” said Pines.

Reference Monitor Symposium

Example
You want to use rec.709 2.6 gamma. You use a gamma function value of 0.384615385.

Changing the normalization constant multiplication
To move away from the edge of the color space you can lower the number of the white projector luminance

You can change the P3 DCI 2.6 gamma transformation to P3 D65 and P3 D55 by changing the 3×3 matrix
There are P3 D65, P3 D55 and other NPM 3×3 matrix examples in SMPTE EG 432-1-10.

Example
You want to convert a 16 tiff RGB sequence from Resolve that has a
C-log to P3 D65 3D LUT or
C-log to P3 DCI WHITE 3D LUT
applied.
Link:Arri lut generator

To convert it you use the standard Easydcp P3 DCI WHITE XML transformation

or make a custom P3 D65 transformation

with this NPM from this post

0.48657095  0.26566769  0.19821729
0.22897457   0.69173852    0.07928691
0                           0.04511338    1.04394437

More info

With the P3 D65 workflow you can:

-First use the C-Log to Rec709 3D LUT on a rec709 monitor (D65)

-move to a P3 2.6 gamma D65 projector and and view it using the C-Log to P3 D65 3D lut.

-Then make the DCP in Easydcp with the custom P3 D65 transformation.

 

White point targets white values:

REC 709 D65 projector White = 4095,4095,4095 at 14 fL
In DCDCM X’Y’Z’ D65 is 3883, 3960, 4092 at 14 fL

P3 D65 projector White = 4095,4095,4095 at 14 fL
In DCDCM X’Y’Z’ D65 is 3883, 3960, 4092 at 14 fL

P3 DCI WHITE projector=White 4095,4095,4095 at 14 fl
In DCDCM X’Y’Z’ DCI WHITE is 3794, 3960, 3890 at 14 fL

You can adjust the normalizing constant variable to be within these targets.

Notes:
The white in the film you are making do not have to be D65 or DCI WHITE, you can use any creative white you want to.

The P3 primaries are wide-gamut relative to desktop standards; pure sRGB red is relatively desaturated with a distinctly orange-red hue, while pure P3 red is blood red, almost on the spectral locus. The DCI white point is not necessarily the creative white point used in mastering. Productions are free to master to any white point they prefer, provided all mastered colors falls within the allowed DCI gamut. Indeed, for artistic considerations the (0.314, 0.351) white point is often avoided due to its greenish cast relative to the daylight curve.

– Visual Effects Society: White paper: Cinematic Color: From Your Monitor to the Big Screen

DCDCM X’Y’Z can have D65, D55 and DCI WHITE white points at 14 fL. Source: SMPTE RP 431-2:2011

The Disney test image DCP that is shown in the background of this picture from this post has DCI WHITE in the middle and D55 and D65 white squares: All of these are at 14 fL.

You can also calculate NPM 3×3 matrixes yourself by applying the math in SMPTE RP 177 / SMPTE EG 432-1-10 to the primaries and reference white point of the mastering projector native color space. (See this post)

P3 with other white points than D65, D55 and DCI White could make the DCP go out of gamut. Larger color spaces than P3 will not fit and need to have some gamut mapping. SMPTE EG 432-1-10 has more info the math used.


These color transformation can also be saved as 3D LUTs in Nuke and applied in Resolve, After Effects and Fraunhofer Easydcp.
See this post for more info.