[osg-users] Text gradient in HSV or RGB

Terry Welsh mogumbo at gmail.com
Mon Nov 16 20:50:43 PST 2009


I just tried using a color gradient in my osgText::Text.  The problem
is that I can't fade from a color with a definite hue to a gray
accurately.  For example, fading from green on the top to gray on the
bottom ((0, 1, 0) to (0.5, 0.5, 0.5)) works for the capital letters.
But lower-case letters end up with sort of a desaturated orange on top
(0.75, 0.75, 0.375) and it looks weird.  This is because osgText::Text
interpolates in HSV space instead of RGB space and gray is assumed to
have a hue of 0.

The comments in Text.cpp say  "for linear interpolation to look
correct for colors and imitate what OpenGL does, we need to convert
over to Hue-Saturation-Value and linear interpolate in that space."
It's possible this is in the OpenGL spec, but I've never heard of it
and I've never seen an OpenGL implementation actually do this.  I
think we should simplify things and just interpolate in RGB space,
which is probably the correct way to go.

Alternatives are:
1.  to never specify a color that is exactly gray and give it a little
of the same hue as your other color.
2.  to make Text.cpp a little smarter in computing the hues if one or
more of the specified colors are gray.

Thoughts?  I think I can fix up the code pretty fast once we agree on
a solution.
--
Terry Welsh  /  mogumbo 'at' gmail.com
www.reallyslick.com  /  www.mogumbo.com


More information about the osg-users mailing list