Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

dark_vision

out of the fog...

This topic is 5213 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all. I have added fog to a scene with the following code: pGraphics->SetRenderState(D3DRS_FOGENABLE, TRUE); pGraphics->SetRenderState(D3DRS_FOGCOLOR, D3DCOLOR_RGBA(141, 141, 141, 255)); pGraphics->SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_LINEAR); pGraphics->SetRenderState(D3DRS_FOGSTART, 0.0f); pGraphics->SetRenderState(D3DRS_FOGEND, 1.0f); It looks ok, but I wanted to see the objects arising from the fog. More clearly... my far view is set to 10000, so, without fog, moving foward start showing new objects out of nowhere, now with fog they appear like 50% combined with the back color (wich is the same) and start getting clearer as I come close. Better than the first case, but still i''ll be better if they appeared almost lost with the back color (like 5% own color and 95% background). I hope I made myself clear. I have played a lot with the start/end values, used FOGVETEXMODE and also D3DFOG_EXP and D3DFOG_EXP2, and still haven''t got what I want. Maybe it can''t be done and I have to make something like my own shader? I hope someone can help me with this one. Thanks in advance, James.

Share this post


Link to post
Share on other sites
Advertisement
I think you need to convert your fog start and end values from float to DWORD. also have u tried enabling range fog?


FLOAT fFogStart = 30.0f;
FLOAT fFogEnd = 80.0f;

DWORD dwFogStart = *((DWORD*)&fFogStart);
DWORD dwFogEnd = *((DWORD*)&fFogEnd);

// Turn on fog
pGraphics->SetRenderState(D3DRS_FOGENABLE, TRUE);
pGraphics->SetRenderState(D3DRS_FOGCOLOR, D3DCOLOR_RGBA(141, 141, 141, 255));
pGraphics->SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_NONE);
pGraphics->SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR);
pGraphics->SetRenderState(D3DRS_FOGSTART, dwFogStart);
pGraphics->SetRenderState(D3DRS_FOGEND, dwFogEnd);
pGraphics->SetRenderState(D3DRS_RANGEFOGENABLE, TRUE);

Share this post


Link to post
Share on other sites
Ok it was that DWORD conversion, I don''t know why I didn''t made it before. A lot of thanks for making me realize it.

James.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!