Shader "Custom/MyWater" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_Color ("Main Color", COLOR) = (1,1,1,1)
}
SubShader {
Pass {
Tags { "RenderType"="Transparent" "Queue"="AlphaTest" }
ZWrite off
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
fixed4 _Color;
float4 _MainTex_ST;
sampler2D _CameraDepthTexture;
struct v2f {
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
float4 screenPos : TEXCOORD1;
};
v2f vert (appdata_base v)
{
v2f o;
o.pos = mul (UNITY_MATRIX_MVP, v.vertex);
o.screenPos = ComputeScreenPos(o.pos);
o.uv = TRANSFORM_TEX (v.texcoord, _MainTex);
return o;
}
float4 frag (v2f i) : COLOR
{
float depth = UNITY_SAMPLE_DEPTH(tex2Dproj(_CameraDepthTexture, UNITY_PROJ_COORD(i.screenPos)));
depth = LinearEyeDepth(depth);
return float4(depth.xxx, 1);
//float4 texcol = tex2D (_MainTex, i.uv);
//return texcol * _Color;
}
ENDCG
}
}
Fallback "VertexLit"
}