캐릭터 쉐이더 백업

캐릭터 쉐이더 재작업으로 인해, 기존 쉐이더 백업

Shader “AT2/Char/Main” {

Properties {

 _Color (“Main Color”, Color) = (1,1,1,1)

 _SpecColor (“Specular Color”, Color) = (0.5, 0.5, 0.5, 1)

 _Shininess (“Shininess (Normal.b)”, Range (0.01, 1)) = 0.078125

 _SpecColor1 (“Camera Direct SpecColor (Only Forward)”, Color) = (0.5, 0.5, 0.5, 1)

 _Shininess1 (“Camera Direct Shininess (Only Forward : Normal.b)”, Range (0.01, 1)) = 0.078125

 _MainTex (“Base (RGB) Alpha (A)”, 2D) = “white” {}

 _Normalmap (“Normalmap”, 2D) = “bump” {}

 _EmissionLM (“Emission (Lightmapper)”, Float) = 0

 _UpperGlobalLight (“UpperGlobalLight”,Color)=(0.0,0.0,0.0,1)

 _LowerGlobalLight (“LowerGlobalLight”,Color)=(0.0,0.0,0.0,1)

 _RimColor (“Rim Color”, Color) = (0.26,0.19,0.16,0.0)

 _RimPower (“Rim Power”, Range(0.5,8.0)) = 3.0

 _Reflection (“Reflection Texture”, CUBE) = “grey” {}

 //~ _Cutoff (“Alpha cutoff”, Range (0,1)) = 0.0

}

SubShader {

 //Tags{“Queue”=“AlphaTest” “IgnoreProjector”=“True” “RenderType”=“TransparentCutout”}

 Tags{

  “RenderType”=“Opaque”

  }

 LOD 600

 Cull Off

 ZWrite On

 //AlphaTest Greater [_Cutoff]

CGPROGRAM

#pragma surface surf BlinnPhong alphatest:_Cutoff    vertex:vert

#include “UnityCG.cginc”

#pragma target 3.0 // it’s for prevent “arithmetic instruction limit” -JP-

#pragma only_renderers d3d9

sampler2D _MainTex;

sampler2D _Normalmap;

samplerCUBE _Reflection;

float4 _UpperGlobalLight;

float4 _LowerGlobalLight;

float4 _Color;

//~ float4  _SpecColor; //  Declare previous (another file)

float _Shininess;

float4  _SpecColor1;

float _Shininess1;

float4 _RimColor;

float _RimPower;

struct Input {

 float2 uv_MainTex;

 float2 uv_Normalmap;

 float3 viewDir;

 float3 viewDirWorld : TEXCOORD2;

 float3 LightDirWorld : TEXCOORD3;

 float3 normalWS : TEXCOORD4;

 float3 tangentWS : TEXCOORD5;

};

void vert (inout appdata_full v, out Input o)

   {

  o.viewDirWorld = mul( (float3x3)_Object2World, -ObjSpaceViewDir( v.vertex ) );

  // we transform the normal and tangent in world space as well

  o.normalWS = mul( _Object2World, float4(v.normal,0) ).xyz;

  o.tangentWS = mul( _Object2World, float4(v.tangent.xyz,0) ).xyz;

  o.LightDirWorld = WorldSpaceLightDir( v.vertex );

  }

void surf (Input IN, inout SurfaceOutput o) {

 //Main Texture

 float4 tex = tex2D(_MainTex, IN.uv_MainTex);

 float4 c = tex * _Color;

 o.Albedo = c.rgb;

 // Make Normal :  World Nomal

 float4 NormalTex = tex2D (_Normalmap, IN.uv_Normalmap);

 o.Normal =  (float3(NormalTex.r,NormalTex.g,1)*2.0f-1.0f);

 o.Normal = normalize(float3(o.Normal.r,o.Normal.g,o.Normal.b));

 float3 binormalWS = cross( IN.normalWS, IN.tangentWS ) ;

 float3 WorldNormal;

 // Make World Nomal : Normal Inverse Test

  if ( 1.0 == sign(IN.uv_Normalmap.x-1.0f) )

  {

   WorldNormal= o.Normal .x * normalize(IN.tangentWS);

   WorldNormal += -o.Normal .y * normalize(binormalWS);

  }

  else

  {

   WorldNormal= o.Normal .x * normalize(IN.tangentWS);

   WorldNormal += o.Normal .y * normalize(binormalWS);

  }

  WorldNormal += o.Normal .z * normalize(IN.normalWS);

  WorldNormal= normalize(WorldNormal);

 // Make GI Color

 float GITerm =saturate(dot(WorldNormal, float3(0,1,0))*0.5+0.5);

 float GITermInv =saturate(dot(WorldNormal, float3(0,-1,0))*0.5+0.5);

 float3 GIColor = (_UpperGlobalLight.rgb* GITerm ) + (_LowerGlobalLight.rgb * GITermInv );

 // Make second Specular

 half3 h = normalize(  WorldNormal - IN.viewDirWorld );

 float nh = saturate( dot( h, WorldNormal ) );

 float spec = pow( nh, _Shininess1 *256) *NormalTex.b ;

 float3 CameraSpecColor =_SpecColor1.rgb * GIColor * spec;

 // Make Rim Light

 float Fresnel= 1.0 - abs(dot( normalize( float4(-IN.viewDirWorld, 1.0).xyz), WorldNormal) ) ;

 float rim = (pow(saturate(Fresnel+ 0.3)  ,_RimPower)) ;

 float3 rimlight = rim* _RimColor.rgb * GIColor;

 // Reflection

 float3 reflectVec = reflect( IN.viewDirWorld ,WorldNormal);

 float3 ReflectTex = texCUBE (_Reflection, reflectVec ).rgb;

 ReflectTex *= 1-NormalTex.a;

 o.Albedo = lerp (c.rgb, ((ReflectTex*3) * (c.rgb*0.5)  ), 1-NormalTex.a) ;

 o.Emission = (c.rgb * GIColor)+CameraSpecColor + (rimlight*0.8);

 o.Gloss = NormalTex.b;

 o.Alpha =  1;//tex.a* _Color.a;

 o.Specular = _Shininess  ;

}

ENDCG

}

FallBack “Self-Illumin/Specular”

}

Hugo로 만듦
JimmyStack 테마 사용 중