DirectX SDK

Light Direction

A light's direction property determines the direction that the light emitted by the object travels, in world space. Direction is only used by directional and spotlights, and is described with a vector.

[C++]

An application that uses C++ employs the the dvDirection member (a D3DVECTOR structure) of the D3DLIGHT7 structure. Direction vectors are described as distances from a logical origin, regardless of the light's position within a scene. Therefore, a spotlight that points straight into a scene (along the positive z-axis) would have a direction vector of <0,0,1> no matter where its position is defined to be. Similarly, you could simulate sunlight shining directly down on a scene by using a directional light whose direction is <0,-1,0>. Obviously, you don't have to create lights that shine along the coordinate axes; you can mix and match values to create lights that shine at more interesting angles.

[Visual Basic]

Visual Basic applications set the light direction in the direction member of the light's D3DLIGHT7 type. The direction member is of type D3DVECTOR. Direction vectors are described as distances from a logical origin, regardless of the light's position within a scene. Therefore, a spotlight that points straight into a scene (along the positive z-axis) would have a direction vector of <0,0,1> no matter where its position is defined to be. Similarly, you could simulate sunlight shining directly down on a scene by using a directional light whose direction is <0,-1,0>. Obviously, you don't have to create lights that shine along the coordinate axes; you can mix and match values to create lights that shine at more interesting angles.

Note  Although you don't need to normalize a light's direction vector, always be sure that it has magnitude. In other words, don't use a <0,0,0> direction vector.