Jump to content

  • Log In with Google      Sign In   
  • Create Account

Problem with fod


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 Arkanoid   Members   -  Reputation: 109

Like
0Likes
Like

Posted 03 April 2012 - 01:21 PM

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?

Sponsor:

#2 Waterlimon   Members   -  Reputation: 1143

Like
0Likes
Like

Posted 03 April 2012 - 01:38 PM

should 1000 be 1000.0f?
The lack of awesome free resource gathering building sandbox games capable of running an user made 8 bit computer in the world disturbs me.

#3 InvalidPointer   Members   -  Reputation: 951

Like
0Likes
Like

Posted 04 April 2012 - 08:39 AM

You copied the 'linear fog' code instead of the 'exponential fog' code Posted Image

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));
}

clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.

#4 Arkanoid   Members   -  Reputation: 109

Like
0Likes
Like

Posted 04 April 2012 - 11:12 AM


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

#5 InvalidPointer   Members   -  Reputation: 951

Like
0Likes
Like

Posted 04 April 2012 - 03:55 PM

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.
clb: At the end of 2012, the positions of jupiter, saturn, mercury, and deimos are aligned so as to cause a denormalized flush-to-zero bug when computing earth's gravitational force, slinging it to the sun.

#6 mhagain   Members   -  Reputation: 4032

Like
0Likes
Like

Posted 04 April 2012 - 04:46 PM

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.

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#7 Arkanoid   Members   -  Reputation: 109

Like
0Likes
Like

Posted 05 April 2012 - 07:13 AM

g_pd3dDevice->SetRenderState(D3DRS_FOGDENSITY, 0.001f);

and white screen too...

#8 froop   Members   -  Reputation: 274

Like
0Likes
Like

Posted 05 April 2012 - 07:19 AM

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);

#9 mhagain   Members   -  Reputation: 4032

Like
0Likes
Like

Posted 05 April 2012 - 07:41 AM

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));

It appears that the gentleman thought C++ was extremely difficult and he was overjoyed that the machine was absorbing it; he understood that good C++ is difficult but the best C++ is well-nigh unintelligible.


#10 froop   Members   -  Reputation: 274

Like
0Likes
Like

Posted 05 April 2012 - 08:03 AM

oops sorry for adding even more confusion. wanted to point out the float/DWORD thing

#11 Arkanoid   Members   -  Reputation: 109

Like
0Likes
Like

Posted 05 April 2012 - 11:05 AM

thx all... now it works




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS