Fog blending with shadows and ground

[SEE StaggartCreations REPLY FOR SOLUTION]

So, I was adding the Universal Rendering Pipeline to my game so I can get the glow effect, which worked, but now my fog and shadows are acting weird, as well as the directional light. The shadows and the ground begin blending in with the fog as my player moves further from the starting point. Also the directional light works only in a certain direction (all other angles are “fogged”).

Specs:

  • Unity version - 2020.3.27f1
  • OS version - Windows 10 Home
  • DirectX version - 11

Solutions I’ve tried:

  • Using different fog methods - didn’t work, also Linear doesn’t cover objects properly
  • Using a custom skybox
  • Attaching directional light to player
  • Tweaking literally every possible setting relating to Lighting, the Directional Light, the Main Camera and URP

Fog settings:

GIF #1 (directional light works only in certain direction)

GIF #2 (in game)

All together: https://imgur.com/a/cwlUCPn

Any help would be greatly appreciated.

Okay since there weren’t any responses I decided to backtrack and try using the regular Post-processing effects pack again, with no rendering pipeline. The glow material works now and the “glitchy fog” is gone, but this also means I can’t use URP with fog anymore.

But if anyone has this problem in the future, after further experimenting I found out that the fog itself was the culprit. It wasn’t the fault of directional lights, cameras or the other lighting settings. I guess fog in URP is kinda glitchy and hard to work with.

Fog gets applied to a mesh on a per-vertex basis. Meaning if you stretch out a cube, the fog density gets linearly interpolated from the far to the near end. That’s what seems to be happening in your GIF.

A way around this is to use a mesh with more edge loops. A denser vertex count will result in more accurate fog in this case.

I believe as of 2021.1+ (or .2?) fog is now applied on a per-pixel basis. As a result, a simple quad scaled way up would still appear to be fogged correctly.

Okay so good news. Both of your solutions worked, I first tried subdividing the edges of a cube in Blender 20 times (I think this is what you meant by edge loop?) and swapping the Ground mesh with the Blender cube mesh. This worked pretty well, albeit being slightly noticable.

Then after checking release notes for 2021.1 + 2021.2, you were right they changed it in 2021.2. After installing Unity Editor 2021.2.0f1 the fog worked perfectly.

Although I don’t see any point for me to go back to URP now that I’ve found an alternate solution, I was only using URP for the glow material anyway. But still thank you for the help, and if somebody else has this problem in the future I’m sure your solution will help them.

2 Likes