Graphics Reference
In-Depth Information
#ifdef BRIGHTNESS
vec3 target = vec3( 0., 0., 0. );
#else
vec3 target = vec3( 0.5,0.5,0.5 );
#endif
fFragColor = vec4( mix( target, irgb, uT ), 1. );
}
Blending an Image with a Version of Itself
Another common kind of image manipulation involves creating a base value
that is computed from the image itself. This might be a grayscale image or a
blurred image in the examples below. Again, these are common and very use-
ful kinds of manipulation. And again, we show examples that have been set up
for glman as described above.
Saturation
We think of color saturation as a description of the “purity” of the color, or how
far the color is from gray. This is consistent with the notion of saturation in the
HLS color system, where saturation is the distance from the pure grays that
are at the center of the HLS double cone. If saturation is reduced, the color is
more gray; if it is increased, the color is purer and more vivid.
To manipulate the saturation of an image, you create a grayscale base
image by replacing the color at each point by its luminance that we defined
earlier in this chapter:
target = vec3( luminance, luminance, luminance);
and mix the color with this target, as we have seen. Values of uT less than 1
will move each color component toward its luminance, making the color less
saturated, while values greater than 1 will move each color component away
from the luminance, making it more saturated, as shown in Figure 11.23.
A simple fragment shader to manipulate saturation is shown below.
const vec3 W = vec3( 0.2125, 0.7154, 0.0721 );
uniform sampler2D uImageUnit;
uniform float uT;
in vec2 vST;
Search WWH ::




Custom Search