Getting Started with CG 14:vertex Shader-Geometric transformations-vertex warps

Source: Internet
Author: User
Tags mul

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.