I've changed the engine a bit, so it now supports fog (only in Direct3D mode currently). I've simply added new virtual function to the CVideoDirectX8 class:
Code: Select all
void CVideoDirectX8::setFog(bool bUse, bool usePixelFog, bool useLinearFog, ul32 color, f32 start, f32 end, f32 density)
{
pID3DDevice->SetRenderState(D3DRS_FOGENABLE, bUse);
pID3DDevice->SetRenderState(D3DRS_FOGCOLOR, color);
pID3DDevice->SetRenderState(usePixelFog?D3DRS_FOGTABLEMODE:D3DRS_FOGVERTEXMODE, useLinearFog?D3DFOG_LINEAR:D3DFOG_EXP);
if(useLinearFog)
{
pID3DDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD *)(&start));
pID3DDevice->SetRenderState(D3DRS_FOGEND, *(DWORD *)(&end));
}
else
{
pID3DDevice->SetRenderState(D3DRS_FOGDENSITY, *(DWORD *)(&density));
}
if(!usePixelFog)
pID3DDevice->SetRenderState (D3DRS_RANGEFOGENABLE, true);
return;
}
bool usePixelFog determines whether pixel or vertex mode should be used;
bool useLinearFog determines whether linear or exponential fog should be used;
ul32 color determines the color of the fog (i.e. 0x00FF0000 is red, 0x0000FF00 is green, etc...). BTW, i've added
Code: Select all
typedef unsigned long ul32
f32 start and f32 end are the distances of the beginning and the end of LINEAR fog;
f32 density is the density of the EXPONENTIAL fog.
BTW, the fog has no effect on the skybox It also makes billboards with alpha channel look ugly Anyways, i hope this would be useful for someone...
P.S. Please excuse me for my bad english...