HDR Encode
Scene-linear in, a signal your TV will actually read
- image
- encoded_image
You've got a scene-linear image with real values above 1.0 and you want to put it on a screen that can show them. That's not a saturation slider, it's a delivery standard, and there are two of them: PQ (HDR10 / Dolby Vision) and HLG (broadcast). HDR Encode turns scene-linear HDR into a valid signal for either - the step that turns "I have HDR data" into "I have an HDR file."
You reach for this late in the graph, after grading, once you've decided the mastering peak. It's the last creative decision before the file leaves your machine, and it's one of the pack's output nodes, so ComfyUI will run it whether or not something consumes the result.
How it works
PQ (ST.2084) is an absolute encoding: the signal means a specific luminance, so the node simply encodes your scene-linear values against reference_white_nits (203 by default - the BT.2408 anchor for diffuse white) and clips at peak_nits. Because it's absolute, the mastering peak you choose is baked into how the file reads.
HLG is scene-referred and relative: the node does a BT.2100 transcode for a 1000-nit display, with reference white landing at 75% signal. scene_linear_gain scales the scene-linear data before encoding, which is effectively your exposure trim on the way out.
Then there's primaries. apply_bt2020 converts BT.709 primaries to BT.2020 - and the tooltip is blunt that this is required for standards-compliant HDR10/HLG delivery when your source is BT.709. If your source is already BT.2020, turn it off. Negatives get clipped either way.
Inputs and outputs
Required: image (scene-linear, 1.0 = reference white, with primaries either BT.709-with-the-toggle-on or already BT.2020), and format - PQ (HDR10) or HLG (Broadcast).
Optional: peak_nits with four choices - 100, 1000, 4000, 10000 - where 1000 is standard HDR10 and 4000/10000 are Dolby Vision territories. reference_white_nits (203), scene_linear_gain (HLG only), and apply_bt2020 (off by default, which surprises people given it's on the compliance checklist).
One output: encoded_image. Feed it to a Write node - the plain image writers will happily save this as an SDR-looking PNG unless you're writing something that carries the encoding, which is where the pack's EXR/video write path comes in.
Install
Manager → search Radiance → Install → restart → refresh your browser.
cd ComfyUI/custom_nodes
git clone https://github.com/fxtd-studios/radiance.git
cd radiance
python -m pip install -r requirements.txt
Windows portable users: python_embeded\python.exe for the pip step. No models needed.
Where people get burned
Two really common ones.
First, apply_bt2020 defaults to False. If you feed Rec.709-primaried scene-linear data and leave it alone, you get a technically-encoded file with the wrong gamut - it'll look oversaturated in some players and under-saturated in others, and you'll blame the encode. Turn it on unless your source genuinely is BT.2020, and don't turn it on twice by feeding ACEScg without converting first.
Second, peak_nits is not a brightness control. It's the mastering display peak, and PQ is absolute - mismatch it against what your content actually reaches and you either waste headroom or clip. That's exactly what HDR Analysis and HDR Diagnostics are for: measure the peak first, then pick.
And the pack-wide one: this node outputs a tensor, so nothing downstream magically becomes an HDR file. The container has to carry the metadata, or you've made a very precise SDR-looking image.
Inputs (6)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | Scene-linear HDR, 1.0 = reference white (203 nits by default). Primaries are either BT.709 (turn apply_bt2020 on) or already BT.2020 (leave it off). Negatives are clipped. | |
| format | COMBO | PQ (HDR10) | PQ: absolute ST.2084 signal clipped at peak_nits. HLG: BT.2100 transcode for a 1000-nit display, reference white at 75% signal. |
| peak_nitsopt | COMBO | 1000 | [PQ] Mastering display peak luminance. 1000 = HDR10, 4000/10000 = Dolby Vision grade. |
| reference_white_nitsopt | FLOAT | 20380–400 | [PQ / HLG] Nits where linear 1.0 (diffuse white) maps. BT.2408 recommends 203; HLG then puts 1.0 at 75 % signal. |
| scene_linear_gainopt | FLOAT | 1.00.1–8 | [HLG] Scale scene-linear before encoding. Useful for exposure trim. |
| apply_bt2020opt | BOOLEAN | false | Convert BT.709 primaries to BT.2020. Required for standards-compliant HDR10 / HLG delivery. Disable if source is already BT.2020. |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| encoded_image | IMAGE | — |