Graphics Reference
In-Depth Information
False Coloring
Color is important in creating realistic images, but it has other functions as well.
If you want to display information that has more than three dimensions, for
example, you can use traditional geometry to show up to three dimensions and
then use color for the fourth. You can also use color to emphasize the third
dimension when your geometry is
projected to the two dimensions of a
screen or of paper. This use is shown
in Figure 8.4; this same figure was
used in the discussion of false coloring
(or pseudocolor) in [14], but here the
figure has been generated using ver-
tex and fragment shaders and is much
more effective. The technique is much
more general than this, of course. We
will examine this approach and the more general concept of transfer functions
in the later chapter on shaders in scientific visualization.
The vertex shader is much like the one we illustrated when we created
Figure 6.7 in the previous chapter, so we won't include it here. The function
in the figure is a Coulomb function. If we have an array of vec3 data and each
entry's x - and y -coordinates represent a position in the plane, while the z -coor-
dinate represents the charge at that point, the function is
Figure 8.4. A surface whose elevation is coded with color.
[]
Qi z
.
valuexy
(, )
=
,
(
)
(
) +− []
2
(
)
2
[]
xQix yQiy
.
.
where the sum is over all the entries in the plane. This function is writen in
the vertex shader as
float Value = 0.0;
for(int i=0; i<3; i++ )
{
float dist=sqrt((x-Q[i].x)*(x-Q[i].x)+(y-Q[i].y)*(y-
Q[i].y));
Value += Q[i].z/dist;
}
Note that the dist computation could have been expressed, probably
more efficiently, as
Search WWH ::




Custom Search