[x3d-public] Which color space for Background color interpolation

Andreas Plesch andreasplesch at gmail.com
Mon Oct 12 21:30:42 PDT 2020


While trying to linearly interpolate in HSV space, a question came up
for me with regards to Hue. Hue is represented as an angle in a color
circle. This means there are two ways to linearly interpolate, in the
acute segment defined by the two hues, or in the obtuse segment. Say
the first hue is 10 degrees and the second 300. At a fraction of 0.5,
the interpolated value may be 155 ( in the obtuse segment ) or 335 (
in the acute segment ).

One rule may be to always go counterclockwise in the circle, eg. from
10 to 300 in the example. But then it is hard to predict if the
interpolation between two similar shades of a color (say for a blue
sky) results in similar shades, or actually goes around most of the
full color circle, generating a very colorful result.

So a more reasonable rule may be to always interpolate in the acute
segment, clockwise or counterclockwise as necessary. I think slerp
always takes the shorter path as well.

I hope that there is a more straightforward interpretation of what it
means to interpolate in HSV space, and I just overlooked something.

-Andreas

On Mon, Oct 12, 2020 at 6:17 PM Andreas Plesch <andreasplesch at gmail.com> wrote:
>
> The Background specification in
>
> https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/enveffects.html#Backgrounds
>
> states that
>
> "The sky colour is linearly interpolated between the specified
> skyColor values." and
> "The ground colour is linearly interpolated between the specified
> groundColor values."
>
> The ColorInterpolator specification in
>
> https://www.web3d.org/documents/specifications/19775-1/V3.3/Part01/components/interp.html#ColorInterpolator
>
> states that
>
> "A linear interpolation using the value of set_fraction as input is
> performed in HSV space."
>
> The ColorInterpolator language is more precise in giving the space in
> which linear interpolation should be performed.
>
> I think there is a need to also become more precise for Background
> color interpolation. The consistent approach would be to choose HSV
> space there as well:
>
> "The sky colour is linearly interpolated in HSV space between the
> specified skyColor values." and
> "The ground colour is linearly interpolated in HSV space between the
> specified groundColor values."
>
> HSV space probably also leads to more aesthetically pleasing backgrounds.
>
> [x3dom currently performs all color interpolation in RGB space].
>
> Do we need such a clarification ?
>
> -Andreas
> --
> Andreas Plesch
> Waltham, MA 02453



-- 
Andreas Plesch
Waltham, MA 02453



More information about the x3d-public mailing list