我想做的是两个贴图混合 其中的一个图片做旋转的运动
Shader "Unlit/ting"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_Rotate ("Rotate",2D) = "white" {}
_UVScale ("UV缩放", Range(1, 2)) = 1
_RotateSpeed ("RotateSpeed",Range(0,20)) = 5
// _RotatePiv ("RotatePiv",float2(0,0))
}
SubShader
{
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
uniform sampler2D _Rotate; uniform half4 _Rotate_ST;
uniform sampler2D _MainTex; uniform half4 _MainTex_ST;
uniform float _UVScale;
uniform half _RotateSpeed;
struct VertexInput {
half4 vertex : POSITION;
half4 texcoord0 : TEXCOORD0;
};
struct VertexOutput {
half4 pos : SV_POSITION;
half4 uv0 : TEXCOORD0;
};
VertexOutput vert (VertexInput v) {
VertexOutput o = (VertexOutput)0;
o.uv0 = v.texcoord0;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex );
return o;
}
half4 frag(VertexOutput i):COLOR
{
half4 _diffuse_var = tex2D(_MainTex,TRANSFORM_TEX(i.uv0, _MainTex));
half2 uv0 = i.uv0.xy - half2(0.5,0.566);
uv0 = half2(uv0.x*cos(_RotateSpeed * _Time.y) - uv0.y*sin(_RotateSpeed*_Time.y),
uv0.x*sin(_RotateSpeed * _Time.y) + uv0.y*cos(_RotateSpeed*_Time.y) );
uv0 += half2(0.5,0.566);
half4 _rotate_var = tex2D(_Rotate,uv0);
half3 emissive = ((_diffuse_var.rgb*_diffuse_var.a)+(_rotate_var.rgb));
return fixed4(emissive,_diffuse_var.a);
}
ENDCG
}
}
}