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

Format
#include "gbi.h"

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 TOWARDS
     the light source */

  char      pad3;
  /* This does not need
     to be normalized
     but should have a
    large magnitude (~127) */

} Light_t;            
typedef union {
  Light_t     l;
  long int force_structure_alignment[4];
} Light;

gSPLight(Gfx *gdl,
   Light *l, int n)
gsSPLight(Light *l, int n)
Arguments
  • gdl is the pointer to the graphics display list
  • l is the pointer to the light
  • n is the number of the light to replace (1-8)
What This Macro Does
It loads a single light structure into the numbered position in the light buffer.

Use the gSPNumLights macro to specify which lights should be used in the lighting calculation. If gSPNumLights specifies that N lights will be used, then the 1st N lights (1-N) will be used as directional lights (color and direction) and the N+1st will be used as an ambient light (color only).

The colors in the light structure combine the color of the light with the color of the material. Although this convention may seem awkward at first, this optimization provides significant speedup in the RSP geometry engine.

After the light is set (with a gSPLight macro) and then used (with any gSPVertex macro), then that light's color may be changed for vertices in future gSPVertex calls by calling gSPLight again. This method of changing the light color is performance-efficient. (Note that this is also the method to use to change the material color.) However, if the light's direction must be changed, call the gSPLight macro to resend the light, and call gSPNumLights to reset the number of lights.

The best way to define the static lights is to call gdSPDefLights, and then call gSPSetLights instead of using gSPLight and gSPNumLights explicitly.

Note
Requiring a copy of the diffuse light value in the structure is an optimization for the RSP geometry engine; lighting calculations for vertices are processed two at a time. This optimization can be exploited for special effects.

See Also
gSPGeometryMode
gSPSetLights
gdSPDefLights
gSPNumLights
gSPLightColor



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 January 1998