Shader "Unlit/WaterEffect"
{
Properties {
_MainTex("Base 2D", 2D) = "white"{}
_Color("Color",Color) = (1,1,1,1)
}
SubShader {
Tags{"Queue"="Transparent" "RenderType" = "Opaque"}
Pass
{
Blend SrcAlpha One//打开混合模式
ZWrite off
Lighting off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "Lighting.cginc"
struct appdata
{
float4 vertex:POSITION;
float3 normal:Normal;
};
struct v2f {
float4 vertex:SV_POSITION;
float4 color:COLOR;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _Color;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
float3 viewDir = normalize(ObjSpaceViewDir(v.vertex));//计算出顶点到相机的向量
float val = 1 - saturate(dot(v.normal, viewDir));//计算点乘值
o.color = _Color * val;
return o;
}
fixed4 frag(v2f i): COLOR
{
return i.color;
}
ENDCG
}
}
FallBack "Diffuse"
}