-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDepthTestFog.shader
More file actions
47 lines (40 loc) · 1.09 KB
/
DepthTestFog.shader
File metadata and controls
47 lines (40 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
Shader "Image FX/DepthTestFog" {
Properties{
_MainTex("Albedo (RGB)", 2D) = "white" {}
_DepthPower("Depth Amount", Range(0,1)) = 0.5
}
SubShader {
Pass{
//Blend One DstColor
//Blend SrcColor OneMinusDstColor //Esto genera acumulacion de color similar a los efectos de difuminado de metal gear
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
uniform sampler2D _MainTex, _CameraDepthTexture;
uniform sampler2D _FogTex;
fixed _DepthPower;
struct v2f {
float4 pos : SV_POSITION;
fixed4 color : COLOR;
};
v2f vert(appdata_base v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.color.xyz = v.normal * 0.5 + 0.5;
return o;
}
fixed4 frag(v2f_img i) : COLOR{
float4 fog = tex2D(_MainTex, i.uv);
float d = UNITY_SAMPLE_DEPTH(fog);
d = pow(LinearEyeDepth(d), _DepthPower);
float4 c = tex2D(_MainTex, i.uv);
return c * (d * unity_FogColor);
}
ENDCG
}
}
FallBack "Diffuse"
}