nrm - ps
Normalisiert einen 3D-Vektor.
Syntax
| nrm dst, src |
|---|
Hierbei gilt:
- dst ist das Zielregister.
- src ist ein Quellregister.
Bemerkungen
| Pixel-Shaderversionen | 1_1 | 1_2 | 1 _ 3 | 1_4 | 2 _ 0 | 2 _ x | 2 _ sw | 3 _ 0 | 3 _ sw |
|---|---|---|---|---|---|---|---|---|---|
| Nrm | x | x | x | x | x |
Diese Anweisung funktioniert konzeptionell wie hier gezeigt.
squareRootOfTheSum = (src0.x * src0.x + src0.y * src0.y + src0.z * src0.z)1/2;
dest.x = src0.x * (1 / squareRootOfTheSum);
dest.y = src0.y * (1 / squareRootOfTheSum);
dest.z = src0.z * (1 / squareRootOfTheSum);
dest.w = src0.w * (1 / squareRootOfTheSum);
Die Register dest und src dürfen nicht identisch sein. Das dest-Register muss ein temporäres Register sein.
Diese Anweisung führt die lineare Interpolation basierend auf der folgenden Formel aus.
float f = src0.x*src0.x + src0.y*src0.y + src0.z*src0.z;
if (f != 0)
f = (float)(1/sqrt(f));
else
f = FLT_MAX;
dest.x = src0.x*f;
dest.y = src0.y*f;
dest.z = src0.z*f;
dest.w = src0.w*f;