Graphics Reference
In-Depth Information
uniform sampler2D uTexUnit;
uniform float uMin, uMax;
in vec3 vMCposition;
out vec4 fFragColor;
void main( )
{
vec3 stp = ( vMCposition + 1. ) / 2.;
// maps [-1.,1.] to [0.,1.]
if( any( lessThan( stp, vec3(0.,0.,0.) ) ) )
discard;
if( any( greaterThan( stp, vec3(1.,1.,1.) ) ) )
discard;
float scalar = texture( uTexUnit, stp ).r;
if( scalar < uMin )
discard;
if( scalar > uMax )
discard;
float t = ( scalar - SMIN ) / ( SMAX - SMIN );
vec3 rgb = Rainbow( t );
fFragColor = vec4( rgb, 1. );
}
Using the same 3D dataset as before, this process pro-
duces an image like that shown in Figure 15.13.
Notice the use of the lessThan( ) , greaterThan( ) ,
and any ( ) functions. This also could have been expressed,
equally correctly, as
if( stp.s < 0. || stp.s > 1. )
discard;
if( stp.t < 0. || stp.t > 1. )
discard;
Figure 15.13. Interpolated color
cuting plane.
if( stp.p < 0. || stp.p > 1. )
discard;
Search WWH ::




Custom Search