Shader "linedShader"
{
Properties
{
_Color ("Main Color", Color) = (0.5,0.5,0.5,1)
_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_InlineColor ("Inline Color", Color) = (0,0,0,1)
_Outline ("Outline width", Range (.002, 0.008)) = .005
_MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader
{
pass
{
Tags {"Queue"="Geometry"}
CGPROGRAM
#pragma exclude_renderers gles
#pragma vertex vert
struct appdata
{
float4 vertex : POSITION;
};
struct v2f
{
float4 pos : POSITION;
float4 color : COLOR;
};
float _Outline;
float4 _InlineColor;
v2f vert(appdata v)
{
v2f o;
v.vertex.xyz *= 1 - _Outline * 1.1;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.color = _InlineColor;
return o;
}
ENDCG
}
pass
{
Tags {"Queue"="Geometry+1"}
CGPROGRAM
#pragma exclude_renderers gles
#pragma vertex vert
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 pos : POSITION;
//float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
float _Outline;
//float4 _Color;
float4 _MainTex_ST;
v2f vert(appdata v)
{
v2f o;
v.vertex.xyz *= 1 - _Outline ;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
float3 norm = mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal);
float2 offset = TransformViewToProjection(norm.xy);
o.pos.xy += offset * _Outline; // * o.pos.z ;
//o.color = _Color;
o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
return o;
}
ENDCG
SetTexture [_MainTex]
{
combine texture * primary, constant
}
SetTexture [_MainTex]
{
ConstantColor [_Color]
combine constant * previous , texture
}
}
pass
{
Tags {"Queue"="Geometry+2"}
Tags { "LightMode" = "Always" }
Cull Front
ZWrite On
ColorMask RGB
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#pragma exclude_renderers gles
#pragma vertex vert
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
};
struct v2f
{
float4 pos : POSITION;
float4 color : COLOR;
};
float _Outline;
float4 _OutlineColor;
v2f vert(appdata v)
{
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
float3 norm = mul ((float3x3)UNITY_MATRIX_IT_MV, v.normal);
float2 offset = TransformViewToProjection(norm.xy);
o.pos.xy += offset * _Outline * 2; // * o.pos.z ;
o.color = _OutlineColor;
return o;
}
ENDCG
}
}
}