popcorn/Shader/3D/UnlitUVScrollAdditiveRimAdd...

87 lines
2.6 KiB
Plaintext

Shader "UsayaLib/3D/Unlit/UVScrollAdditiveRimAdditive" {
Properties {
_TintColor ("Tint Color", Color) = (0.5, 0.5, 0.5, 0.5)
_MainTex ("Base (RGB)", 2D) = "white" { }
_ScrollX ("Scroll X", float) = 0
_ScrollY ("Scroll Y", float) = 0
_RimColor ("Rim color", Color) = (1, 1, 1, 1)
_RimEffect ("Rim effect", Range(0, 1)) = 0
}
SubShader {
Tags {
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Blend SrcAlpha One
Cull Off
ZWrite Off
Fog {
Mode Off
}
Pass {
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_particles
#pragma multi_compile_fog
#include "UnityCG.cginc"
fixed4 _TintColor;
sampler2D _MainTex;
float4 _MainTex_ST;
float _ScrollX;
float _ScrollY;
fixed4 _RimColor;
fixed _RimEffect;
struct appdata_t {
float4 vertex: POSITION;
float4 texcoord: TEXCOORD0;
fixed4 color: COLOR;
float3 normal : NORMAL;
};
struct v2f {
float4 vertex: SV_POSITION;
float2 texcoord: TEXCOORD0;
float3 viewDir : TEXCOORD1;
fixed4 color: COLOR;
float3 normal : NORMAL;
UNITY_FOG_COORDS(1)
};
v2f vert(appdata_t v){
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
o.texcoord.x = o.texcoord.x + _ScrollX * _Time.y;
o.texcoord.y = o.texcoord.y + _ScrollY * _Time.y;
o.viewDir = normalize(ObjSpaceViewDir(v.vertex));
o.color = 2.0 * v.color * _TintColor;
o.normal = UnityObjectToWorldNormal(v.normal);
UNITY_TRANSFER_FOG(o, o.vertex);
return o;
}
fixed4 frag(v2f i): SV_Target {
fixed4 col = i.color * tex2D(_MainTex, i.texcoord);
float val = 1 - abs(dot(i.viewDir, i.normal)) * _RimEffect;
fixed4 rim = _RimColor * _RimColor.a * val * val;
col += rim;
UNITY_APPLY_FOG_COLOR(i.fogCoord, col, (fixed4)0);
return col;
}
ENDCG
}
}
Fallback off
}