gDPSetFogColor Function [Macro]

Function

gDPSetFogColor

Sets the fog color

Syntax

#include <ultra64.h>        /* gbi.h */
gDPSetFogColor(Gfx *gdl, u32 r, u32 g, u32 b, u32 a)
gsDPSetFogColor(         u32 r, u32 g, u32 b, u32 a)

Arguments

gdl
Display list pointer.
r
Red component of RGBA color (8-bit precision, 0~255).
g
Green component of RGBA color (8-bit precision, 0~255).
b
Blue component of RGBA color (8-bit precision, 0~255).
a
Alpha component of RGBA color (8-bit precision, 0~255).

Description

Sets the RDP's fog color. The fog color is a general-use color register in the blender (BL). For details, see Section 12.7.3 "BL Internal Color Registers" in the N64 Programming Manual.

Note

In order to do fog, you must generate fog attenuation coefficients in the alpha channel of the RSP graphics microcode. For details, see gSPSetGeometryMode, g*SPFogPosition.

N64 processes fog by Gouraud-shading the fog attenuation coefficients in the alpha channel. At that time, the BL adjusts the attenuation of the pipeline pixel colors to the surrounding fog color. Because the RDP's alpha channel is being used for Gouraud shading of the fog attenuation coefficient, normal alpha values cannot be Gouraud shaded at that time. In other words, you cannot change the transparency inside single triangles when you are using fog.

You can give single triangles constant transact by using gDPSetBlendColor to set the BL. If you Gouraud-shade the fog attenuation coefficient over a size larger than the screen pixel size, you get unrealistic-looking fog. This is because fog attenuates exponentially, and not linearly. You can correct this by dividing up the large geometry into straightline sections in order to calculate the exponential attenuation.

For details, see Sections 11.8 "Vertex Fog State," 12.7.5 "Using Fog," and 15.5.2 "Fog" in the N64 Programming Manual.

See Also

gDPFillRectangle, gDPSetAlphaCompare, gDPSetCombineMode, gDPSetCycleType, gDPSetRenderMode, gSPFogPosition, and gSPSetGeometryMode