84 lines
2.2 KiB
Plaintext
84 lines
2.2 KiB
Plaintext
Shader "Zhanyou/AstroCharacter"
|
|
{
|
|
Properties
|
|
{
|
|
_MainTex ("Texture", 2D) = "white" {}
|
|
_LightDir ("Light Direction", Vector) = (1, 1, 1, 0)
|
|
_LightColor ("Light Color", Color) = (1, 1, 1, 1)
|
|
_BlendColor ("Blend Color", Color) = (1, 1, 1, 1)
|
|
_Intensity ("Light Intensity", Float) = 1
|
|
_Emission ("Emission", Float) = 0.2
|
|
//_MinLuminance ("Min Luminance", Float) = 0.2
|
|
_Outline ("Outline Power", float) = 1
|
|
_OutlineColor ("Outline Color", Color) = (1, 1, 1, 1)
|
|
}
|
|
SubShader
|
|
{
|
|
Tags { "Queue"="Transparent-100" "RenderType"="Transparent" "IgnoreProjector"="True" }
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
LOD 100
|
|
|
|
Pass
|
|
{
|
|
CGPROGRAM
|
|
#pragma vertex vert
|
|
#pragma fragment frag
|
|
#include "UnityCG.cginc"
|
|
#include "Gles2Helper.cginc"
|
|
|
|
struct appdata
|
|
{
|
|
float4 vertex : POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
float4 tangent : TANGENT;
|
|
float3 normal : NORMAL;
|
|
};
|
|
|
|
struct v2f
|
|
{
|
|
float4 vertex : SV_POSITION;
|
|
float2 uv : TEXCOORD0;
|
|
float nDotL : TEXCOORD1;
|
|
float rim : TEXCOORD2;
|
|
};
|
|
|
|
uniform sampler2D _MainTex;
|
|
uniform float4 _MainTex_ST;
|
|
uniform half4 _LightDir;
|
|
uniform half4 _LightColor;
|
|
uniform half4 _BlendColor;
|
|
uniform half _Intensity;
|
|
uniform half _Emission;
|
|
//uniform half _MinLuminance;
|
|
uniform half _Outline;
|
|
uniform half4 _OutlineColor;
|
|
|
|
v2f vert (appdata v)
|
|
{
|
|
v2f o;
|
|
o.vertex = UnityObjectToClipPos(v.vertex);
|
|
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
|
|
o.nDotL = dot(v.normal, normalize(_LightDir.xyz));
|
|
half3 objectViewDir = ObjSpaceViewDir(v.vertex);
|
|
TANGENT_SPACE_ROTATION;
|
|
o.rim = saturate(1 - normalize(MUL_3x3_WITH_VECTOR(rotation, objectViewDir)).z);
|
|
o.rim = pow(o.rim, _Outline);
|
|
return o;
|
|
}
|
|
|
|
fixed4 frag (v2f i) : SV_Target
|
|
{
|
|
fixed4 col = tex2D(_MainTex, i.uv);
|
|
//fixed luminance = Luminance(col.rgb);
|
|
//luminance = luminance * (1 - _MinLuminance) + _MinLuminance;
|
|
//col.rgb = luminance;
|
|
col *= _BlendColor;
|
|
col.rgb = col.rgb * _Emission + col.rgb * max(0, i.nDotL) * _LightColor * _Intensity;
|
|
col.rgb += _OutlineColor.rgb * _OutlineColor.a * i.rim;
|
|
return col;
|
|
}
|
|
ENDCG
|
|
}
|
|
}
|
|
}
|