hdr: per-document Clip vs Highlight-rolloff output mode (Stage A pt 2)
Add a per-document HDR→SDR mapping applied at the final linear→sRGB encode, so
super-white (HDR) video highlights can be recovered instead of hard-clipped:
- core: HdrOutputMode {Clip (default), HighlightRolloff} on Document (serde
default), with a SetDocumentPropertiesAction variant for undoable edits.
- shaders: a fs_main_rolloff entry point (preview linear_to_srgb.wgsl + the export
inline shader) applying a C1 highlight knee — identity below 0.8, smooth rolloff
[0.8,∞)→[0.8,1). SDR below the knee is untouched; Clip stays the historical path.
- preview (stage.rs) and both export encodes (video_exporter.rs) pick the pipeline
variant from document.hdr_output_mode — one value per frame, so no per-pixel
uniform; mirrors the existing fs_main_straight pattern.
- UI: an "HDR output" dropdown in the Document section of the info panel.
Default (Clip) is bit-identical to previous behaviour. Completes Stage A:
HDR-correct input (pt 1) + SDR-safe output mapping. HDR export (10-bit P010/PQ)
and HDR display remain Stages B/C.
This commit is contained in:
@@ -980,10 +980,10 @@ impl InfopanelPane {
|
||||
|
||||
// Extract all needed values up front, then drop the borrow before closures
|
||||
// that need mutable access to shared or self.
|
||||
let (mut width, mut height, mut duration, mut framerate, layer_count, background_color) = {
|
||||
let (mut width, mut height, mut duration, mut framerate, layer_count, background_color, mut hdr_mode) = {
|
||||
let document = shared.action_executor.document();
|
||||
(document.width, document.height, document.duration, document.framerate,
|
||||
document.root.children.len(), document.background_color)
|
||||
document.root.children.len(), document.background_color, document.hdr_output_mode)
|
||||
};
|
||||
|
||||
// Canvas width
|
||||
@@ -1087,6 +1087,23 @@ impl InfopanelPane {
|
||||
}
|
||||
});
|
||||
|
||||
// HDR output mode (how super-white video highlights map to SDR output)
|
||||
ui.horizontal(|ui| {
|
||||
use lightningbeam_core::document::HdrOutputMode;
|
||||
ui.label("HDR output:");
|
||||
egui::ComboBox::from_id_salt(("hdr_output_mode", path))
|
||||
.selected_text(hdr_mode.name())
|
||||
.show_ui(ui, |ui| {
|
||||
let mut changed = false;
|
||||
changed |= ui.selectable_value(&mut hdr_mode, HdrOutputMode::Clip, HdrOutputMode::Clip.name()).changed();
|
||||
changed |= ui.selectable_value(&mut hdr_mode, HdrOutputMode::HighlightRolloff, HdrOutputMode::HighlightRolloff.name()).changed();
|
||||
if changed {
|
||||
let action = SetDocumentPropertiesAction::set_hdr_output_mode(hdr_mode);
|
||||
shared.pending_actions.push(Box::new(action));
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Layer count (read-only)
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Layers:");
|
||||
|
||||
Reference in New Issue
Block a user