Graphics Reference
In-Depth Information
Brightness
Informally, brightness can be thought of as the amount of not-black in a color.
For RGB color, “less” black means that the color components are nearer to 1.0,
and “more” black means that the components are nearer to 0.0. To manipulate
the brightness of an image, use a black image with color
target = vec3(0.0, 0.0, 0.0)
as the base. Values of uT less than 1.0 will darken each component of the color,
while values greater than 1.0 will brighten each component of the color up to
the point where the color is clamped. This can, of course, wash out colors if
the colors are already bright or if you use uT too large. This is shown in Fig-
ure 11.21.
Sample code for a very simple fragment shader that adjusts brightness
is shown below. In effect, brightening the image is done by subtracting black
from it.
uniform sampler2D uImageUnit;
uniform float uT;
in vec2 vST;
out vec4 fFragColor;
void main( )
{
vec3 irgb = texture( uImageUnit, vST ).rgb;
vec3 black = vec3( 0., 0., 0. );
fFragColor = vec4( mix( black, irgb, uT ), 1. );
}
Figure 11.21. Brightness manipulation in a photograph from a prehistoric French tomb with uT = 0.0 (left),
1.0 (middle), and 2.0 (right).
Search WWH ::




Custom Search