// 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,Spec,Emission,Flow"
|
{
|
Properties
|
{
|
_MainTex ("Main Texture", 2D) = "white" { }
|
_ChanTex ("Spec Texture", 2D) = "white" { }
|
_AddTex ("Add Texture", 2D) = "white" { }
|
[HideInInspector]_NormalTex ("Normal Texture", 2D) = "white" { }
|
|
_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 Back
|
Fog
|
{
|
Mode Off
|
}
|
|
CGPROGRAM
|
|
#pragma target 3.0
|
#pragma vertex vert
|
#pragma fragment frag
|
|
|
#pragma multi_compile_fwdbase
|
|
#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
|
half3 nrm: TEXCOORD1;
|
half3 tng: TEXCOORD2;
|
half3 bin: TEXCOORD3;
|
half3 cam: TEXCOORD4;
|
half3 lgt: TEXCOORD5;
|
half3 ref: TEXCOORD6;
|
|
#if !defined(SHADOWS_OFF)
|
SHADOW_COORDS(7)
|
#endif
|
|
//half1 shd : TEXCOORD5;
|
};
|
// assets
|
uniform sampler2D _MainTex;
|
uniform sampler2D _ChanTex;
|
uniform sampler2D _AddTex;
|
uniform sampler2D _NormalTex;
|
|
// properties
|
uniform half _Hit;
|
uniform half _BaTi;
|
|
vertShader vert(vertexInput v)
|
{
|
vertShader o;
|
half3 worldVertex = mul(unity_ObjectToWorld, v.vertex).xyz;
|
|
// pos and uv tex coord
|
o.pos = UnityObjectToClipPos(v.vertex);
|
o.uv1 = v.texcoord;
|
|
// frag lighting
|
o.nrm = normalize(mul(half4(v.normal, 0.0), unity_WorldToObject).xyz);
|
o.tng = normalize(mul(unity_ObjectToWorld, half4(v.tangent.xyz, 0.0)).xyz);
|
o.bin = normalize(cross(o.nrm, o.tng) * v.tangent.w);
|
o.cam = normalize(WorldSpaceViewDir(v.vertex));
|
o.ref = normalize(worldVertex - _WorldSpaceCameraPos);
|
|
// probes
|
//half2 prb = inlineShadeProbes ( half4 (o.nrm, 1) ); // probes
|
//o.shd = prb.r; //shadowmask
|
|
// hit effect
|
// half hit = max ( 0, _Hit * pow ( 1.0 - max ( 0, dot ( v.normal, normalize ( ObjSpaceViewDir ( v.vertex ) ) ) ), 4 ) ); // hit effect
|
half hit = _Hit;
|
half3 bati = _BaTi * half3(1, 0, 0) * sin(_Time.z * 3);
|
|
// vertex lighting
|
//o.lgt = inlineLights ( worldVertex ) + hit + bati * bati;
|
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
|
fixed3 outcolor = tex2D(_MainTex, i.uv1);
|
fixed3 channels = tex2D(_ChanTex, i.uv1);
|
fixed3 addchannels = tex2D(_AddTex, i.uv1);
|
fixed3 bumpmap = tex2D(_NormalTex, i.uv1);
|
|
// normals
|
fixed3 normRG = fixed3(bumpmap.rg, 1) - fixed3(0.5, 0.5, 0.5);
|
fixed3x3 matrixDIR = half3x3(i.tng, i.bin, i.nrm);
|
fixed3 normDIR = normalize(mul(normRG, matrixDIR));
|
|
// shadows
|
#if !defined(SHADOWS_OFF)
|
fixed shdlight = dot(_WorldSpaceLightPos0, normDIR) * channels.b * min(1, SHADOW_ATTENUATION(i) + bumpmap.b);
|
#else
|
fixed shdlight = dot(_WorldSpaceLightPos0, normDIR) * channels.b;
|
#endif
|
shdlight = smoothstep(0.333, 0.333 + 0.666 * bumpmap.b, shdlight);
|
|
// spec, rim
|
fixed dotprod = max(0, dot(i.cam, normDIR));
|
fixed spclight = pow(dotprod, 30) * channels.r;
|
fixed rimlight = pow(1 - dotprod, 2) * channels.b * 0.5;
|
fixed3 additive = 1 * spclight + 1 * rimlight + i.lgt;
|
|
// composite
|
outcolor *= 0.3 + 1 + 1 * shdlight;
|
outcolor *= 0.6 + additive;
|
|
fixed timeadd = _Time.x * _FlowSpeed * 100;
|
|
fixed uvshiftH = (timeadd - floor(timeadd)) * _FlowDirectionH;
|
fixed uvshiftV = (timeadd - floor(timeadd)) * _FlowDirectionV;
|
|
fixed addChannelsB = tex2D(_AddTex, i.uv1 + fixed2(uvshiftH, uvshiftV)).b;
|
outcolor += _FlowColor * addchannels.r * _FlowIntensity * addChannelsB;
|
|
outcolor += _SelfLuminousColor * addchannels.g * (sin(_Time.x * _SelfLuminousSpeed * 200) * 0.5 + 0.5) * _SelfLuminousIntensity;
|
|
return fixed4(outcolor.rgb, 1);
|
}
|
|
ENDCG
|
|
}
|
}
|
FallBack "Diffuse"
|
}
|