Graphics Reference
In-Depth Information
Also, notice that when uTol = 5., the uTol if-statement always fails, and
we end up with the same display as we had with the interpolated colors. Thus,
we don't actually need the separate cuting plane shader at all. Shaders that can
do double duty are always appreciated!
It is also important to notice that the shaders maintain the mapping from
the coordinates of the cuting planes to the texture coordinates that hold the
data. This means that the cuting planes do not need to be oriented parallel to
principal axes, but can be rotated into any orientation. It also means that the
cuting geometry does not need to be a plane at all. It can be any shape for
which you can produce the coordinates-to-texture mapping.
Volume Probe
Sometimes a cuting plane is too restrictive, that is, it is thin and lat. What if
we want to map a colored representation of the scalar data to something that
is not so thin and flat? What if we want to map it instead to something that is
3D? A variation on the cuting plane is to pass a 3D object through the scene
and map data values to it. This called a volume probe . This technique uses a
simple vertex shader and does most of its work in the fragment shader. The
vertex shader, shown below, keeps track of the eye coordinates of each vertex.
out vec4 vECposition;
void main( )
{
vECposition = uModelViewMatrix * aVertex;
gl_Position = uModelViewProjectionMatrix * aVertex;
}
The eye coordinates are then interpolated through the rasterizer, con-
verted to s-t-p texture coordinates by the fragment shader, and finally looked
up in the data texture. A fragment shader that does this is shown below.
const float SMIN = 0.;
const float SMAX = 120.;
uniform float uMin, uMax;
uniform sampler3D uTexUnit;
in vec4 vECposition;
out vec4 fFragColor;
Search WWH ::




Custom Search