From Ohm

TFs With OpenGL Dependent Texturing

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

uniform sampler3D sampler;
vec4 c = texture3D(sampler, texcoords);
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!

Retrieved from http://schorsch.efi.fh-nuernberg.de/roettger/index.php/MedicalVisualization/TFsWithGLSLDependentTexturing

Page last modified on November 19, 2020, at 02:29 PM