summaryrefslogtreecommitdiff
path: root/docs/userguide/baking_luts.rst
blob: 7085bf58a7ec40cc1a235fdd03d9699b1b9011d0 (plain)
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
.. _userguide-bakelut:

Baking LUT's
============

Sometimes it is necessary to write a color transform as a
lookup-table file

This is usually because an application does not natively support OCIO
(unlike, say, Nuke which various OCIO nodes), but can load a LUT of
some kind. This would currently include applications like Autodesk
Flame, Adobe Photoshop, SideFX's MPlay (Houdini's "Image Viewer")

Remember that baking a LUT is not a perfect solution. Different LUT
formats have various limitations. Certain applications might apply
LUT's differently (often incorrectly), and some formats simply cannot
accurately represent certain transforms. Others might require
carefully selecting shaper spaces and so on.

Be sure to carefully test the generated LUT in the target
application. Burning the LUT into a test image (such as Marcie!), and
carefully comparing to a reference is often the only way to be sure a
LUT is correct.

Config-based baking
*******************

This section assumes you have a working OCIO config.

The config can either be specified by setting the OCIO environment variable::

    bash$ export OCIO=~/path/to/spi-vfx/config.ocio

Alternatively the config can be specified as a command-line argument
to the ociobakelut command, ``--iconfig ~/path/to/spi-vfx/config.ocio``

These examples will use the :ref:`config-spivfx` config, specifically the
following colorspaces

* ``lnf`` - scene-referred linear light colorspace (reference colorspace)
* ``lg10`` - film log colorspace (0-1 colorspace)
* ``srgb8`` - sRGB display colorspace

Remember these are just for the examples - you can of course use any
config and any colorspaces

Log-input display LUT
+++++++++++++++++++++

Say we have a ``lg10`` image in MPlay (maybe a ".cin" film scan), and
wish to view it in our main display colorspace, ``srgb8``

The available formats are listed in the ``ociobakelut --help`` - for
MPlay, we use the "houdini" format (see :ref:`the FAQ<faq-supportedlut>`
for a more detailed list)

So, to create a LUT that transforms from ``lg10`` to ``srgb8``::

    bash$ ociobakelut --format houdini --inputspace lg10 --outputspace srgb8 log_to_display.lut

We could then load this LUT into MPlay and view a lg10 image
correctly! (note that by MPlay tries to linearise ".cin" files by
default, which can be disabled in the preferences, "Convert form 10bit
Log")

For most other applications, we could simply change the ``--format``

Shaper spaces
+++++++++++++

Before we create a LUT to view linear-light images, it's important to
understand shaper-spaces and preluts.

The two main types of LUT's are 1D and 3D. Such LUT formats typically
require input values in the 0.0-1.0 range. Such a LUT would be
unsuitable for linear-light values input images (where values are
often over 1)

To address this, various LUT formats contain a smaller "prelut" (or
"shaper LUT") which is applied before the main LUT. This is used to
transform the input values into a 0-1 range (typically a linear-to-log
type transform)

In terms of color-transforms, the prelut transforms from
"input-space" to "shaper-space", then the main LUT transforms from
"shaper-space" to "output-space"

Some formats do not support such a shaper LUT - these are typically
used in applications which do not work with floating-point images (e.g
Lustre often works with 10-bit integer DPX's, so it's natively
supported "--format lustre" (3DL) format has no need for a prelut)


Linear-light input display LUT
++++++++++++++++++++++++++++++

With shaper-spaces explained, lets say we have a ``lnf`` linear light
image in MPlay, and wish to view it in the ``srgb8`` colorspace.

To create this LUT accurately, without clipping, we will use the LUT's
prelut to transform from ``lnf`` to ``lg10``, then the 3D LUT will
transform from ``lg10`` to ``srgb8``

Sounds complicated, but the command is almost the same as before, just
with the ``--shaperspace`` argument (and ``--inputspace`` changed, of
course)::

    bash$ ociobakelut --format houdini --inputspace lnf --shaperspace lg10 --outputspace srgb8 lin_to_display.lut

Allocation-based prelut
+++++++++++++++++++++++

If your :ref:`allocation variables<allocationvars>` are setup
correctly, you can omit the ``--shaperspace`` argument, and a prelut
will be automatically created based on the allocation vars (see the
linked page for more information)

Since the colorspaces in the config we are using (:ref:`config-spivfx`) have
their allocation variables set correctly, we could simplify the
``lnf`` to ``srgb8`` bake command::

    bash$ ociobakelut --format houdini --inputspace lnf --outputspace srgb8 lin_to_display_allocbased.lut

This command creates a very different prelut to the explicitly
specified ``--shaperspace lg10`` in the previous example. Explicitly
specifying a shaper can produce better results, however the
allocation-based prelut usually works nicely, and is convinient

Note that allocation-var based preluts is baker-format dependant, and
not all formats currently implement them


Config-free baking
******************

You can perform baking without using a OCIO config. This means you
don't have to create a temporary config just to, say, convert from one
LUT format to another.

Converting between formats
++++++++++++++++++++++++++

Say we have a houdini LUT named ``log_to_display.lut``. To convert
this to a Flame compatible 3dl file, simply run::

    ociobakelut --format flame --lut log_to_display.lut for_flame.3dl


Reversing a 1D LUT
++++++++++++++++++

You can apply a LUT in reverse, and write this to a new LUT (this does
not work for 3D LUT's, but will for 1D LUT's)::

    bash$ ociobakelut --format flame --invlut logtosrgb.3dl srgbtolog.3dl

Creating a grade LUT
++++++++++++++++++++

You can create a LUT which applies CDL-compliant grades::

    ociobakelut --format cinespace --slope 1.2 1.0 0.9 mygrade.csp

Combining options
+++++++++++++++++

These options can be used together, or used multiple times.

For example, to perform a slope offset, then apply "mylut.csp", saving
it out for Lustre::

    bash$ ociobakelut --format lustre --slope 2.0 1.5 0.4 --lut mylut.csp output.3dl


ICC profiles (Photoshop)
************************

Photoshop is very focused around print and graphic-design, industries
with very different color management concerns to modern feature-film
VFX. As such, it can be a pain to integrate.

The main issue is current versions of Photoshop (CS5) are only
practical for working with 16-bit integer images (not floating
point/linear-light images as is common in compositing software)

The second issue is there is no simple way to load a simple 1D or 3D
LUT into Photoshop (and it's API does not make this easy either!)

A working space
+++++++++++++++

First, we need to decide on a colorspace to use for the images in
Photoshop. This is the colorspace in which matte-paintings will be
performed (likely a different colorspace that used for
texture-painting, as these have different requirements)

The working space should be a "0-1 colorspace", reversable, and for
matte-paintings ideally allow painting values over "diffuse white" (in
other words, to paint values over 1.0 when converted to linear-light
in comp)

This is a facility-dependant workflow choice.

For this example we will use the ``vd16`` colorspace, as described by
the :ref:`config-spivfx`

Creating display LUT
++++++++++++++++++++

"Proofing profiles" in Photoshop can be used in a very similar way to
a display LUT in applications like Nuke. This proof-profile can be
used to apply a 3D color transform from the working-space to a
display space (e.g transform from ``vd16`` to ``srgb8`` in the spi-vfx
config)

These proofing-profiles are ICC profiles - a rather print-specific
technology and relatively complex format 

Luckily, ``ociobakelut`` can be used to create these... but, first,
there are some important considerations:

It is important to match the ``--displayicc`` option to the profile
used for the display.

Secondly, Photoshop has a lot of print-focused color-management
options, some of which can cause problems.

Determine display ICC
+++++++++++++++++++++

On OS X, launch "System Preferences", open "Displays" and click
"Color" tab. The currently active ICC profile is selected.

If you just want something simple that "probably matches" a Linux
machine, say, it is easiest to uncheck "Show profiles for this display
only" and select the "sRGB IEC61966-2.1" profile. You can skip the
rest of this section in this case.

.. figure::  images/ps_icc/psicc_open_current_profile.png
    :align:   center

However, if you have a specific display-profile selected (maybe
created by monitor-calibration software), you should do the following:

Click "Open Profile", and right-click the icon in the top of the window, and click the folder:

.. figure::  images/ps_icc/psicc_reveal_profile.png
    :align:   center

This reveals the current profile in Finder. You can drag the file onto
a Terminal.app window to get the full path (or, type it manually)

.. TODO: Is there a standard way to find this on Windows?

Create the ICC profile
++++++++++++++++++++++

Almost done now. We can write the ICC profile!

The full command is, using our example colorspaces of ``vd16`` and ``srgb8``::

    bash$ ociobakelut --format icc --inputspace vd16 --outputspace srgb8 --displayicc /path/to/my/monitorprofile.icc --description "vd16 to srgb8"


The first three options are the same as any other LUT::

    bash$ ociobakelut --format icc --inputspace vd16 --outputspace srgb8 [...]

Then we specify the display ICC profile::

    [...] --displayicc /path/to/my/monitorprofile.icc [...]

We can set the description (shown in Photoshop), and as the last argument, specify::

    [...] --description "vd16 to srgb8"  [...]

Finally an argument for the output file:

    [...] vd16_to_srgb.icc


If you selected the "sRGB IEC61966-2.1" display profile, you can omit
the ``--displayicc`` argument (it defaults to an standard sRGB
profile)::

    bash$ ociobakelut --format icc --inputspace vd16 --outputspace srgb8 --description "vd16 to srgb8"

Loading the "display LUT"
+++++++++++++++++++++++++

Last step is to load the ICC profile into Photoshop, and enable it.

On OS X, these can be put into::

    /Library/ColorSync/Profiles/

(or the equivelant directory in your home-directory)

On Windows, right-click the profile and select "Install profile"


Then on either platform, click "View > Proof Setup > Custom..."

.. figure::  images/ps_icc/psicc_proof_setup.png
    :align:   center

Select your profile from the "Device to simulate" dropdown (the name
is what you supplied with ``--description``):

.. figure::  images/ps_icc/psicc_select_profile.png
    :align:   center

As pictured, selecting "Preserve RGB numbers", and deselecting
"Simulate Black Ink" is a good starting point (see the next section on
"Other color settings")

Finally, you can load an image in your working space, and click "View
> Proof Colors", or hit cmd+y (or ctrl+y)

When active, the profile name is shown in the window title (e.g
".... (RGB/16#/vd16 to srgb8", where the part after the "#/" is the
profile name, "RGB/16" indicates the current image mode)

Other color settings
+++++++++++++++++++++

(note this guide is based on Photoshop CS5, and written while checking
the OS X version, although most of these apply similarly on Windows 7)

It is usually possible to get a matte-painting to look identical in
Photoshop as it does in a more VFX-friendly application such as Nuke.

However, as mentioned Photoshop has a lot of color-management related
options, many of which can impair the match between it and other
applications. The operating system also has some controls (as seen
before with the ColorSync display profile)

The settings that require tweaking have a tendency to change with OS
versions, Photoshop versions and the phase of the moon. The only way
to be sure is to compare Photoshop side-by-side with a
LUT-reference-image (ideally toggling between Photoshop and Nuke):

.. figure::  images/ps_icc/psicc_itworks.png
    :align:   center


The most improtant settings are in the "View > Proof Setup > Custom
..." menu.

The recommended "Preserve RGB" setting works sometimes. Other times
disabling "Preserve RGB Numbers" and selecting "Rendering Intent:
Relative Colorimetric" can be closer.

It is safest to not assign a profile to the images you are working
on - this is done by clicking "Edit > Assign Profile", and selecting
"Don't Color Manage This Document".

In closing, of course none of this matters if you don't have a
calibrated monitor!