Jump to content

Probleme with the fog and the shadows


Dad72
 Share

Recommended Posts

Hi,

 

When I put fog on my scene it is active only from the outer limit of the ground and not from the camera. If I have a terrain of 1000 * 1000 my fog begins very far from the camera if i am on the ground in the middle.
It should be visible on the ground also, no? If I does not of ground it works very well.
I've try the mode LINEAR, EXP and EXP2, same observation.

 

and my shadows do not work.

Link to comment
Share on other sites

This is because you use a custom shader for the ground. If you need fog support, you have to code it in your shader :)

 

Here is an extract of the code I used in the StandardMaterial:

 
#define FOGMODE_NONE    0.#define FOGMODE_EXP     1.#define FOGMODE_EXP2    2.#define FOGMODE_LINEAR  3.#define E 2.71828uniform vec4 vFogInfos;uniform vec3 vFogColor;varying float fFogDistance;float CalcFogFactor(){float fogCoeff = 1.0;float fogStart = vFogInfos.y;float fogEnd = vFogInfos.z;float fogDensity = vFogInfos.w;if (FOGMODE_LINEAR == vFogInfos.x){fogCoeff = (fogEnd - fFogDistance) / (fogEnd - fogStart);}else if (FOGMODE_EXP == vFogInfos.x){fogCoeff = 1.0 / pow(E, fFogDistance * fogDensity);}else if (FOGMODE_EXP2 == vFogInfos.x){fogCoeff = 1.0 / pow(E, fFogDistance * fFogDistance * fogDensity * fogDensity);}return clamp(fogCoeff, 0.0, 1.0);}float fog = CalcFogFactor();color.rgb = fog * color.rgb + (1.0 - fog) * vFogColor;
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...