Skip to content

Instantly share code, notes, and snippets.

@s2kw
Last active March 1, 2016 07:39
Show Gist options
  • Save s2kw/48d0e062a6945b879192 to your computer and use it in GitHub Desktop.
Save s2kw/48d0e062a6945b879192 to your computer and use it in GitHub Desktop.
/*-------------------------------------------------
System Designed,
Code Written,
by Kunihiro Sasakawa as [email protected]
-------------------------------------------------*/
Shader "SkyCircus/RimEmission"
{
Properties
{
_RimEmissionColor("_RimEmissionColor", Color) = (0.0,1.0,0.0,1.0)
_EmissionPower("_EmissionPower",Range(0,5.0) ) = 1
_InColor("_InSideColor",Color ) = (1.0,0.0,0.0,1.0)
_InPower("_InPower", Range(0.0,5.0) ) = 1.2
_OutColor("_OutSideColor",Color ) = (0.0,1.0,0.0,1.0)
_OutPower("_OutPower", Range(0,5.0) ) = 0.0
_Strength("_Strength", Range(0.0,5.0) ) = 1.5
_AlphaFactor("_AlphaFactor",Range(0.0,2.0)) = 0.5
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
}
Cull Back // 裏返し
ZWrite On
ZTest LEqual
CGPROGRAM
//#pragma surface surf BlinnPhongEditor alpha vertex:vert
#pragma surface surf BlinnPhong alpha
#pragma target 3.0
#include "UnityCG.cginc"
fixed4 _RimEmissionColor;
fixed _OutPower;
fixed _InPower;
fixed _AlphaFactor;
fixed _EmissionPower;
fixed _Strength;
fixed4 _InColor;
fixed4 _OutColor;
//struct SurfaceOutput
//{
// half3 Albedo;
// half3 Normal;
// half3 Emission;
// half3 Gloss;
// half Specular;
// half Alpha;
// half Custom;
//};
struct Input
{
float4 screenPos;
float3 viewDir;
float2 uv_Texture;
float3 worldRefl;
INTERNAL_DATA
};
void surf (Input IN, inout SurfaceOutput o)
{
o.Albedo = fixed3(0.0,0.0,0.0);
o.Normal = fixed3(0.0,0.0,1.0);
o.Gloss = 0.0;
o.Specular = 0.0;
fixed3 Fresnel0 = fixed3(0,0,1.0); //角度
fixed f = 1.0 - dot( normalize( IN.viewDir ), Fresnel0 );
float4 Fresnel1 = float4( f,f,f,f );
float4 Step0 = step( Fresnel1,float4( 1.0,1.0,1.0,1.0 ));
float4 Clamp0 = clamp( Step0, _OutPower.xxxx, float4( 1.0,1.0,1.0,1.0 ));
float4 Pow0 = pow(Fresnel1,_InPower.xxxx);
float4 Multiply0 = Pow0 * _Strength.xxxx;
float4 Multiply1 = Clamp0 * Multiply0;
float progress = 1f - Multiply1.w * _RimEmissionColor.a;
o.Emission = Multiply1.xyz * _RimEmissionColor.rgb * _EmissionPower.xxx;
fixed4 color = lerp( _OutColor, _InColor , progress);
o.Albedo = color;
o.Alpha = color.a * _AlphaFactor;
}
ENDCG
}
Fallback "Diffuse"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment