hi:
i disable fog state in the effect pass;and want to enable fog when i push 'F'.
but, i found it didn't work. my .fx is:
technique Fog
{
pass P0
{
pixelshader = null;
vertexshader = null;
FogVertexMode = LINEAR;
FogStart = 50.0f;
FogEnd = 300.0f;
FogColor = 0x00CCCCCC;
FogEnable = false;
}
}
and the c++ code is:
Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0x00CCCCCC, 1.0f, 0);
Device->BeginScene();
// set the technique to use
FogEffect->SetTechnique( FogTechHandle );
UINT numPasses = 0;
FogEffect->Begin(&numPasses, 0);
D3DXMATRIX I;
D3DXMatrixIdentity(&I);
for(int i = 0; i < numPasses; i++)
{
FogEffect->BeginPass(i);
if( TheTerrain )
TheTerrain->draw(&I, false);
}
FogEffect->End();
if( ::GetAsyncKeyState('F') & 0x8000f )
{
Device->SetRenderState(D3DRS_FOGENABLE, true);
Device->SetRenderState( D3DRS_FOGSTART, 50.0f );
Device->SetRenderState( D3DRS_FOGEND, 300.0f );
Device->SetRenderState( D3DRS_FOGCOLOR, 0x00ffCCCC );
Device->SetRenderState( D3DRS_FOGTABLEMODE , D3DFOG_LINEAR);
}
Device->EndScene();
Device->Present(0, 0, 0, 0);
so, why it doesn't work. thanks a lot