[置顶] Cg入门15:Vertex Shader - 几何变换 —波

Shader "Sbin/vf36" {
	SubShader {
		
		pass{
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag

			#include "UnityCG.cginc"

			struct v2f{
				float4 pos : POSITION;
				float4 col : COLOR;
			};

			v2f vert(appdata_base v){
				//v.vertex.y += sin(-length(v.vertex.xz)+_Time.y)/2;
				
				v.vertex.y +=sin((v.vertex.x+v.vertex.z)+_Time.y)/2;
				v.vertex.y +=sin((v.vertex.x-v.vertex.z)+_Time.y)/2;
				
				v2f o;
				o.pos = mul(UNITY_MATRIX_MVP,v.vertex);
				o.col = fixed4(0,v.vertex.y,1,1);

				return o;
			}
			
			fixed4 frag(v2f v):COLOR
			{
				return v.col;
			}

			ENDCG
		}
	} 
}
  
  
  
  
石头丢进水里效果:
[置顶] Cg入门15:Vertex Shader - 几何变换 —波_第1张图片
xz方向水波纹效果:
[置顶] Cg入门15:Vertex Shader - 几何变换 —波_第2张图片


你可能感兴趣的:([置顶] Cg入门15:Vertex Shader - 几何变换 —波)