TFs With OpenGL Dependent Texturing
In order to use color-mapping in the shader, we need to
- perform 3D texturing to yield the actual fragment texture color
TEMP texcol; TEX texcol,fragment.texcoord[0],texture[0],3D;
- and modify the color to implement the color mapping, e.g. from [0.25,1] to red.
TEMP test; SUB test.x,texcol.x,0.25; CMP texcol.x,test.x,texcol.x,1;
In order to have an arbitrary lookup table, we store the table in a 1D texture and perform a 1D dependent texture lookup 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:
TEX texcol,fragment.texcoord[0],texture[0],3D; TEX texcol,texcol.x,texture[1],1D;
Dependent texture lookups cannot be parallelized, therefore they are slower than regular texture lookups in the fragment shader.
In principle, the fragment shader can be regarded to be the TF (by implementing it)!