Advertisement
BlueBear

highligh.shader

May 20th, 2014
292
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Shader "BlenderesHighlight" {
  2.     Properties {
  3.         _Color ("Main Color", Color) = (1,1,1,1)
  4.         _OutlineColor ("Outline Color", Color) = (0,0,0,1)
  5.         _Outline ("Outline width", Range (0.002, 0.03)) = 0.01
  6.         _MainTex ("Base (RGB)", 2D) = "white" { }
  7.     }
  8.     SubShader {
  9.         Tags { "RenderType"="Opaque" }
  10.         UsePass "Toon/Basic/BASE"
  11.         Pass {
  12.             Name "OUTLINE"
  13.             Tags { "LightMode" = "Always" }
  14.             CGPROGRAM
  15.  
  16.             #pragma vertex vert
  17.  
  18.             struct appdata {
  19.                 float4 vertex;
  20.                 float3 normal;
  21.             };
  22.  
  23.             struct v2f {
  24.                 float4 pos : POSITION;
  25.                 float4 color : COLOR;
  26.                 float fog : FOGC;
  27.             };
  28.  
  29.             uniform float _Outline;
  30.             uniform float4 _OutlineColor;
  31.  
  32.             v2f vert(appdata v) {
  33.                 v2f o;
  34.                 o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
  35.                 float3 norm = mul ((float3x3)UNITY_MATRIX_MV, v.normal);
  36.                 norm.x *= UNITY_MATRIX_P[0][0];
  37.                 norm.y *= UNITY_MATRIX_P[1][1];
  38.                 o.pos.xy += norm.xy * _Outline;
  39.                 o.fog = o.pos.z;
  40.                 o.color = _OutlineColor;
  41.                 return o;
  42.             }
  43.  
  44.             ENDCG
  45.  
  46.             //Color (0,0,0,0)
  47.             Cull Front
  48.             ZWrite On
  49.             ColorMask RGB
  50.             Blend SrcAlpha OneMinusSrcAlpha
  51.             SetTexture [_MainTex] { combine primary }
  52.         }
  53.     }
  54.     Fallback "Diffuse"
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement