Sign in to follow this  
bigbrother2000

changing fog color - during runtime

Recommended Posts

Hi all, i'm trying to change the fog during runtime by using a variable fogcolor. If changefogcolor is set to one then the fog should change to black although instead of a gradual gradient in change like the backdrop the fog will remain white and then turn suddenly to black once the value is 255. It is passed the same fogcolor variable that is given to the backdrop so shouldn't the effect be the same? //placed in render function if ((changefogcolor == 1) && (fogcolor < 255)) { fogcolor++; } m_pD3DDevice->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(fogcolor, fogcolor, fogcolor), 1.0f, 0); //Begin the scene m_pD3DDevice->BeginScene(); m_pD3DDevice->SetRenderState(D3DRS_FOGCOLOR, D3DXCOLOR(fogcolor,fogcolor,fogcolor,0));

Share this post


Link to post
Share on other sites
Use this instead:
m_pD3DDevice->SetRenderState(D3DRS_FOGCOLOR, D3DCOLOR_XRGB(fogcolor,fogcolor,fogcolor));

D3DXCOLOR likes floats, D3DCOLOR likes ints/dwords/whole numbers.

Also, why exactly are you clearing to your fog color? You seem to have used D3DCOLOR in your clear call, so you had it right in one place.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this