Shader "_MyShader/8_Animation/2_Water"
{
Properties
{
_MainTex ("MainTex", 2D) = "white" {}
_Color ("Color", COLOR) = (1,1,1,1)
_Magnitude ("Distortion Magnitude", float) = 1.0
_Frequency ("Distortion Frequency", float) = 1.0
_InvWaveLength ("Inverse Wave Length", float) = 10
_Speed ("Speed", float) = 0.5
}
SubShader
{
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RendererType"="Transparent" "DisableBatching"="True"}
Pass
{
Tags { "LightMode"="ForwardBase" }
ZWrite off
Blend SrcAlpha OneMinusSrcAlpha
Cull off
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
float4 _MainTex_ST;
fixed4 _Color;
float _Magnitude;
float _Frequency;
float _InvWaveLength;
float _Speed;
struct a2v {
float4 vertex:POSITION;
float4 texcoord:TEXCOORD;
};
struct v2f {
float4 pos:SV_POSITION;
float2 uv:TEXCOORD1;
};
v2f vert(a2v v){
v2f o;
float4 offset;
offset.yzw=float3(0,0,0);
offset.x = sin(_Frequency * _Time.y + v.vertex.x * _InvWaveLength + v.vertex.y * _InvWaveLength + v.vertex.z * _InvWaveLength) * _Magnitude;
o.pos=mul(UNITY_MATRIX_MVP, v.vertex + offset);
o.uv=TRANSFORM_TEX(v.texcoord,_MainTex);
o.uv += float2(0, _Time.y * _Speed);
return o;
}
fixed4 frag(v2f i):SV_Target{
fixed4 col = tex2D(_MainTex,i.uv);
col.rgb *= _Color.rgb;
return col;
}
ENDCG
}
}
FallBack "Transparent/VertexLit"
}
UnityShader 学习笔记 17 顶点动画之水流
最新推荐文章于 2025-06-02 21:33:51 发布