1 Shader "Hidden/PostProcessing/DeferredFog"
5 #pragma multi_compile __ FOG_LINEAR FOG_EXP FOG_EXP2
6 #include "../StdLib.hlsl"
9 TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
10 TEXTURE2D_SAMPLER2D(_CameraDepthTexture, sampler_CameraDepthTexture);
12 #define SKYBOX_THREASHOLD_VALUE 0.9999
14 float4 Frag(VaryingsDefault i) : SV_Target
16 half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
18 float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo);
19 depth = Linear01Depth(depth);
20 float dist = ComputeFogDistance(depth);
21 half fog = 1.0 - ComputeFog(dist);
23 return lerp(color, _FogColor, fog);
26 float4 FragExcludeSkybox(VaryingsDefault i) : SV_Target
28 half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
30 float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo);
31 depth = Linear01Depth(depth);
32 float skybox = depth < SKYBOX_THREASHOLD_VALUE;
33 float dist = ComputeFogDistance(depth);
34 half fog = 1.0 - ComputeFog(dist);
36 return lerp(color, _FogColor, fog * skybox);
43 Cull Off ZWrite Off ZTest Always
49 #pragma vertex VertDefault
59 #pragma vertex VertDefault
60 #pragma fragment FragExcludeSkybox