Graphics Reference
In-Depth Information
Hue Shifting
Along with the conversion to CMYK color, you can also convert among the
other major color models. We assume that you are familiar with the HLS and
HSV color models [14], and we will implement hue shifting by converting
RGB to either HLS or HSV color, changing the hue in the new color model, and
then shifting back to RGB. The effect of this kind of image shifting is shown in
Figure 11.4.
Figure 11.4. A color image and the same image with hue shifted by 240 degrees.
Some sample fragment shader code to do this is shown below, using
the HSV color model. This color model is used because the hue is an angular
function, and you can shif color easily by adding a numeric value to the hue
and taking the result mod 360. The color conversions from RGB to HSV and
back from HSV to RGB use two functions from [18]. The hue-shifting shader
is writen to use the glman slider variable T , with range [0., 360.], to control the
amount of the hue shift.
uniform float uT;
uniform sampler2D uImageUnit;
in vec2 vST;
out vec4 fFragColor;
vec3
convertRGB2HSV( vec3 rgbcolor )
Search WWH ::




Custom Search