123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- // Unity built-in shader source. Copyright (c) 2016 Unity Technologies. MIT license (see license.txt)
- // Edited by MinionsArt for hologram effect
- Shader "Am/Hologram Effect" {
- Properties{
- _TintColor("Tint Color", Color) = (0,0.5,1,1)
- _RimColor("Rim Color", Color) = (0,1,1,1)
- _MainTex("Main Texture", 2D) = "white" {}
- _GlitchTime("Glitches Over Time", Range(0.01,3.0)) = 1.0
- _WorldScale("Line Amount", Range(1,200)) = 20
-
- //Dissolve Texture
- _DissolveTex("Dissolve Texture", 2D) = "white" { }
- _Height("Dissolve by Height in Local Space", float) = 1
- _DissolveUpDown("Dissolve Up to Down Or Down to Up", float) = 1
- _DissolveSpread("Dissolve Spread", float) = 3
- _DissolveTint("Dissolve Color Tint", Color) = (1.0, 1.0, 1.0, 1.0)
- _LineWidth("Dissolve Board Line Width", float) = 0.1442
- }
- Category{
- Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" "PreviewType" = "Sphere" }
- Blend SrcAlpha OneMinusSrcAlpha
-
- Cull Back
- SubShader
- {
- /*Pass{
- ColorMask 0
- }*/
- Pass{
-
- //ColorMask RGB
-
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma target 2.0
-
- #include "UnityCG.cginc"
-
- sampler2D _MainTex;
- fixed4 _TintColor;
- fixed4 _RimColor;
-
-
- struct appdata_t {
- float4 vertex : POSITION;
- fixed4 color : COLOR;
-
- float2 texcoord : TEXCOORD0;
- float3 normal : NORMAL; // vertex normal
- };
-
- struct v2f {
- float4 vertex : SV_POSITION;
- fixed4 color : COLOR;
- float2 texcoord : TEXCOORD0;
- float3 wpos : TEXCOORD1; // worldposition
- float3 normalDir : TEXCOORD2; // normal direction for rimlighting
- //#if DissolveH
- float3 lightDir : TEXCOORD4;
- float3 viewDir : TEXCOORD5;
- fixed distance : TEXCOORD6;
- //#endif
- };
-
- float4 _MainTex_ST;
- float _GlitchTime;
- float _WorldScale;
- float _OptTime = 0;
-
- //#if DissolveH
- uniform sampler2D _DissolveTex;
- uniform fixed _Height;
- uniform fixed _DissolveSpread;
- uniform fixed3 _DissolveTint;
- uniform fixed _LineWidth;
- uniform fixed _DissolveUpDown;
- //#endif
-
- v2f vert(appdata_t v)
- {
- v2f o;
-
- o.vertex = UnityObjectToClipPos(v.vertex);
-
- // Vertex glitching
- //_OptTime = _OptTime == 0 ? sin(_Time.w * _GlitchTime) : _OptTime;// optimisation
- //float glitchtime = step(0.99, _OptTime); // returns 1 when sine is near top, otherwise returns 0;
- //float glitchPos = v.vertex.y + _SinTime.y;// position on model
- //float glitchPosClamped = step(0, glitchPos) * step(glitchPos, 0.2);// clamped segment of model
- //o.vertex.xz += glitchPosClamped * 0.1 * glitchtime * _SinTime.y;// moving the vertices when glitchtime returns 1;
-
- o.color = v.color;
- o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
-
- // world position and normal direction
- o.wpos = mul(unity_ObjectToWorld, v.vertex).xyz;
- o.normalDir = normalize(mul(float4(v.normal, 0.0), unity_WorldToObject).xyz);
-
- //#if DissolveH
-
- o.viewDir = normalize(_WorldSpaceCameraPos.xyz - o.wpos.xyz);
- o.lightDir = normalize(_WorldSpaceLightPos0.xyz);
- //Dissolve by height in local coordinate.
- fixed l = _Height - v.vertex.y;
- o.distance = l * _DissolveUpDown;
- //#endif
-
- return o;
- }
-
- fixed4 frag(v2f i) : SV_Target
- {
- float4 text = tex2D(_MainTex, i.texcoord) * _TintColor;// texture
-
- // rim lighting
- float3 viewDirection = normalize(_WorldSpaceCameraPos.xyz - i.wpos.xyz);
- half rim = 1.0 - saturate(dot(viewDirection, i.normalDir));// rimlight based on view and normal
-
- // small scanlines down
- //float fraclines = frac((i.wpos.y * _WorldScale) + _Time.y);//small lines
- //float scanlines = step(fraclines, 0.5);// cut off based on 0.5
- // big scanline up
- float bigfracline = frac((i.wpos.y * 4 ) - _Time.x * 6);// big gradient line
- bigfracline = step(bigfracline, 0.05);
-
- fixed4 col = text + (bigfracline * 0.4 * _TintColor) + (rim * _RimColor);// end result color
-
- //col.a = 0.8 * (scanlines + rim);// alpha based on scanlines and rim
- //col.a = 0.8 * rim;
- //#if DissolveH
- //fixed NdotL = dot(i.normalDir, i.lightDir);
- //fixed NdotV = dot(i.normalDir, i.viewDir);
- //fixed3 dissColor = tex2D(_DissolveTex, fixed2(NdotL, NdotV));
- ////fixed l = _Height - i.posWorld.y;
- //fixed clipDiff = i.distance + dissColor * _DissolveSpread;
- //clip(clipDiff);
- //fixed t = 1 - smoothstep(0.0, _LineWidth, clipDiff);
- //
- //col.rgb = lerp(col.rgb, _DissolveTint.rgb, t);
- //#endif
- return col;
- }
- ENDCG
- }
- }
- }
- }
|