Firstborn/Library/PackageCache/com.unity.postprocessing@3.2.2/PostProcessing/Shaders/Builtins/DeferredFog.shader

66 lines
1.9 KiB
Plaintext
Raw Normal View History

2023-03-28 13:24:16 -04:00
Shader "Hidden/PostProcessing/DeferredFog"
{
HLSLINCLUDE
#pragma multi_compile __ FOG_LINEAR FOG_EXP FOG_EXP2
#include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"
#include "Packages/com.unity.postprocessing/PostProcessing/Shaders/Builtins/Fog.hlsl"
TEXTURE2D_SAMPLER2D(_MainTex, sampler_MainTex);
TEXTURE2D_SAMPLER2D(_CameraDepthTexture, sampler_CameraDepthTexture);
#define SKYBOX_THREASHOLD_VALUE 0.9999
float4 Frag(VaryingsDefault i) : SV_Target
{
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo);
depth = Linear01Depth(depth);
float dist = ComputeFogDistance(depth);
half fog = 1.0 - ComputeFog(dist);
return lerp(color, _FogColor, fog);
}
float4 FragExcludeSkybox(VaryingsDefault i) : SV_Target
{
half4 color = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, i.texcoordStereo);
float depth = SAMPLE_DEPTH_TEXTURE(_CameraDepthTexture, sampler_CameraDepthTexture, i.texcoordStereo);
depth = Linear01Depth(depth);
float skybox = depth < SKYBOX_THREASHOLD_VALUE;
float dist = ComputeFogDistance(depth);
half fog = 1.0 - ComputeFog(dist);
return lerp(color, _FogColor, fog * skybox);
}
ENDHLSL
SubShader
{
Cull Off ZWrite Off ZTest Always
Pass
{
HLSLPROGRAM
#pragma vertex VertDefault
#pragma fragment Frag
ENDHLSL
}
Pass
{
HLSLPROGRAM
#pragma vertex VertDefault
#pragma fragment FragExcludeSkybox
ENDHLSL
}
}
}