Shader "Custom/WaterRippleShader"{ // Shader 檔名
Properties{
_MainTex("Base (RGB)", 2D) = "white" {} // Textrue2D 貼圖 (公開)
_Scale ("Scale", float) = 1 // Shader Scale (float)數值輸入(公開)
_Speed("Speed", float) = 1 // Shader Speed (float)數值輸入(公開)
_Frequency("Frequency", float) = 1 // Shader Frequency (float)數值輸入(公開)
}
SubShader{
Tags {"RenderType" = "Opaque"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert vertex:vert
sampler2D _MainTex;
float _Scale, _Speed, _Frequency;
struct Input{
float2 uv_MainTex;
};
void vert(inout appdata_full v) {
half offsetvert = v.vertex.x;
half value = _Scale * sin(_Time.w * _Speed + offsetvert * _Frequency);
v.vertex.y += value;
}
void surf(Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
-------------------------------------
改變座標後:
Shader "Custom/WaterRippleShader"{ // Shader 檔名
Properties{
_MainTex("Base (RGB)", 2D) = "white" {} // Textrue2D 貼圖 (公開)
_Scale ("Scale", float) = 1 // Shader Scale (float)數值輸入(公開)
_Speed("Speed", float) = 1 // Shader Speed (float)數值輸入(公開)
_Frequency("Frequency", float) = 1 // Shader Frequency (float)數值輸入(公開)
}
SubShader{
Tags {"RenderType" = "Opaque"}
LOD 200
CGPROGRAM
#pragma surface surf Lambert vertex:vert
sampler2D _MainTex;
float _Scale, _Speed, _Frequency;
struct Input{
float2 uv_MainTex;
};
void vert(inout appdata_full v) {
half offsetvert = (v.vertex.x * v.vertex.x) + (v.vertex.z * v.vertex.z);
half value = _Scale * sin(_Time.w * _Speed + offsetvert * _Frequency);
v.vertex.y += value;
}
void surf(Input IN, inout SurfaceOutput o) {
half4 c = tex2D(_MainTex, IN.uv_MainTex);
o.Albedo = c.rgb;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
沒有留言:
張貼留言