Files

60 lines
1.5 KiB
Plaintext

Shader "BlockWorld/Water"
{
// 半透明水面:关深度写入,避免块与块之间互相裁掉
Properties
{
_MainTex ("Atlas", 2D) = "white" {}
_Alpha ("Alpha", Range(0, 1)) = 0.72
}
SubShader
{
Tags { "RenderType" = "Transparent" "Queue" = "Transparent" }
Cull Back
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
float4 _MainTex_ST;
float _Alpha;
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
fixed4 color : COLOR;
};
struct v2f
{
float4 pos : SV_POSITION;
float2 uv : TEXCOORD0;
fixed4 color : COLOR;
};
v2f vert (appdata v)
{
v2f o;
o.pos = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.color = v.color;
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 c = tex2D(_MainTex, i.uv) * i.color;
c.a = _Alpha;
return c;
}
ENDCG
}
}
Fallback "Transparent/Diffuse"
}