next up previous contents
Next: 17 Natural Phenomena Up: 16 Scientific Visualization Techniques Previous: 16.4.6 Going Farther   Contents

16.5 Illuminated Stream Lines

Stream line based techniques rely on tracing a path through the field starting at some point in the field. Once the path has been traced, the path is represented using geometric primitives. When visualizing 3-dimensional fields, illumination and shading provide additional visual cues, particularly for dense collections of stream lines. One type of geometry that can be used is tube shaped geometry constructed from segments of cylinders following the path. In order to capture accurate shading information the radius of the cylinders needs to be finely tessellated resulting in a large polygon load when displaying a large number of stream lines.

Another possibility it to use line primitives since they can be rendered very efficiently and allow very large numbers of streamlines to be drawn. A disadvantage is that lines are rendered as flat geometry with a single normal at each end point so they result in much lower shading accuracy compared to using tessellated cylinders. In [95] an algorithm is described to approximate cylinder-like lighting using texture mapping.

The main idea behind the algorithm is to choose a normal vector that lies in the same plane as that formed by the tangent vector $\vec{T}$ and light vector $\vec{L}$. The diffuse and specular lighting contributions are then expressed in terms of the line's tangent vector and the light vector rather than a normal vector. For the diffuse term, $\vec{L} \cdot \vec{N} = \sqrt{1 - (\vec{L} \cdot \vec{T})^2}$. This allows the diffuse cosine term to be evaluated using the OpenGL texture matrix to compute $\vec{L} \cdot \vec{T}$, by specifying the components of the tangent vector in the texture coordinate and the components of the light vector in the texture matrix,

\begin{displaymath}M = \pmatrix{L_x & L_y & L_z & 1 \cr 0 & 0 & 0 & 0 \cr 0 & 0 & 0 & 0 \cr 0 & 0 & 0 & 2 \cr}\end{displaymath}

The resulting $s$ texture coordinate is $t_s = (\vec{L} \cdot \vec{T} + 1)/2$ which has been biased to ensure that the computed coordinate value lies in the range $[0,1]$. The $s$ texture coordinate is then used to index a 1-dimensional texture storing the cosine function modulated by the material diffuse reflectance $f( t_s ) = d_{m}\sqrt{1 - (2t_s - 1)^2}$.

Similarly the specular term $(\vec{V} \cdot \vec{R})^n$ can be expressed in terms of the tangent vector and viewing direction $\vec{V}$ as $((\vec{L} \cdot \vec{T}) (\vec{V} \cdot \vec{T}) - \sqrt{1-(\vec{L} \cdot \vec{T})^2}\sqrt{1-(\vec{V} \cdot \vec{T})^2})^n$. Using the texture matrix,

\begin{displaymath}M = \pmatrix{L_x & L_y & L_z & 1 \cr V_x & V_y & V_z & 1 \cr 0 & 0 & 0 & 0 \cr 0 & 0 & 0 & 2 \cr}\end{displaymath}

to compute $t_t = (\vec{V} \cdot \vec{T} + 1)/2$, then $\vec{V} \cdot \vec{T} = 2t_t - 1$ and $t_s = (\vec{L} \cdot \vec{T} + 1)/2$ as before. Thus $t_s$ and $t_t$ can be used with a 2-dimensional texture to generate the specular term. Since the texture encodes the viewing direction $\vec{V}$, the texture map must be regenerated if the view direction changes (if the light moves with the view, as is the case for a headlight, then no recomputation is necessary). Finally, the specular and diffuse terms can be combined together with an ambient term into a single texture map to perform the entire lighting calculation in a single pass.

Since the texture map encodes the material reflectance coefficients, multiple texture maps are required for multiple materials. This need for multiple maps can be eliminated by sending the material color as the line color and storing only the light intensity in the texture map. The two can be combined using the GL_ MODULATE texture environment function. Multiple maps or recomputations are required to support different combinations of diffuse and specular properties.

The illuminated lines can also be rendered using transparency techniques. This is useful for dense collections of stream lines. The opacity value is sent with the line color and the lines must be sorted from back to front to be rendered correctly as described in Section 12.


next up previous contents
Next: 17 Natural Phenomena Up: 16 Scientific Visualization Techniques Previous: 16.4.6 Going Farther   Contents
2001-01-10