标签:优化 unit lan cgi ini users return 旋转 rac
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){ //---------------------旋转xz面顶点start----------------------------- /* float angle = length(v.vertex)*_SinTime.w; //沿y轴旋转矩阵: 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); //优化计算 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; */ //---------------------旋转xz面顶点end----------------------------- //---------------------缩放xz面顶点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); //优化计算,不知道为什么不对? //float x = (sign(angle)/2+0.5)*v.vertex.x; //---------------------缩放xz面顶点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 } } }
Cg入门14:Vertex Shader - 几何变换 —顶点扭曲
标签:优化 unit lan cgi ini users return 旋转 rac
原文地址:http://www.cnblogs.com/wzzkaifa/p/7300818.html