Skip to content

Height fog implementation for Unity. Work in progress

License

Notifications You must be signed in to change notification settings

SanielX/Height-Fog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Height-Fog

Height fog implementation for Unity. Work in progress. This is NOT volumetric fog, it's an image effect. Right now some settings don't actually do anything

How to use

Like any Post Processing V2 shader. Add it as effect to Post Process volume. Though it does not support transparent geometry (And won't do it by default)

To enable support in custom shaders you need to include "HeightFogUsage.hlsl" and then use ApplyFog function. In the end it will look like this

//...
#include "HeightFogUsage.hlsl"
#pragma multi_compile _ HF_FOG_ENABLED HF_LIGHT_ATTEN
//...
struct v2f
{
    float3 wpos : TEXCOORD0;
}
//...//
v2f vert (appdata v)
{
    v2f o;
    //...//
    o.wpos = mul(unity_ObjectToWorld, v.vertex);
    //...//
    return o;
}
//...//

fixed4 frag (v2f i) : SV_Target
{
    fixed4 col = tex2D(_MainTex, i.uv);
    // This won't change color if fog isn't enabled
    col.rgb = ApplyFog(col.rgb, i.wpos);

    return col;
}

You can also try to use this function in surface shaders in "Finilize Color" function. Though I did not test it

Thanks this repository for inverse projection code

About

Height fog implementation for Unity. Work in progress

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published