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
|
gSPLightFormat#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
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
|