Horizon Fog

Hello!

Since a few weeks now i’m trying to read all their is about unity, and i love itI and the community rocks… tnx everybody for letting me learn so much… For an artporject of mine i need a horizon fog:
(a link from the terrain tutorial)

I am creating a dutch field a “polder” and the horizon is verry ugly. This is the work from wich it originated.

I rememberd the days when I tweaked with bryce. It had a nice band on the horizon, that whould work i guess…
I read about yoggy’s fog band, but i am a bit clueless of how he did it. The standard fog in the rendering setting is not enough i guess, because it is a farsight. I know there are particles involved and i saw the tutorial from the tornadotwins (all 29 :roll_eyes: ), but that’s no way near fog…

there is some nice progress in this field i keep track: http://forum.unity3d.com/threads/26043-Vertical-gradient-fog
should be pretty impressive once it is finished.

If someone whould help me on my way, i would be verry gratefull, to bad i am a visual person, no programmer, otherwise i could have done this by reading the manual (rtfm!)

I can trade however, I teach photoshop at an acadamy, so if ya want some hard skills in return… let me know!

Tnx in advance

I’m hopeful that someone on this forum has a better way to do it in Unity, but when I’ve implemented it in other systems it required writing custom shader code.

Search for “Real Time Rendering of Light Scattering For Outdoor Scenes”. There is a good summary paper by James Long.

I would love this feature too, I hate that if you activate fog your skybox becomes totally useles… but horizont fog would be very helpful to close scene geometry at a certain point and retain the skybox feature.

I didnt quite understand, you want fog on the ground ?
If so, you might wanna check this : http://forum.unity3d.com/attachment.php?attachmentid=16700&d=1295270009

And if you want to make it softer aand if you have PRO licence, you might as well want to use this shader instead of the material inside that package:

Shader "MyShaders/FoggyGround" {
 Properties {
  _Color ("Main Color", Color) = (1,1,1,1)
  _MainTex ("Base (RGB)", 2D) = "white" {}
  _InvFade ("Soft Factor", Range(0.01,3.0)) = 1.0
 }
 SubShader {
  Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
  AlphaTest Greater .01
  Cull Off ZWrite Off
  LOD 200
  
  CGPROGRAM
  #pragma exclude_renderers gles
  #pragma vertex vert
  #pragma surface surf Lambert alpha
  #include "UnityCG.cginc"

  float4 _Color;
  sampler2D _MainTex;
  sampler2D _CameraDepthTexture;
  float _InvFade;

  struct Input {
   float2 uv_MainTex;
   float4 proj : TEXCOORD;
  };
  
  void vert (inout appdata_full v, out Input o) {
   float4 oPos = mul(UNITY_MATRIX_MVP, v.vertex);
   #if UNITY_UV_STARTS_AT_TOP
    float scale = -1.0;
   #else
    float scale = 1.0;
   #endif
   o.proj.xy = (float2(oPos.x, oPos.y*scale) + oPos.w) * 0.5;
   o.proj.zw = oPos.zw;
   COMPUTE_EYEDEPTH(o.proj.z);
  }

  void surf (Input IN, inout SurfaceOutput o) {
   float sceneZ = LinearEyeDepth (tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(IN.proj)).r);
   float partZ = IN.proj.z;
   float fade = saturate (_InvFade * (sceneZ-partZ));
   half4 tex = tex2D(_MainTex, IN.uv_MainTex);
   o.Albedo = tex.rgb * _Color.rgb;
   o.Alpha = tex.a * _Color.a;
   o.Alpha *= fade * 2.0f;
  }
  ENDCG
 }
 FallBack "Diffuse"
}

Finally, this may not be what you wanted though.

Tnx all for re:
@Aubergine, nice work I was following your work already… great work…

But indeed it was not what i was after…

here is my level so far, download it 'cause it is 180mb (and i did not know how to shrink it…)
http://www.gerwald.nl/Unity/WebPlayer-Polder.html

You see the band on the horizon? not the best… and there is certainly room for growth…

It is called arieal perspective:

More on yoggy`s fogband (dunno why they call him yoggy, he calles himself: forest johnson)
http://forum.unity3d.com/threads/9132-More-Clan-Screens

And indeed no Pro version for me on the “horizon” (pun intended :wink: )
Tnx Y’all

The only possible solution for what you want i can think of is;
whatever your ground object is(the one which needs blending with horizon) must use a smiliar shader like i posted above and fades the texture to the fog texture depending on depth texture which unfortunately require pro and worse is it requires deferred rendering.

However, you can use particles to fake such an illusion i guess.

Edit: Or, why cant you just use normal fog and adjust the color to the horizon color and adjust the distance anyways?

Yes… I figured that you could use particles for such an effect… and i know already that one could use a mesh in the shape of a ring. The problem is, i cannot find a tutorial or something where i can learn to make a fog out of particles. And maybe it is beyond my set of skills, but id like to try. The normal fog; I d tweaked it for a while but i could not get anything near realism or even semi realism. It is nice for objects and buildings 50 meters away or something like that. But not for landscapes… Or maybe you caught me being a Noob… wich in fact I am… But trying so hard not to be one, :wink:

Flat horizons are always problematic, you might want to use some height variation at the horizon and then your fog will work as desired.
Nothin needs to be perfect though.

Whocares? Im a noob as well and im proud of it :stuck_out_tongue:

Hahahah…
I guess you are right in all the points you made… :wink:

Finaly i have found some particles tutorials wich are helping me make smoke, perhaps i could help me to see how i cam make fog:
http://forestjohnson.blogspot.com/search/label/particle%20effects