Shader "Sbin/BlendTexAnimShader"{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
_SecondTex ("Texture", 2D) = "white" {}
_F("F",Range(0,10))=4
}
SubShader
{
Pass
{
colormask rgba//只准許輸出紅色
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MainTex;
sampler2D _SecondTex;
float _F;
struct v2f{
float4 pos:POSITION;
float2 uv:TEXCOORD0;
};
v2f vert (appdata_base v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.uv = v.texcoord.xy;
return o;
}
fixed4 frag (v2f v) : COLOR
{
//用一張紋理實現:會動的星空效果
//===========================================
//float2 uv = v.uv;
//float offset_uv = 0.05*sin(v.uv*_F + _Time.x*2);
//uv +=offset_uv;
//fixed4 col1 = tex2D(_MainTex, uv);
//uv = v.uv;
//uv -=offset_uv;
//fixed4 col2 = tex2D(_MainTex, uv);
//return (col1+col2)/2;
//===========================================
//使用兩張紋理實現:湖面會動的星空效果
//===========================================
//fixed4 mainColor = tex2D(_MainTex, v.uv);
//float offset_uv = 0.05*sin(v.uv*_F + _Time.x*2);
//float2 uv = v.uv + offset_uv;
//fixed4 secondColor = tex2D(_SecondTex, uv);
//mainColor.rgb += secondColor;
//return mainColor/2;
//===========================================
//只輸出制定顏色通道
//===========================================
fixed4 mainColor = tex2D(_MainTex, v.uv);
float offset_uv = 0.05*sin(v.uv*_F + _Time.x*2);
float2 uv = v.uv + offset_uv;
fixed4 secondColor = tex2D(_SecondTex, uv);
mainColor.rgb *= secondColor.b;
return mainColor;
}
ENDCG
}
}
}
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。