// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
|
// Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
|
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
|
Shader "Character/Character, In-Game ,Additive"
|
{
|
Properties
|
{
|
_MainTex("Main Texture", 2D) = "white" {}
|
_ChanTex("Add Texture", 2D) = "black" {}
|
|
_FlowColor("FlowColor",Color) = (1,1,1,1)
|
_FlowSpeed("FlowSpeed",Range(0,1)) = 0
|
_FlowIntensity("FlowIntensity",Range(0,2)) = 0
|
_FlowDirectionH("FlowDirectionH",Range(-1,1))=0
|
_FlowDirectionV("FlowDirectionV",Range(-1,1))=0
|
|
_SelfLuminousColor("SelfLuminousColor",Color) = (1,1,1,1)
|
_SelfLuminousSpeed("SelfLuminousSpeed",Range(0,1)) = 0
|
_SelfLuminousIntensity("SelfLuminousIntensity",Range(0,2)) = 0
|
|
_Hit("FlashWhite", Range(0,1)) = 0
|
_BaTi("FlashRed", Range(0,2)) = 0
|
}
|
|
Subshader
|
{
|
|
Tags {
|
"Queue" = "Geometry"
|
"IgnoreProjector" = "True"
|
"LightMode" = "ForwardBase"
|
}
|
|
Pass
|
{
|
Cull Off
|
Fog {Mode Off}
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
CGPROGRAM
|
#pragma target 3.0
|
#pragma vertex vert
|
#pragma fragment frag
|
|
#pragma multi_compile_fwdbase
|
#pragma multi_compile QUALITY_LOW QUALITY_MED QUALITY_HGH
|
|
#pragma exclude_renderers flash
|
|
#include "UnityCG.cginc"
|
#include "SnxxzCG.cginc"
|
|
#if !defined (SHADOWS_OFF)
|
#include "AutoLight.cginc"
|
#endif
|
|
struct vertexInput
|
{
|
half4 vertex : POSITION;
|
half3 normal : NORMAL;
|
half4 tangent : TANGENT;
|
half2 texcoord : TEXCOORD0;
|
};
|
|
struct vertShader
|
{
|
// basics
|
half4 pos : SV_POSITION;
|
half2 uv1 : TEXCOORD0;
|
|
// frag lighting
|
#ifdef QUALITY_HGH
|
half3 spc : TEXCOORD2;
|
half3 rim : TEXCOORD3;
|
half shd : TEXCOORD4;
|
half3 lgt : TEXCOORD5;
|
half3 ref : TEXCOORD6;
|
#endif
|
#ifdef QUALITY_MED
|
half3 spc : TEXCOORD2;
|
half3 rim : TEXCOORD3;
|
half shd : TEXCOORD4;
|
half3 lgt : TEXCOORD5;
|
#endif
|
#ifdef QUALITY_LOW
|
//half3 spc : TEXCOORD2;
|
//half3 rim : TEXCOORD3;
|
//half shd : TEXCOORD4;
|
half3 lgt : TEXCOORD5;
|
#endif
|
|
#if !defined (SHADOWS_OFF)
|
SHADOW_COORDS(7)
|
#endif
|
|
};
|
// assets
|
uniform sampler2D _MainTex;
|
uniform sampler2D _ChanTex;
|
|
// properties
|
uniform half _Hit;
|
uniform half _BaTi;
|
|
vertShader vert(vertexInput v)
|
{
|
vertShader o;
|
|
// pos and uv tex coord
|
o.pos = UnityObjectToClipPos(v.vertex);
|
o.uv1 = v.texcoord;
|
|
// frag lighting
|
#ifdef QUALITY_HGH
|
half3 worldVertex = mul(unity_ObjectToWorld, v.vertex).xyz;
|
half3 worldNormal = normalize(mul(half4 (v.normal, 0.0), unity_WorldToObject).xyz);
|
half3 lightDirect = normalize(_WorldSpaceLightPos0.xyz);
|
half dotprod = max(0, dot(v.normal, normalize(ObjSpaceViewDir(v.vertex))));
|
o.spc = pow(dotprod, 10) * _Gbl_Spc;
|
o.rim = pow(1 - dotprod, 2) * _Gbl_Rim;
|
o.shd = max(0, dot(worldNormal, lightDirect));
|
o.ref = reflect(normalize(worldVertex - _WorldSpaceCameraPos), worldNormal);
|
#endif
|
#ifdef QUALITY_MED
|
half3 worldVertex = mul(unity_ObjectToWorld, v.vertex).xyz;
|
half3 worldNormal = normalize(mul(half4 (v.normal, 0.0), unity_WorldToObject).xyz);
|
half3 lightDirect = normalize(_WorldSpaceLightPos0.xyz);
|
half dotprod = max(0, dot(v.normal, normalize(ObjSpaceViewDir(v.vertex))));
|
o.spc = pow(dotprod, 10) * _Gbl_Spc;
|
o.rim = pow(1 - dotprod, 2) * _Gbl_Rim;
|
o.shd = max(0, dot(worldNormal, lightDirect));
|
#endif
|
#ifdef QUALITY_LOW
|
//half3 worldNormal = normalize ( mul ( half4 ( v.normal, 0.0 ), _World2Object ).xyz );
|
//half3 lightDirect = normalize(_WorldSpaceLightPos0.xyz);
|
//half dotprod = max ( 0, dot ( v.normal, normalize ( ObjSpaceViewDir ( v.vertex ) ) ) );
|
//o.spc = pow ( dotprod, 10 ) * _Gbl_Spc * 0.1;
|
//o.rim = pow ( 1 - dotprod, 2 ) * _Gbl_Rim;
|
//o.shd = max ( 0, dot ( worldNormal, lightDirect ) );
|
#endif
|
|
//half hit = max ( 0, _Hit * pow ( 1.0 - max ( 0, dot ( v.normal, normalize ( ObjSpaceViewDir ( v.vertex ) ) ) ), 3 ) ); // hit effect
|
half hit = _Hit;
|
half3 bati = half3(_BaTi,0,0) *sin(_Time.x * 60);
|
o.lgt = 0.6 + hit + bati * bati;
|
|
#if !defined (SHADOWS_OFF)
|
TRANSFER_SHADOW(o);
|
#endif
|
|
return o;
|
}
|
|
fixed4 _FlowColor;
|
fixed _FlowSpeed;
|
fixed _FlowDirectionH;
|
fixed _FlowDirectionV;
|
fixed _FlowIntensity;
|
|
fixed4 _SelfLuminousColor;
|
fixed _SelfLuminousSpeed;
|
fixed _SelfLuminousIntensity;
|
|
fixed4 frag(vertShader i) : SV_Target {
|
|
// textures
|
fixed4 inputColor= tex2D(_MainTex, i.uv1);
|
fixed3 outcolor = inputColor.rgb;
|
fixed a = inputColor.a;
|
|
fixed3 channels = tex2D(_ChanTex, i.uv1);
|
|
// channels
|
#ifndef QUALITY_LOW
|
|
#endif
|
|
// phong shadows
|
#ifdef QUALITY_HGH
|
fixed shdlight = smoothstep(0.2, 0.3, i.shd * channels.b);
|
#endif
|
#ifdef QUALITY_MED
|
fixed shdlight = step(0.25, i.shd * channels.b);
|
#endif
|
#ifdef QUALITY_LOW
|
//fixed shdlight = i.shd;
|
#endif
|
|
// realtime shadows
|
#ifndef QUALITY_LOW
|
#if !defined (SHADOWS_OFF)
|
shdlight *= SHADOW_ATTENUATION(i);
|
#endif
|
#endif
|
|
// spec, rim
|
#ifdef QUALITY_HGH
|
fixed3 spclight = i.spc * channels.rrr;
|
fixed3 rimlight = i.rim * channels.bbb;
|
#endif
|
#ifdef QUALITY_MED
|
fixed3 spclight = i.spc * channels.rrr;
|
fixed3 rimlight = i.rim * channels.bbb;
|
#endif
|
#ifdef QUALITY_LOW
|
#endif
|
|
// composite
|
#ifdef QUALITY_HGH
|
outcolor *= 0.2 + _Gbl_Amb + _Gbl_Lgt * shdlight;
|
outcolor *= spclight + rimlight + i.lgt;
|
#endif
|
#ifdef QUALITY_MED
|
outcolor *= 0.2 + _Gbl_Amb + _Gbl_Lgt * shdlight;
|
outcolor *= spclight + rimlight + i.lgt;
|
#endif
|
#ifdef QUALITY_LOW
|
outcolor *= 0.2 + _Gbl_Amb + _Gbl_Lgt;
|
outcolor *= i.lgt;
|
#endif
|
|
fixed timeadd = _Time.x * _FlowSpeed * 100;
|
|
fixed uvshiftH =(timeadd - floor(timeadd)) *_FlowDirectionH;
|
fixed uvshiftV = (timeadd - floor(timeadd)) *_FlowDirectionV;
|
|
fixed channelsB = tex2D(_ChanTex, i.uv1+fixed2(uvshiftH, uvshiftV)).b;
|
outcolor += _FlowColor*channels.r*channelsB*_FlowIntensity;
|
|
outcolor += _SelfLuminousColor*channels.g*(sin(_Time.x * _SelfLuminousSpeed * 200)*0.5 + 0.5)*_SelfLuminousIntensity;
|
|
clip(a - 0.01);
|
return fixed4(outcolor.rgb, a);
|
}
|
|
ENDCG
|
}
|
}
|
FallBack "Diffuse"
|
}
|