lit - vs

2 つの内積と 1 つの指数からライティング係数を計算して、ライティングを部分的にサポートします。

構文

lit dst, src

この場合

  • dst はデスティネーション レジスタです。
  • src はソース レジスタです。

解説 

頂点シェーダーのバージョン 1_1 2_0 2_x 2_sw 3_0 3_sw
lit x x x x x x

ソースのベクトルには、次の擬似コードに示すような値が含まれているものと想定されます。

src.x = N*L        ; The dot product between normal and direction to light
src.y = N*H        ; The dot product between normal and half vector
src.z = ignored    ; This value is ignored
src.w = exponent   ; The value must be between -128.0 and 128.0

次のコードは、実行される演算を示しています。

dest.x = 1;
dest.y = 0;
dest.z = 0;
dest.w = 1;

float power = src.w;
const float MAXPOWER = 127.9961f;
if (power < -MAXPOWER)
    power = -MAXPOWER;          // Fits into 8.8 fixed point format
else if (power > MAXPOWER)
    power = MAXPOWER;          // Fits into 8.8 fixed point format

if (src.x > 0)
{
    dest.y = src.x;
    if (src.y > 0)
    {
        // Allowed approximation is EXP(power * LOG(src.y))
        dest.z = (float)(pow(src.y, power));
    }
}

デスティネーション y 要素 (dest.y) の評価は、低精度の演算で用が足ります。実装では、累乗は少なくとも 8 つの小数ビットをサポートする必要があります。内積は正規化されたベクトルで計算されて、クランプの制限は -128 から 128 までです。

エラーは、logp - vs および exp - vs の組み合わせに対応しているか、8 ビット カラー成分のおよそ 1 有効ビット以下である必要があります。