MedicalVisualization

TFs With OpenGL Dependent Texturing

OpenGL GLSL Shader Example | | Introduction to VTK

The fragment shader is the TF!

In order to perform color-mapping with GLSL in the fragment shader, we need to

  • perform a 3D texturing lookup to yield the actual fragment texture color
uniform sampler3D sampler;
vec4 c = texture3D(sampler, texcoords);
  • and modify the color to implement the color mapping, e.g. from [0.25,1] to red
if (c.x >= 0.25) c.x = 1;
gl_FragColor = c;
MPR-TF
MPR-TF2
MPR-TF3

In order to have an arbitrary lookup table, we store the table in a 1D texture and perform a 1D dependent texture lookup (a palette) with the scalar value retrieved from the 3D texture lookup. It is called a dependent texture lookup, because it depends on a previous texture lookup:

uniform sampler3D sampler;
uniform sampler1D palette;
float s = texture3D(sampler, texcoords).r;
gl_FragColor = texture1D(palette, s);

Dependent texture lookups cannot be performed in parallel, therefore they are slower than regular texture lookups in the fragment shader.

In principle, the fragment shader can be regarded to be the TF, because depending on s it computes an output color gl_FragColor!

OpenGL GLSL Shader Example | | Introduction to VTK

Options: