Skip to content

Commit

Permalink
refacto(primaries_inset): better README, add demo video
Browse files Browse the repository at this point in the history
  • Loading branch information
MrLixm committed Nov 14, 2023
1 parent a5eece2 commit 338a7e1
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 37 deletions.
104 changes: 67 additions & 37 deletions src/primaries_inset/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,24 @@ a 3x3 matrix. It is possible to visuallize the gamut transformation in a
CIE xy graph plot.

The reshape transformation is called an "inset" as we are creating a smaller
gamut than the original.
gamut than the original (but note we actually apply the inverse conversion making
the source gamut smaller than the new gamut).

This is the main concept behind [the AgX DRT](https://github.com/MrLixm/AgXc) which
This is the main concept behind [the AgX DRT](https://github.com/sobotka/AgX) ([ personal fork](https://github.com/MrLixm/AgXc)) which
was also [ported to darktable](https://github.com/darktable-org/darktable/pull/15104).

![nuke screenshot with PrimariesInset enable](doc/img/demo-inset-on.png)
![demo recording of the node utilisation in Nuke](doc/img/demo.mp4)

And disabled :
| enabled | disabled |
|--------------------------------------------------------------------------|-----------------------------------------------------------------------------|
| ![nuke screenshot with PrimariesInset enable](doc/img/demo-inset-on.png) | ![nuke screenshot with PrimariesInset disabled](doc/img/demo-inset-off.png) |

![nuke screenshot with PrimariesInset disabled](doc/img/demo-inset-off.png)

The above example is in the context of a traditional ACES workflow (note the
> The above example is in the context of a traditional ACES workflow (note the
ACES view-transform in the viewer) but could be used with any other "tonemapping".

The PrimaryInset operation works closely with the application of a 1D tonescale curve
(usually reffered as tonemapping) after itself.

If you find the effect of the Inset too strong and just woudl like to fix those
very saturated camera artefact it's possible to apply an outset after the inset :

![nuke screenshot of the outset workflow](doc/img/demo-outset.png)

Unfortunately the workflow require to bake the view transform in the chain
(OCIO Display node) :
1. apply ACES view-transform
2. revert the sRGB EOTF conversion to get back ACEScg value
3. duplicate the first `PrimaryInset` node but check the `Invert` option
4. reapply the sRGB EOTF conversion

## plotting

It is possible to preview the new inset colorspace as a plot in the CIE1931 xy space.

Just check the `show` checkbox next to the `Plot` title.

![nuke gif of the plot being edited interactively](doc/img/demo-plot.gif)
The PrimaryInset operation works bests with the application of a 1D tonescale curve
(usually reffered as tonemapping) after itself thanks to the increase of complimentary
in the RGB values, which help achieve crosstalk during per-channel (produced by the tonescale).

# Instructions

Expand All @@ -50,14 +32,17 @@ Just check the `show` checkbox next to the `Plot` title.
scene.
- That's it

System :
- PrimariesInset uses:
- python code for `Presets` but works on non-commercial versions.
- blink script but works on non-commercial versions >= 14.0
- The python code _should_ be python 2 compatible but has only been tested on latest
## Requirements

The tool use the following features :

- python code for `Presets` but works on non-commercial versions.
- The python code _should_ be python 2 compatible but has only been tested on latest
python3 versions of Nuke.
- blink script but works on non-commercial versions >= 14.0


## Usage
## Basic-Usage

- Expect an image to be transformed as input.
- Select the preset corresponding to the input image's colorspace encoding.
Expand All @@ -68,10 +53,55 @@ in the _Plot_ section : your image disapear to leave a dark squared canvas with
only a gamut visible.
- Keep playing with the _Options_ to see how it works.

### default values

Here is some default values that are recommended when using `BT.2020` as source
gamut. They are based on the [darktable implementation](https://github.com/darktable-org/darktable/pull/15104)
and Troy Sobotka work.

- inset: `0.15 - 0.25`
- inset R: `0.06` : additional decrease of purity for red that can be still quite srong
- inset B: `0.15` : additional decrease of purity for blue that tend to look deeper
- rotate R: `5` : shift reds in favor of yellowness which work better for fire and sunsets.
- rotate B: `-6` : sift blues to compensate for Abney effect

## Outset-workflow

If you find the effect of the inset too strong you can apply an outset after the
tonescale has been applied to restore purity but preserve the "whiteness" in highlights:

![nuke screenshot of the outset workflow](doc/img/demo-outset.png)

Unfortunately the workflow is complicated because you need to apply the tonescale
before applying the outset. And the tonescale is usually part of the output-transform.

In the case of an ACES workflow :

1. apply `PrimaryInset` node as usual
2. apply ACES view-transform (OCIO Display node)
3. revert the sRGB EOTF conversion to get back ACEScg value
4. duplicate the first `PrimaryInset` node from step 1. but check the `Invert` option
5. reapply the sRGB EOTF conversion for display.
6. make sure the viewer view-transform is set to raw or similar.

## Plotting

It is possible to preview the new inset colorspace as a plot in the CIE1931 xy space
(note this is not a perceptual space).

Just check the `show` checkbox next to the `Plot` title.

![nuke gif of the plot being edited interactively](doc/img/demo-plot.gif)

While plotting you can check `Invert Inset` to see the actual destination colorspace
being used for the math conversion (kind of unintuitive yes).

# Developer

See the [./src/](./src) folder for the original files that create the final node.
See the [./src/](./src) folder for development instructions.

## TODO

- [ ] fix NO_HANDLE flag issue that doesn't seems to work
- [ ] fix NO_HANDLE flag that is not preserved between sessions (woudl require `onCreate` callback)
- [ ] add grid to plot
- [ ] draw gamuts boundaries with lines
Binary file added src/primaries_inset/doc/img/demo.mp4
Binary file not shown.

0 comments on commit 338a7e1

Please sign in to comment.