Graphics Reference
In-Depth Information
When you apply this warp operation to a geometric object such as a cylin-
der, you get a representation of the path an object would take in the flow field.
We call this general warped object a streamtube . We will show the behavior of this
warp operation on the glman geometric arrow object defined with the command
Xarrow 200
This defines an arrow with 200 slices from left to right,
aligned with the x axis, as shown in Figure 15.33. This large num-
ber of slices gives the arrow enough vertices for the vertex shader
to produce a smooth warp.
In an application, you would normally pass in details about
the flow field through a texture or other data structure. To simplify
things here, we will just hard code the vertex shader to twist the
arrow into a spiral. The properties of the spiral are defined by the
glman uniform slider variables uN and uK that control the number
of twists in the warped arrow and the total x -length of the warped
arrow, respectively. Here is the vertex shader code to do this:
Figure 15.33. The original,
unwarped arrow object.
const float R = 2.;
const float PI = 3.14159265;
const float TWOPI = 2.*PI;
const float HALFWIDTH = 0.10;
uniform float uN;
uniform float uK;
uniform float uPeristaltic;
uniform float uSpeed;
uniform float Timer;
out float vColor;
out float vLightIntensity;
const vec3 LIGHTPOS = vec3( 5., 5., 10. );
void main( )
{
vColor = aColor;
vec3 vertex = aVertex.xyz;
float t = ( vertex.x + 1. ) / 2.; // change [-1.,1.]
// to [0.,1.]
float timer = fract( uSpeed*Timer );
if( timer-HALFWIDTH <= t && t <= timer+HALFWIDTH )
Search WWH ::




Custom Search