Skip to content

Commit

Permalink
[css-color-hdr] Handle negative component values in HLG function
Browse files Browse the repository at this point in the history
  • Loading branch information
svgeesus committed Oct 24, 2024
1 parent 8745dbb commit bedf32e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions css-color-hdr/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,11 @@ Predefined color spaces for HDR: {#predefined-HDR}
const a = 0.17883277;
const b = 0.28466892; // 1 - (4 * a)
const c = 0.55991073; // 0.5 - a * Math.log(4 *a)
if (E <= 1/12) {
Edash = Math.sqrt( 3 * E);
// handle negative values
var sign = E < 0? -1 : 1;
var abs = Math.abs(E);
if (abs <= 1/12) {
Edash = sign * Math.sqrt( 3 * abs);
}
else {
Edash = a * Math.log(12 * E - b) + c;
Expand Down

0 comments on commit bedf32e

Please sign in to comment.