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





gSPFogPosition

Syntax
#include <ultra64.h>  /* gbi.h */
gSPFogPosition(Gfx *gdl, s32 min, s32 max)
gsSPFogPosition(s32 min, s32 max)
Arguments
  • gdl is the display list pointer.

  • min is the place where fog starts (0~1000 (near plane ~ far plane)).

  • max is the place where fog saturates (0~1000 (near plane ~ far plane)).

Explanation
gSPFogPosition specifies the location where the fog effect begins and the location where the effect saturates. Fog changes the color of objects based on their Z positions. Generally, objects are blended with the "fog color" (see gDPSetFogColor) as they become further away from the viewpoint. The farther the object is from the viewpoint, the closer its color gets to the fog color.

The fog effect is mainly used so objects don't suddenly "pop out" of view when they reach the far clipping plane and "pop into" view when they enter the clipping range. To use this effect, set max to 1000. As the object gets closer to the far plane it fades out with the fog color, becoming totally saturated with fog at the far plane.

min sets the distance at which the object begins to fade into the fog. This can be set on the near clipping plane (min = 0) or between the near and far planes (0 < min < 1000). Generally, the min value is set smaller than the max value (but this is reversed when transparent fog is being used).

Note
When fog is used in a perspective-transformed space, it has greater effect than one would expect. The min value may turn out to be far larger than imagined. Also, the location of the near plane has a big influence on the fog effect. One currently-known restriction is that the fog effect does not work well when the value of (starting point) is greater than the value of (ending point - 4). For example, when max=1000 and min=998.

Example

Turn fog ON:

// Set the RDP cycle type.
gDPSetCycleType(gdl++, G_CYC_2CYCLE);
// Set the RDP fog color.
gDPSetFogColor(gdl++, fog_red, fog_green, fog_blue, 0xff);
// Set the blender (BL) rendering mode.
gDPSetRenderMode(gdl++, G_RM_FOG_SHADE_A, G_RM_AA_ZB_OPA_SURF2);
// Specify the fog thickness.
gSPFogPosition(gdl++, 500, 1000);
// Set the geometry mode (fog creation ON).
gSPSetGeometryMode(gdl++, G_FOG);

See also
gDPSetCycleType
gDPSetFogColor
gDPSetRenderMode

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