N64® Functions Menu

al - Audio Library Functions
gDP - DP GBI Macros
gdSP - General GBI Macros
gSP - SP GBI Macros
gt - Turbo Microcode RDP
gu - Graphics Utilities
Math - Math Functions
nuSys - NuSystem
os - N64 Operating System
sp - Sprite Library Functions
uh - Host to Target IO
64DD - N64 Disk Drive

Nintendo® Confidential

## gSPLight

Syntax

    #include <ultra64.h> /* gbi.h */
    gSPLight(Gfx *gdl, Light *l, s32 n)
    gsSPLight(Light *l, s32 n)

Arguments

- gdl is the display list pointer.

- l is the pointer to light structure.

- n is the light number that is replaced (1~8)

Explanation
Loads one Light structure at the specified position in the light buffer. Use gSPNumLights to specify the number of lights to use in the lighting calculation. When gSPNumLights specifies N number of lights, the 1st to Nth lights are used as directional lights (color and direction), and N+1 light is used as the ambient light (color only).

The Light structure color is obtained by mixing the material color and the light color. This optimization improves the performance of the RSP geometry engine.

To change only the color of the light after the light has been set with gSPLight and used by gSPVertex, reset gSPLight, and re-execute gSPVertex. This method of changing the light color boosts performance efficiency. (The same method can be used to change the material color.) However, to change the light direction, you must not only set the light using gSPLight, but also use gSPNumLights to reset the number of lights (even if the number has not changed). For details, see Section 11.7.3 "Lighting With Ambient Light and Diffuse Light" in the N64 Programming

Note
To make the RSP geometry engine more efficient, two vertex lighting calculations are processed at a time. Therefore, the Light structure must have a copy of the diffuse light value. This optimization can be used for special effects.

Comment
For static light, it is more efficient to use gdSPDefLights together with gSPSetLightsM, rather than using gSPLight and gSPNumLights.

The Light structure is shown below.

    typedef struct {
            unsigned char	col[3];  /* Diffuse light value (RGBA) */
            char		pad1;
            unsigned char	colc[3]; /* Copy of diffuse light value (RGBA) */
            char		pad2;
            signed char	dir[3];	 /* Direction toward light source (normalized) */
            char		pad3; /* Important:  Size of "dir" must not exceed 127  */
    } Light_t;
    typedef union {
            Light_t		l;
            long long int	force_structure_alignment[2];
    } Light;

Example
Please refer to Section 11.7.3.6 "Note on Material Properties" in the N64 Online Programming Manual.

See Also
gdSPDefLights
gSPSetGeometryMode
gSPLightColor
gSPNumLights
gSPSetLightsM]

Revision History
2/1/1999 Completely rewritten.

Nintendo® Confidential Warning: all information in this document is confidential and covered by a non-disclosure agreement. You are responsible for keeping this information confidential and protected. Nintendo will vigorously enforce this responsibility.
Copyright © 1998
Nintendo of America Inc. All rights reserved
Nintendo and N64 are registered trademarks of Nintendo
Last updated March 1999