2023-04-25 02:12:55 +00:00
|
|
|
### Copyright
|
|
|
|
Copyright (C) 2023 Allen Webster <https://mr4th.com>
|
|
|
|
|
|
|
|
Distributed with GPL 3 license (full license in LICENSE-GPL-3.txt)
|
|
|
|
|
|
|
|
### Contact
|
|
|
|
allenw@mr4th.com
|
|
|
|
|
|
|
|
### Purpose
|
|
|
|
This is a standalone Win32 OpenGL application that works as a set of
|
|
|
|
experiments to demonstrate the behavior and effect of SRGB conversions
|
|
|
|
and antialiasing techniques
|
|
|
|
|
|
|
|
In the final output program, the left side shows the gamma-naive results
|
|
|
|
where no SRGB conversions are applied to input colors or to output colors.
|
|
|
|
The right side shows the gamma-aware results where input colors are converted
|
|
|
|
from SRGB to Linear RGB, and output colors are converted from Linear RGB to
|
|
|
|
SRGB.
|
|
|
|
|
|
|
|
From top to bottom the experiments are:
|
|
|
|
|
|
|
|
1. A gradient which goes white (1,1,1) to black (0,0,0)
|
|
|
|
interpolated linearly by
|
|
|
|
alpha = (x - left)/(right - left)
|
|
|
|
color = (1,1,1)*(1 - alpha) + (0,0,0)*(alpha)
|
2023-04-29 03:00:33 +00:00
|
|
|
|
|
|
|
2. Pulls out three colors into solid color blocks:
|
|
|
|
(0,0,0), (0.5,0.5,0.5), and (1,1,1)
|
|
|
|
|
|
|
|
3. Tests sRGB -> Linear approximation function. (Right side only)
|
|
|
|
Compares two discrete gray pallets.
|
|
|
|
The top shows 16 levels of gray by sampling them from an SRGB texture.
|
|
|
|
The bottom shows the same 16 gray values with the input colors converted
|
|
|
|
from sRGB -> Linear by x^2.2 instead of by texture sampling.
|
|
|
|
|
|
|
|
4. Tests color gradients
|
|
|
|
(1,0,0) >>> (1,1,0)
|
|
|
|
(1,1,0) >>> (0,1,0)
|
|
|
|
(0,1,0) >>> (0,1,1)
|
|
|
|
(0,1,1) >>> (0,0,1)
|
|
|
|
(0,0,1) >>> (1,0,1)
|
|
|
|
(1,0,1) >>> (1,0,0)
|
|
|
|
|
|
|
|
5. Tests partial transparency
|
|
|
|
3 horizontal stripes - opaque
|
|
|
|
3 vertical stripes - alpha = 0.5
|
|
|
|
3 vertical stripes - alpha = 0.75
|
|
|
|
|
|
|
|
6. Tests rectangle anti-aliasing by drawing rectangles with a width
|
|
|
|
of 2 placed at various sub-pixel positions
|
|
|
|
|
|
|
|
7. Tests circle anti-aliasing by drawing three circles of various
|
|
|
|
radii. The circle anti-aliasing is computed with a highly accurate
|
|
|
|
area-under-the-curve integration method - see the "sanity test"
|
|
|
|
functions for how the accuracy of the pixel coverage is verified.
|
|
|
|
|
|
|
|
8. Tests circle anti-aliasing with colored backgrounds and shape colors
|
|
|
|
to see if anti-aliasing gives rise to any colored fringes.
|
|
|
|
|
|
|
|
In the top-left corner there is a gamma calibration test image. The
|
|
|
|
top left corner is "0.5 Gray" in the "Linear color space" and the
|
|
|
|
bottom right corner is "0.5 Gray" in the "sRGB color space". The other
|
|
|
|
two corners are identical black-and-white checkerboards. When squinting
|
|
|
|
to physically blur the checkerboard, the brihgtness should resemble the
|
|
|
|
brightness of the top left corner on a correctly calibrated monitor.
|
|
|
|
|
|
|
|
The anti-aliasing of the rectangles and circles should also look better
|
|
|
|
on linear color space side for a correctly calibrated monitor.
|
|
|
|
|