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.xyz);
  • 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.xyz).r;
gl_FragColor = texture1D(palette, s);

Dependent texture lookups cannot be performed in parallel, therefore they are a bit slower than regular texture lookups in the fragment shader, but still very efficient.

In principle, the fragment shader can be regarded to be an [implicit] transfer function f(s), because depending on s it computes an output color f(s)=gl_FragColor!

OpenGL GLSL Shader Example | | Introduction to VTK

Options: