?/TD>
Microsoft DirectX 9.0

nrm (Vertex Shader)


Normalize a 3-D vector.

Syntax

nrm dst, src

where

Remarks

Vertex shader versions1_12_02_x2_sw3_03_sw
nrmxxxxx

This instruction works conceptually as shown here.

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);

This is a macro instruction. The dest and src registers cannot be the same. The dest register must be a temporary register.

This instruction performs the linear interpolation based on the following formula.

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;

Instruction Information

Minimum operating systemWindows 98


© 2002 Microsoft Corporation. All rights reserved.