12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- /*
- // Copyright (c) 2015 José Guerreiro. All rights reserved.
- //
- // MIT license, see http://www.opensource.org/licenses/mit-license.php
- //
- // Permission is hereby granted, free of charge, to any person obtaining a copy
- // of this software and associated documentation files (the "Software"), to deal
- // in the Software without restriction, including without limitation the rights
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- // copies of the Software, and to permit persons to whom the Software is
- // furnished to do so, subject to the following conditions:
- //
- // The above copyright notice and this permission notice shall be included in
- // all copies or substantial portions of the Software.
- //
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- // THE SOFTWARE.
- */
- Shader "Hidden/OutlineBufferEffect" {
- Properties
- {
- [PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
- _Color ("Tint", Color) = (1,1,1,1)
- [MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
- }
- SubShader
- {
- Tags
- {
- "Queue" = "Transparent"
- "IgnoreProjector" = "True"
- "RenderType" = "Transparent"
- "PreviewType" = "Plane"
- "CanUseSpriteAtlas" = "True"
- }
- Cull [_Culling]
- Lighting Off
-
- CGPROGRAM
- #pragma surface surf Lambert vertex:vert nofog noshadow noambient nolightmap novertexlights noshadowmask nometa //keepalpha
- #pragma multi_compile _ PIXELSNAP_ON
- sampler2D _MainTex;
- fixed4 _Color;
- float _OutlineAlphaCutoff;
- struct Input
- {
- float2 uv_MainTex;
- //fixed4 color;
- };
- void vert(inout appdata_full v, out Input o)
- {
- #if defined(PIXELSNAP_ON)
- v.vertex = UnityPixelSnap(v.vertex);
- #endif
- UNITY_INITIALIZE_OUTPUT(Input, o);
- //o.color = v.color;
- }
- void surf(Input IN, inout SurfaceOutput o)
- {
- fixed4 c = tex2D(_MainTex, IN.uv_MainTex);// * IN.color;
- if (c.a < _OutlineAlphaCutoff) discard;
- /* float alpha = c.a * 99999999;
- o.Albedo = _Color * alpha;
- o.Alpha = alpha; */
- o.Albedo = _Color;
- o.Emission = o.Albedo;
- }
- ENDCG
- }
- Fallback "Transparent/VertexLit"
- }
|