Properties {
_MainColor("MainColor",Color)=(1,1,1,1)
_MainTex ("MainTex", 2D) = "white" {}
_NormalMap("NormalMap",2D)="bump"{}
_ScrollXSpeed("ScrollXSpeed",Range(0,1))=0
_ScrollYSpeed("ScrollYSpeed",Range(0,1))=0
_WaveA("WaveA",Range(0,0.3))=0.1
_WaveB("WaveB",Range(0,5))=1
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Lambert vertex:vert
fixed4 _MainColor;
sampler2D _MainTex;
sampler2D _NormalMap;
float _ScrollXSpeed;
float _ScrollYSpeed;
float _WaveA;
float _WaveB;
struct Input
{
float2 uv_MainTex;
float2 uv_NormalMap;
float2 Normal;
};
void vert(inout appdata_full v)
{
v.vertex.y+=_WaveA*sin((v.vertex.x+v.vertex.z)*_WaveB+_Time.y);
}
void surf (Input IN,inout SurfaceOutput o)
{
fixed2 scrollUV=IN.uv_MainTex;
scrollUV+=float2(_ScrollXSpeed*_Time.y,_ScrollYSpeed*_Time.y);
fixed4 c=tex2D(_MainTex,scrollUV)*_MainColor;
o.Albedo=c.rgb;
o.Alpha=c.a;
fixed2 scrollBumpUV=IN.uv_MainTex;
scrollBumpUV-=float2(_ScrollXSpeed*_Time.y,_ScrollYSpeed*+_Time.y);
o.Normal=UnpackNormal(tex2D(_NormalMap,scrollBumpUV));
}
ENDCG
}
Unity shader 初学 表面着色器 简易模拟水
于 2023-08-08 19:38:27 首次发布