Jump to content
  • Advertisement
Sign in to follow this  
Knight52

[DX9] fog won't turn on

This topic is 2447 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

I added this bit of code into the program


LPDIRECT3DDEVICE9 device;
...
device->SetRenderState(D3DRS_FOGENABLE, true);
device->SetRenderState(D3DRS_FOGCOLOR, D3DCOLOR_XRGB(255, 255, 0));
device->SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_EXP);
device->SetRenderState(D3DRS_FOGDENSITY, 0.1);


No fog at all when I run the program. I tried changing fog's density from 0.1 to 0.99, nothing at all. If I put in more than that, still nothing. Less than 0, everything but background is filled with yellow I set for the fog. I changed from FOGTABLEMODE to FOGVERTEXMODE, from exp to exp2, to linear. I tried everything I can think of. but the fog just doesn't show up at all. The model goes beyond the far plane. I'm quite sure I did something wrong here. What could I do wrong?

Share this post


Link to post
Share on other sites
Advertisement
Read the documentation for D3DRS_FOGDENSITY (http://msdn.microsoft.com/en-us/library/windows/desktop/bb172599%28v=vs.85%29.aspx):
Values for this render state are floating-point values. Because the IDirect3DDevice9::SetRenderState method accepts DWORD values, your application must cast a variable that contains the value, as shown in the following code example.m_pDevice9->SetRenderState(D3DRS_FOGDENSITY, *((DWORD*) (&fFogDensity)));[/quote]

Also, this kind of fog will flat-out not work at all with SM3 or higher hardware: http://msdn.microsoft.com/en-us/library/windows/desktop/bb147365%28v=vs.85%29.aspx#Fog_Depth_and_Shading_Mode_Changes

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!