概要
非リニアの色空間からリニア空間への変換などあ、Look Up Table を作って変換すれば良いが、リニア空間から、非リニア空間への変換をやろうとすると、LookUpTableが巨大化しすぎて実用範囲から外れてしまう。
以下に、Look Up Table の逆引き関数を載せる。
なんといっても最大の特徴は、条件分岐が発生していないことである!!
これは革命である(笑
※ただし、Look Up Table は小→大の関係が維持されていること。
int InverseGamma( float value, const float * GammaTable )
{
int index = 0;
index = ((GammaTable[ 128]) <= value) << 7;
index += ((GammaTable[index+ 64]) <= value) << 6;
index += ((GammaTable[index+ 32]) <= value) << 5;
index += ((GammaTable[index+ 16]) <= value) << 4;
index += ((GammaTable[index+ 8]) <= value) << 3;
index += ((GammaTable[index+ 4]) <= value) << 2;
index += ((GammaTable[index+ 2]) <= value) << 1;
index += ((GammaTable[index+ 1]) <= value) << 0;
return index;
}