Skip to content

Instantly share code, notes, and snippets.

@gamemachine

gamemachine/crestfog.cginc

Last active Nov 20, 2019
Embed
What would you like to do?
[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