Graphics Reference
In-Depth Information
3D Line Integral Convolution
The same process can be used in 3D. Here, we have generated a 3D positional
noise texture and a floating point 3D flow texture in which the x , y , and z low
directions have been encapsulated in the r , g , and b components of the texture,
simply extending the 2D approach above. Again, most of the work is done in
the fragment shader:
uniform int uLength;
uniform float uTol;
uniform float uScale;
uniform sampler3D uImageUnit;
uniform sampler3D uFlowUnit;
in vec3 vSTP;
out vec4 fFragColor;
void main( )
{
float Res = float( textureSize( uFlowUnit, 0 ).s );
// flow field direction:
vec3 v = texture( uFlowUnit, vSTP ).xyz;
v *= uScale;
v /= Res;
// starting location:
vec3 stp = vSTP;
vec3 color = texture( uImageUnit, stp ).rgb;
for( int i = 0; i < uLength; i++ )
{
stp += v;
stp = clamp( stp, 0., 1. );
vec3 new = texture( uImageUnit, stp ).rgb;
color += new;
}
stp = vSTP;
for( int i = 0; i < uLength; i++ )
{
stp -= v;
stp = clamp( stp, 0., 1. );
vec3 new = texture( uImageUnit, stp ).rgb;
color += new;
}
Search WWH ::




Custom Search