post processing
[WindSway-HDRP.git] / Library / PackageCache / com.unity.postprocessing@2.1.6 / PostProcessing / Shaders / Builtins / DeferredFog.shader
blob055fd1f825b4af7e6fbc2539ea18fa1ffb33a8e0
1 Shader "Hidden/PostProcessing/DeferredFog"
3     HLSLINCLUDE
5         #pragma multi_compile __ FOG_LINEAR FOG_EXP FOG_EXP2
6         #include "../StdLib.hlsl"
7         #include "Fog.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
15         {
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);
24         }
26         float4 FragExcludeSkybox(VaryingsDefault i) : SV_Target
27         {
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);
37         }
39     ENDHLSL
41     SubShader
42     {
43         Cull Off ZWrite Off ZTest Always
45         Pass
46         {
47             HLSLPROGRAM
49                 #pragma vertex VertDefault
50                 #pragma fragment Frag
52             ENDHLSL
53         }
55         Pass
56         {
57             HLSLPROGRAM
59                 #pragma vertex VertDefault
60                 #pragma fragment FragExcludeSkybox
62             ENDHLSL
63         }
64     }