Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Terrain Fog


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
9 replies to this topic

#1 Medo3337   Members   -  Reputation: 675

Like
0Likes
Like

Posted 20 April 2013 - 09:12 PM

I'm trying to enable fog on terrain:

    float fogstart=5000.0f;   
    float fogend=10000.0f;

    m_d3dDevice->SetRenderState(D3DRS_FOGENABLE,TRUE);
    m_d3dDevice->SetRenderState(D3DRS_FOGTABLEMODE,D3DFOG_LINEAR);
    m_d3dDevice->SetRenderState(D3DRS_FOGCOLOR,0x00F0F0FF);
    m_d3dDevice->SetRenderState(D3DRS_FOGSTART,*(DWORD*)&fogStart);
    m_d3dDevice->SetRenderState(D3DRS_FOGEND,*(DWORD*)&fogEnd);

I'm getting weird results:

fog.png

 

Maybe the white color should have alpha channel?

 



Sponsor:

#2 L. Spiro   Crossbones+   -  Reputation: 14027

Like
0Likes
Like

Posted 20 April 2013 - 11:32 PM

Unless you provide shots of the fog from multiple angles that could be a very valid result.
Specifically, I see grey in the lower-left, indicating it is properly fading from terrain to fog over a certain distance.

The scale of your world seems to be very huge. Most likely this is a problem with your parameters, and the range in which is fades from 0 to 100% is very small (compared to the scale of the world), making you believe there is no fade.
Firstly, see how it looks when the near fog value is set to 0.

Then increase your camera’s near plane to something like 500.
Since your camera’s far plane is obviously higher than 10,000, you likely have a near plane that is too small and you have a severe amount of z-fighting, causing the fading into fog to appear less smooth or even non-existent.


L. Spiro
It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#3 Medo3337   Members   -  Reputation: 675

Like
0Likes
Like

Posted 21 April 2013 - 01:02 AM

When I set fogStart to 1.0f and fogEnd to 1500.0f I get the following result:

FOG RESULT.png

 

Why do I see solid white? I want to make the fog on the terrain look realistic.


Edited by Medo3337, 21 April 2013 - 01:16 AM.


#4 Medo3337   Members   -  Reputation: 675

Like
0Likes
Like

Posted 21 April 2013 - 01:22 AM

The result that I want to accomplish should be something close to this:

223225.gif



#5 L. Spiro   Crossbones+   -  Reputation: 14027

Like
1Likes
Like

Posted 21 April 2013 - 01:56 AM

So, basically there is no real problem/bug here.

There is fading happening based on the parameters you set.

 

You told it to fade into 100% fog at 15,000 units.  At 15,000 units it becomes fully fogged.

If you don’t like that, either set the far plane of the fog to be barely shorter than your camera’s far plane or move the far plane closer to the edge of the far-fog plane.

 

In other words, you told it to become 100% fog at 15,000 units.  Then you told your camera to view around 20,000 or maybe 30,000 units.  If you don’t want to see pure fog, don’t set your camera’s view distance to a range farther than the fog’s far plane.

 

 

L. Spiro


It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#6 Medo3337   Members   -  Reputation: 675

Like
0Likes
Like

Posted 21 April 2013 - 02:30 AM

@L. Spiro: Should I use the fog for the terrain only or for all the meshes?

 

I want the far meshes to appear with LESS details.



#7 L. Spiro   Crossbones+   -  Reputation: 14027

Like
0Likes
Like

Posted 21 April 2013 - 02:36 AM

For all meshes.

 

 

L. Spiro


It is amazing how often people try to be unique, and yet they are always trying to make others be like them. - L. Spiro 2011
I spent most of my life learning the courage it takes to go out and get what I want. Now that I have it, I am not sure exactly what it is that I want. - L. Spiro 2013
I went to my local Subway once to find some guy yelling at the staff. When someone finally came to take my order and asked, “May I help you?”, I replied, “Yeah, I’ll have one asshole to go.”
L. Spiro Engine: http://lspiroengine.com
L. Spiro Engine Forums: http://lspiroengine.com/forums

#8 Medo3337   Members   -  Reputation: 675

Like
0Likes
Like

Posted 21 April 2013 - 06:23 AM

Okay thanks, take a look at the screenshot, it show less details for far mountains, is that fog effect?

realistic result.png



#9 Migi0027 =A=   Crossbones+   -  Reputation: 1987

Like
0Likes
Like

Posted 21 April 2013 - 03:11 PM

I think it is


Hi! Cuboid Zone
The Rule: Be polite, be professional, but have a plan to steal all their shaders!


#10 Medo3337   Members   -  Reputation: 675

Like
0Likes
Like

Posted 21 April 2013 - 03:32 PM

Okay... Thanks everyone!






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