看了shader一段时间,都没时间去真用到,今天策划说要做条河流以后。灵感以前貌似做过。趁有时间写个简单的。
Shader "xinghua/Water" {
Properties {
//名字(UI显示名字, 属性) = 初始化值
_WaterTexture("Water Texture" , 2D) = "white"{}
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
// Physically based Standard lighting model, and enable shadows on all light types
//使用Lamert光照模型
#pragma surface surf Lambert
// Use shader model 3.0 target, to get nicer looking lighting
#pragma target 3.0
//声明变量
sampler2D _WaterTexture;
struct Input {
float2 uv_WaterTexture;
};
void surf (Input IN, inout SurfaceOutput o) {
//思路就是不断改变UV坐标
//拿到UVPos
float2 WaterUVPos = IN.uv_WaterTexture;
float X = 1 * _Time;
float Y = 2 * _Time;
WaterUVPos += float2(X,Y);
float4 c = tex2D(_WaterTexture,WaterUVPos);
//显示
o.Albedo = c.rgb;
}
ENDCG
}
FallBack "Diffuse"
}