antialiasing/compositing in linear light?

Bill Spitzak spitzak at gmail.com
Wed Dec 27 07:23:22 UTC 2023


You can store in 8 bits and still convert to/from linear values when
computing compositing. Squaring the number is likely close enough and can
simplify the math. Also GPUs have built-in instructions to convert between
8 bits and floating point as sRGB.



On Mon, Dec 25, 2023 at 11:25 PM Bandi-T <bandit at surfnonstop.com> wrote:

> Greetings,
>
> Is Cairo antialiasing/compositing in linear light?
>
> I am drawing graphs into onto on-screen areas using Cairo/GTK4
> (Gtk::DrawingArea)/Win10, and the edges of my slanted
> (non-vertical/horizontal) lines (straight line segments) look jagged...
> like they might not have been antialiased in linear light, but in
> gamma-space.
>
> If my observation is correct, I am proposing enhancing Cairo to be able
> to perform anti-aliasing/compositing in linear light.
>
> This would switch internal pixel representation to linear light (float
> or at least 12-13 bits/component – so practically uint16), and then only
> upon a snapshotting (outputting the result) would it generate a 8 bit
> sRGB representation for legacy environments that still expect sRGB, or
> pass through the 16 bit linear representation for more modern
> environments (e.g. GPU textures).
>
> Please see this article with visual demonstrations and discussion about
> the potential improvements:
> https://pixls.us/articles/users-guide-to-high-bit-depth-gimp-2-9-2-part-2/
>
> Conceptually, this would
>
> * convert all incoming legacy color (= color specified in gamma-encoded
> spaces, e.g. sRGB – be it from image pixels, or user-speficied pen/fill
> colors, etc.) into linear light
>
> * internally, always work (draw/paint/antialias/composite) in linear light
>
> * when a gamma-encoded output is needed, render a gamma-encoded snapshot
> of the result
>
> For sRGB (which I assume is going to be the most common case) the needed
> maths is elaborated in the Wikipedia article of sRGB.
>
> Because this needs extra buffering, plus implies non-zero computational
> cost, it would be behind a higher quality antialias flag, so that users
> who don't care would not pay the extra computational costs. (However my
> hope is that the cost on modern hardware versus the quality improvement
> would eventually make this the default mode.)
>
> This is orthogonal to whole-pixel versus sub-pixel antialiasing, so both
> of those modes could/would/should benefit from it.
>
> How viable is this proposal? (For example I am only considering the case
> where Cairo is rendering into a pixel-based memory buffer that
> eventually gets copied on-screen, and am unaware of what this might mean
> for other scenarios.)
>
> Thank you in advance.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20231226/66d97d8a/attachment.htm>


More information about the cairo mailing list