Shader "Castle/ColorMix" {
Properties {
// 基本贴图
_MainTex ("Texture Image", 2D) = "white" {}
// 整体提亮
_HighLight("HighLight", Range(0, 1)) = 0.5
// 混入黑白
_Brightness("Brightness", Range(-1, 1)) = 0.5
// 这里是混入各颜色分量
_Color ("Main Color", COLOR) = (1,1,1,1)
}
SubShader {
Pass {
CGPROGRAM

#pragma vertex vert
#pragma fragment frag

uniform sampler2D _MainTex;
uniform float4 _MainTex_ST;
uniform float _HighLight;
uniform float _Brightness;
uniform float4 _Color;

struct vertexInput {
float4 vertex : POSITION;
float4 texcoord : TEXCOORD0;
};
struct vertexOutput {
float4 pos : SV_POSITION;
float4 tex : TEXCOORD0;
};

vertexOutput vert(vertexInput input)
{
vertexOutput output;

output.tex = input.texcoord;
output.pos = mul(UNITY_MATRIX_MVP, input.vertex);
return output;
}

float4 frag(vertexOutput input) : COLOR
{
return tex2D(_MainTex,
_MainTex_ST.xy * input.tex.xy + _MainTex_ST.zw)
+ float4(0.21 * _HighLight, 0.72 * _HighLight, 0.07 *_HighLight, 1.0)
+ float4(_Brightness,_Brightness,_Brightness, 0.0)
+ _Color;
}

ENDCG
}
}
}

posted on 2014-04-03 20:10  陈峰  阅读(722)  评论(0编辑  收藏  举报