Game Development Reference
In-Depth Information
// Desc: Effect file that handles device states for linear vertex fog.
//
technique Fog
{
pass P0
{
//
// Set misc render states.
pixelshader = null;
vertexshader = null;
fvf = XYZ | Normal;
Lighting = true;
NormalizeNormals = true;
SpecularEnable
= false;
//
// Fog states
FogVertexMode = LINEAR;
// Linear fog function.
FogStart
= 50.0f;
// Fog starts 50 units
// away from viewpoint.
FogEnd
= 300.0f;
// Fog ends 300 units
// away from viewpoint.
FogColor
= 0x00CCCCCC;// Gray colored fog.
FogEnable
= true;
// Enable vertex fog.
}
}
As you can see, linear vertex fog can be controlled through five simple
render states:
FogVertexMode —Specifies the fog function to use for vertex fog.
The fog function specifies how the fog increases with distance, as
naturally fog is less thick near the viewpoint and becomes thicker
as the distance increases. Valid assignment types are LINEAR , EXP ,
and EXP2 . These functions are defined as:
end
d
LINEAR fog function: f
end
start
1
EXP fog function: f
e d density
(
)
1
EXP2 fog function: f
2
e d density
((
)
( d is the distance from the viewpoint.)
Note: If you use the EXP or EXP2 fog functions, you do not need to
set FogStart and FogEnd because they are not used in these types of
fog functions; instead you must set the fog density render state (e.g.,
FogDensity = someFloatType; ).
Search WWH ::




Custom Search