Advertisement
Guest User

Untitled

a guest
Aug 15th, 2019
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "Outline2D" {
  2.     Properties {
  3.         _Color ("Main Tint", Color) = (1,1,1,1)
  4.         _OutlineColor ("Outline Color", Color) = (1,1,1,1)
  5.         _MainTex ("Albedo (RGB)", 2D) = "white" {}
  6.         _Cutoff ("Main Alpha Cutoff", Range(0,1)) = 0.5
  7.         _OutlineCutoff ("Outline Alpha Cutoff", Range(0,1)) = 0.25
  8.         _LineOffset ("Outline Depth Offset", Range(0,-10000)) = -1000
  9.     }
  10.    
  11.     SubShader {
  12.    
  13.         //Standard Pass
  14.         Tags { "RenderType"="Opaque" }
  15.         LOD 200
  16.        
  17.         Offset -3, [_LineOffset]
  18.         Cull Off
  19.    
  20.         CGPROGRAM
  21.         // Physically based Standard lighting model, and enable shadows on all light types
  22.         #pragma surface surf Standard
  23.         #pragma target 3.0
  24.  
  25.         sampler2D _MainTex;
  26.  
  27.         struct Input {
  28.             float2 uv_MainTex;
  29.         };
  30.  
  31.         fixed4 _Color;
  32.         half _Cutoff;
  33.  
  34.         void surf (Input IN, inout SurfaceOutputStandard o) {
  35.             fixed4 albedo = tex2D (_MainTex, IN.uv_MainTex) * _Color;
  36.             clip (albedo.a - _Cutoff);
  37.             o.Albedo = albedo.rgb;
  38.             o.Alpha = albedo.a;
  39.         }
  40.         ENDCG
  41.  
  42.        
  43.         //Outline Pass
  44.         Tags { "RenderType"="Opaque" }
  45.         LOD 200
  46.  
  47.         Offset 0, 0
  48.         Cull Off
  49.        
  50.         CGPROGRAM
  51.         // Physically based Standard lighting model, and enable shadows on all light types
  52.         #pragma surface surf Standard addshadow
  53.         #pragma target 3.0
  54.  
  55.         sampler2D _MainTex;
  56.  
  57.         struct Input {
  58.             float2 uv_MainTex;
  59.         };
  60.  
  61.         fixed4 _OutlineColor;
  62.         half _OutlineCutoff;
  63.  
  64.         void surf (Input IN, inout SurfaceOutputStandard o) {
  65.             fixed4 albedo = tex2D (_MainTex, IN.uv_MainTex);
  66.             clip (albedo.a - _OutlineCutoff);
  67.             o.Albedo = _OutlineColor.rgb;
  68.             o.Alpha = albedo.a;
  69.         }
  70.         ENDCG
  71.     }
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement