Files
JJBB/Assets/Project/Shader/CharacterRenderLine.shader
2024-08-23 15:49:34 +08:00

62 lines
1.4 KiB
Plaintext

Shader "Zhanyou/CharacterRenderLine" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
// 角色材质颜色,乘法运算
_Color("Blend Color", Color) = (1, 1, 1, 1)
_AddColor("Additive Color", Color) = (0, 0, 0, 1)
_LightDir("Light Dir", Vector) = (0, 0, 1,0)
_LightColor("Light Color", Color) = (1, 1, 1, 1)
}
SubShader {
Tags { "Queue" = "AlphaTest+10" "RenderType"="Opaque" }
Pass {
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
struct v2f {
float4 pos : SV_POSITION;
float3 normal:NORMAL;
float2 texcoord : TEXCOORD0;
};
sampler2D _MainTex;
float4 _MainTex_ST;
float4 _Color;
float4 _AddColor;
float4 _LightDir;
float4 _LightColor;
v2f vert (appdata_full v)
{
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f, o);
o.pos = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.normal = normalize(v.normal);
return o;
}
fixed4 frag(v2f i) : SV_TARGET
{
float3 lightDir = normalize(_LightDir.xyz);
float d = dot(i.normal, lightDir);
fixed4 col;
col = tex2D(_MainTex, i.texcoord);
col.rgb *= _Color.rgb;
col.rgb += max(0, d)*_LightColor.rgb;
half grow = Luminance(col.rgb);
col = float4(grow, grow, grow, col.a);
col.rgb += _AddColor;
return col;
}
ENDCG
}
}
Fallback "Unlit/Texture"
}