Jump to content
  • Advertisement
Sign in to follow this  
Arkanoid

Problem with fod

This topic is 2444 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 found this sample from msdn how to create fog:






float Start = 0.5f, // Linear fog distances
End = 1000;

// Enable fog blending.
g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, TRUE);

// Set the fog color.
g_pd3dDevice->SetRenderState(D3DRS_FOGCOLOR, 0x00ffffff);

// Set fog parameters.


g_pd3dDevice->SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_EXP);
g_pd3dDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD *)(&Start));
g_pd3dDevice->SetRenderState(D3DRS_FOGEND, *(DWORD *)(&End));


but i see only a white screen, without any objects...where is wrong here?

Share this post


Link to post
Share on other sites
Advertisement
You copied the 'linear fog' code instead of the 'exponential fog' code smile.png

[source]if(D3DFOG_LINEAR == Mode)
{
// This is what you copied, notice the condition above
g_pDevice->SetRenderState(D3DRS_FOGVERTEXMODE, Mode);
g_pDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD *)(&Start));
g_pDevice->SetRenderState(D3DRS_FOGEND, *(DWORD *)(&End));
}
else
{
// This is what you want to be using, i.e. D3DFOG_LINEAR is *not* your fog mode
g_pDevice->SetRenderState(D3DRS_FOGVERTEXMODE, Mode);
g_pDevice->SetRenderState(D3DRS_FOGDENSITY, *(DWORD *)(&Density));
}[/source]

Share this post


Link to post
Share on other sites


g_pd3dDevice->SetRenderState(D3DRS_FOGENABLE, TRUE);

// Set the fog color.
g_pd3dDevice->SetRenderState(D3DRS_FOGCOLOR, 0x00ffffff);

// Set fog parameters.

g_pd3dDevice->SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_EXP2);
g_pd3dDevice->SetRenderState(D3DRS_FOGDENSITY, 100);

in this variant - i have white screen too

Share this post


Link to post
Share on other sites
Have you experimented at all with adjusting the fog density value? It's entirely possible that things are working as intended though it looks different from what you want.

Share this post


Link to post
Share on other sites
Density also needs the float/DWORD trick, and should be quite low - it's a long time since I've used fixed pipeline fog, but if memory serves you should start at about 0.1 and work downwards from there.

Share this post


Link to post
Share on other sites
I think he means like this:

float fogStart = 0.1f;
float fogEnd = 1000.0f;

device->SetRenderState(D3DRS_FOGENABLE, TRUE);
device->SetRenderState(D3DRS_FOGSTART, *(DWORD *)&fogStart);
device->SetRenderState(D3DRS_FOGEND, *(DWORD *)&fogEnd);
device->SetRenderState(D3DRS_FOGTABLEMODE, D3DFOG_LINEAR);

Share this post


Link to post
Share on other sites
Fog start and end are not valid for exp2 mode. You need to set density the same way that you were originally setting start and end in your first post, like so:

float Density = 0.001f;
g_pd3dDevice->SetRenderState(D3DRS_FOGDENSITY, *(DWORD *)(&Density));

Share this post


Link to post
Share on other sites
oops sorry for adding even more confusion. wanted to point out the float/DWORD thing

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!