Water 4 (Advanced) - Fog Missing From Reflections

I am using Water 4 (Advanced) but the rendered reflection does not look like it is rendering fog (see attached screen grab). Is there something lacking in Water 4 (Advanced) or have I missed a setting somewhere?

As you can see in this screen grab the mountain peak in the center is barely visible due to the fog settings. But it is clearly visible in the reflection on the water’s surface. The main fog render settings appear to be ignored by the reflection camera.

Hi there,

Fog and water reflections seem to be a pretty tough problem. From my experience:

It used to work in Unity 4 Direct X9 with forward rendering path. With any other combination (Unity 5 OR Direct X 11 OR deferred rendering path), it doesn’t.

I think an explanation for this is that, in any of the latest cases, fog seems to be performed in camera clipping space, which means, for the reflection effect, after having projected the vertices through an oblique projection matrix. This process totally distorts the depth-to-clipspace relationship by changing the far clipping plane, and thus fog computations are totally ruined. If you’re into maths, see the magic details here: http://www.terathon.com/lengyel/Lengyel-Oblique.pdf.

If you want to have correct fog in reflections, the solutions I can think of are sadly few, and not easy:

  • rewrite every shader with fog computation in world space, thus avoiding the oblique camera projection problem. This might be quite long, and it might slow down rendering performances. But maybe it can be achieved in Unity 5 by only rewriting all the FOG handling #define directives in the file UnityCG.cginc? I’m not sure however about how fog parameters are passed, and in which coordinate system they are (world space? clip space?).
  • use “hacks”, like creating artificial fog zones that are only visible in reflections (using camera render layers) to compensate for the missing fog; for example a huge sphere which renders some kind of blended color depending on the real distance to the camera, maybe with soft edge attenuation, etc… This could get quite tricky and I’m not sure it would perfectly match the real fog behaviour, but it may do the trick if you don’t aim for the perfect look.

I know this is quite disappointing, but I hope it shed some light on the problem. Maybe someone out there has other ideas/workarounds?

Peace.