Skip to content

Commit a4bc5c1

Browse files
committed
[css-color-hdr] Added interpolation algorithm, #11616
1 parent 076f53a commit a4bc5c1

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

css-color-hdr-1/Overview.bs

+14-5
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ Mixing Dynamic Range Limits: the ''dynamic-range-limit-mix()'' function {#dynami
464464
each with an associated level of HDR headroom.
465465
The actual value is computed by interpolating between these two colors,
466466
based on the current amount of HDR headroom,
467-
as described in [#headroom-interpolation].
467+
as described in [[#headroom-interpolation]].
468468

469469
<div class="informative">
470470
This is a similar mechanism to gain maps,
@@ -478,7 +478,7 @@ Mixing Dynamic Range Limits: the ''dynamic-range-limit-mix()'' function {#dynami
478478
Its syntax is as follows:
479479

480480
<pre class='prod'>
481-
<dfn>hdr-color()</dfn> = color-hdr([ <<color>> && <<number [1,infinity]>>? ]#{2})
481+
<dfn>hdr-color()</dfn> = color-hdr([ <<color>> && <<number [0,infinity]>>? ]#{2})
482482
</pre>
483483

484484
<div class="example" id="ex-hdr-color-simple">
@@ -507,14 +507,23 @@ Mixing Dynamic Range Limits: the ''dynamic-range-limit-mix()'' function {#dynami
507507

508508
</div>
509509

510-
<h3 id="#headroom-interpolation">
510+
<h3 id="headroom-interpolation">
511511
Interpolating colors based on headroom
512512
</h3>
513513

514514
To interpolate between a color <var>c1</var> at headroom <var>H1</var>
515-
and a color <var>c2</var> at headroom <var>H2</var>
515+
and a color <var>c2</var> at headroom <var>H2</var>,
516+
giving result color <var>cxyz</var>,
516517
when the target headroom is <var>H</var>:
517-
518+
519+
1. Let <var>c1xyz</var> be <var>c1</var> converted to D65 CIE XYZ
520+
2. Let <var>c2xyz</var> be <var>c2</var> converted to D65 CIE XYZ
521+
3. Let <var> w1</var> = clamp((log(<var>H</var>) - log(<var>H2</var>)) / (log(<var>H1</var>) - log(<var>H2</var>)), 0, 1)
522+
4. Let <var> w2</var> = clamp((log(<var>H</var>) - log(<var>H1</var>)) / (log(<var>H2</var>) - log(<var>H1</var>)), 0, 1)
523+
Note that <var> w2</var> = 1 - <var> w1</var>
524+
5. Let <var>eps</var> = 0.001 (one JND in linear-light space)
525+
6. Let <var>cxyz</var> = pow(<var>c1xyz</var> + <var>eps</var>, <var>w1</var>) * pow(<var>c2xyz</var> + <var>eps</var>, <var>w2</var>) - <var>eps</var>
526+
518527

519528
<h2 id="color-function">
520529
Specifying Predefined and Custom Color Spaces: the ''color()'' Function

0 commit comments

Comments
 (0)