Graphics Reference
In-Depth Information
For more examples, see [14], where transfer functions are called color
ramps and are discussed in some detail.
In the example shown in Figure 15.20, the fragment shader has taken a
data value from the 3D texture and applied the transfer function before dis-
playing it. But wouldn't it just be easier to set the colors when the 3D texture
was first created and then read them directly from the texture? After all, this
would avoid a lot of per-fragment computation, wouldn't it?
While this would work, there are two reasons we don't like to do it this
way:
1. It forces us to recreate the 3D color texture every time we want to change
the transfer function.
2. The graphics color interpolation can turn out wrong.
The irst reason is prety obvious. By passing raw data through the graph-
ics pipeline, the fragment shader can instantly start using a new color transfer
function, depending on the value of an integer uniform variable. The input 3D
data texture never changes.
But the second reason is more subtle, and has to do with how the graph-
ics system interpolates through the rasterizer. Suppose we want to display a
heated metal bar that has a temperature of 0° at the left end and a temperature
of 100º at the right, as shown in Figure 15.23.
Figure 15.23. A bar with endpoints of different temperatures.
Figure 15.24. The bar above, but with a rainbow scale from left to right.
Figure 15.25. The bar above, but with colors interpolated from the end colors.
Search WWH ::




Custom Search