shader:平移旋转和缩放uv
//pannerUV
float2 pannerUV = (i.uv0+(_Time*_speed)*float2(0,0.2)); // panner
float4 my_MainTexture = tex2D(_MainTexture,TRANSFORM_TEX(pannerUV, _MainTexture));
float3 Finalcolor = my_MainTexture.rgb;
return fixed4(Finalcolor,1);
图片
图片
以上shaderfoge,ase编辑器的rotator都是封包了的,你双击也没卵用,打不开节点, 下面给出源码function。
图片
//rotateUV
float my_cos = cos(1.0*(_Time*_speed));
float my_sin = sin(1.0*(_Time*_speed));
float2 My_RotateCenter= float2(0.5,0.5);
float2 rotateUV = (mul(i.uv0-My_RotateCenter,float2x2( my_cos, -my_sin, my_sin, my_cos))+My_RotateCenter); // rotate
float4 my_MainTexture = tex2D(_MainTexture,TRANSFORM_TEX(rotateUV, _MainTexture));
float3 finalColor = my_MainTexture.rgb;
return fixed4(finalColor,1);
图片
图片
以上shaderfoge,ase编辑器的rotator都是封包了的,你双击也没卵用,打不开节点, 下面给出源码function。
图片
//ScaleUV
float My_ScaleCenter = 1.0;// Actor
float2 ScaleUV = lerp(i.uv0,float2(My_ScaleCenter ,My_ScaleCenter ),fmod((_Time*_speed),1.0)); // scale
float4 my_MainTexture = tex2D(_MainTexture,TRANSFORM_TEX(ScaleUV, _MainTexture));
float3 finalColor = my_MainTexture.rgb;
return fixed4(finalColor,1);
缩放源码连接图
图片
图片
//扭曲效果
fixed2 uv = i.uv - fixed2(0.5,0.5);
float angle = _Speed * 0.1745/(length(uv) + 0.1);//加0.1是放置length(uv)为0
float angle2 = angle * _Time.y;
uv = float2(uv.x*cos(angle2)-uv.y*sin(angle2),uv.y*cos(angle2)+uv.x*sin(angle2));
uv+=fixed2(0.5,0.5);
fixed4 c = tex2D(_MainTex,uv);
return c;
扭曲源码连接图: |