Mul (UNITY_MATRIX_MVP, Uppos):parameter Descriptionby the first parameter UNITY_MATRIX_MVP Matrix to affect the second parameter Uppos vector (or matrix)
Shader "Sbin/vf35" {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) {//---------------------rotate the xz face vertex start-----------------------------/*float angle = Length ( V.vertex) *_sintime.w;//rotates the matrix along the y axis: float4x4 m = {float4 (cos (angle), 0,sign (angle), 0), FLOAT4 (0,1,0,0), Float4 (-sign ( Angle), 0,cos (angle), 0), FLOAT4 (0,0,0,1)};v.vertex = Mul (M,v.vertex);//optimization calculation float x = v.vertex.x*cos (angle) +v.vertex.z *sign (angle); float z = v.vertex.x*-sign (angle) +v.vertex.z*cos (angle); v.vertex.x = X;v.vertex.z = z;*///-------------- -------rotate the xz face vertex end-----------------------------//--------------------- Zoom XZ polygon vertex start-----------------------------float angle = v.vertex.z + _time.y;float4x4 sm = {sin (angle)/8+ 0.5,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1,};v.vertex = Mul (Sm,v.vertex);//optimization calculation, do not know why is not correct? float x = (sign (angle)/2+0.5) *v.vertex.x;//---------------------zoom XZ face vertex start-----------------------------v2f o;o . pos = Mul (UNITY_matrix_mvp,v.vertex); o.col = Fixed4 (0,1,1,1); return o;} Fixed4 Frag (v2f v): Color{return V.col;} ENDCG}}}
Rotate the XZ face vertex effect along the Y axis:
Water Ripple Effect:
Getting Started with CG 14:vertex Shader-Geometric transformations-vertex warps