o.uv0 = ((v.texcoord0.xy-0.5) * _UVAnimParam/frac(_Time.y)+0.5)*_Main_Textures_ST.xy + _Main_Textures_ST.zw;
o.uv0 -= float2(0.5,0.5);
o.uv0 = float2(o.uv0.x * cos(_RotateSpeed * _Time.x) - o.uv0.y * sin(_RotateSpeed * _Time.x),
o.uv0.x * sin(_RotateSpeed * _Time.x) + o.uv0.y * cos(_RotateSpeed * _Time.x));
o.uv0 += float2(0.5,0.5);
UV中间外扩的变换
//计算uv到中间点的向量(向外扩,反过来就是向里缩)
float2 dv = float2(0.5, 0.5) - i.uv;
//按照屏幕长宽比进行缩放
dv = dv * float2(_ScreenParams.x / _ScreenParams.y, 1);
//计算像素点距中点的距离
float dis = sqrt(dv.x * dv.x + dv.y * dv.y);
//用sin函数计算出波形的偏移值factor
//dis在这里都是小于1的,所以我们需要乘以一个比较大的数,比如60,这样就有多个波峰波谷
//sin函数是(-1,1)的值域,我们希望偏移值很小,所以这里我们缩小100倍,据说乘法比较快,so...
float sinFactor = sin(dis * _distanceFactor + _Time.y * _timeFactor) * _totalFactor * 0.01;
//距离当前波纹运动点的距离,如果小于waveWidth才予以保留,否则已经出了波纹范围,factor通过clamp设置为0
float discardFactor = clamp(_waveWidth - abs(_curWaveDis - dis), 0, 1);
//归一化
float2 dv1 = normalize(dv);
//计算每个像素uv的偏移值
float2 offset = dv1 * sinFactor * discardFactor;
//像素采样时偏移offset
float2 uv = offset + i.uv;
网友评论