Skip to content

Instantly share code, notes, and snippets.

@gamemachine
Last active November 20, 2019 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gamemachine/9a077115f02ba24d7566eb333eb18c03 to your computer and use it in GitHub Desktop.
Save gamemachine/9a077115f02ba24d7566eb333eb18c03 to your computer and use it in GitHub Desktop.
[Header(Fog)]
[Toggle] _ApplyFog("Enable", Float) = 1
_FogColor("Fog Color (RGB)", Color) = (0.5, 0.5, 0.5, 1.0)
_FogStart("Fog Start", Float) = 0.0
_FogEnd("Fog End", Float) = 10.0
#pragma shader_feature _APPLYFOG_ON
fixed4 _FogColor;
float _FogStart;
float _FogEnd;
half3 ApplyFog(half3 col, float pixelZ) {
float fogvar = saturate(1.0 - (_FogEnd - pixelZ) / (_FogEnd - _FogStart));
col.rgb = lerp(col.rgb, _FogColor, fogvar);
return col;
}
#if _APPLYFOG_ON
col = ApplyFog(col, pixelZ);
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment