Specifies fog thickness
#include <ultra64.h> /* gbi.h */ gSPFogPosition(Gfx *gdl, s32 min, s32 max) gsSPFogPosition( s32 min, s32 max)
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).
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.
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);
gDPSetCycleType, gDPSetFogColor, and gDPSetRenderMode
02/01/99 Entirely revised.