Graphics Reference
In-Depth Information
// starting location:
vec2 v = texture( uFlowUnit,vST ).xy;
vec3 color = vec3( texture( uImageUnit, vST ) );
vec2 st = vST;
for( int i = 0; i < uLength; i++ )
{
st += v;
st = clamp( st, 0., 1. );
color += vec3( texture( uImageUnit, st ) );
}
st = vST;
for( int i = 0; i < uLength; i++ )
{
st -= v;
st = clamp( st, 0., 1. );
color += vec3( texture( uImageUnit, st ) );
}
color /= float(uLength + uLength + 1); // divide by # of
// samples
fFragColor = vec4( color, 1. );
}
Figure 15.31 shows how this fragment shader works when applied to a
noise image.
Figure 15.31. The circular LIC applied to a noise image. Left: length = 0 (the original image).
Right: length = 50.
Search WWH ::




Custom Search