Jump to content
  • Advertisement
Sign in to follow this  
allecsro

Hide scene edges using fog

This topic is 4478 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 have a large outdoor scene, and I want its edges to be hidden(blurred). I've tried setting up fog, but it applies to all the scene, and so the sky is also obscured.Am I doing this right(by using fog), or is there a better way? Here is the code I use to set up fog :
 float Start   = 0.5f;
 float End     = 0.8f;
 float Density = 0.10f;

 D3DDevice->SetRenderState(D3DRS_FOGENABLE, TRUE);
 D3DDevice->SetRenderState(D3DRS_FOGCOLOR,  0x00FFFFFF);
 D3DDevice->SetRenderState(D3DRS_FOGSTART,  *(DWORD*)&Start);
 D3DDevice->SetRenderState(D3DRS_FOGEND,    *(DWORD*)&End);
 D3DDevice->SetRenderState(D3DRS_FOGDENSITY,*(DWORD*)&Density);

 D3DDevice->SetRenderState(D3DRS_FOGTABLEMODE,D3DFOG_EXP2);
 D3DDevice->SetRenderState(D3DRS_FOGVERTEXMODE,D3DFOG_NONE);
 D3DDevice->SetRenderState(D3DRS_RANGEFOGENABLE,false);
 

Share this post


Link to post
Share on other sites
Advertisement
if you want to stop the sky being fogged, just disable the fog before you render the sky, then switch it back on again.

hth
n

Share this post


Link to post
Share on other sites
Unfortunately that often looks very odd, as the sky stands out clearly and contrasts sharply to the rest of the scene, rather then blending nicely into the 'background'. Perhaps a way around this would be to render the sky with fogging on, however reduce the fogging levels whilst rendering the sky? This certainly isn't technically correct, but it may work for what you want to achieve.

I too have been looking for a way to get the balance between fog and visibility of the sky 'just right'.

Share this post


Link to post
Share on other sites
That balancing could be done by either creating a sky that blends good, or blend the sky texture with another texture that fades into the color of the fog at the bottom.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!