Created
September 17, 2018 06:37
-
-
Save TachibanaKoki/a547434d140dbb9fffb4639ee555c13c to your computer and use it in GitHub Desktop.
全文
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Custom/StencilOutline" { | |
Properties | |
{ | |
_OutlineWidth("Outline Width", float) = 0.1 | |
} | |
SubShader | |
{ | |
Tags{ "RenderType" = "Transparent" "Queue" = "Transparent" } | |
Pass | |
{ | |
Stencil | |
{ | |
Ref 1 | |
Comp always | |
Pass replace | |
} | |
Cull Front | |
ZWrite Off | |
ZTest Off | |
Blend SrcAlpha OneMinusSrcAlpha | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
struct appdata | |
{ | |
half4 vertex : POSITION; | |
half3 normal : NORMAL; | |
}; | |
struct v2f | |
{ | |
half4 pos : SV_POSITION; | |
}; | |
half _OutlineWidth; | |
v2f vert(appdata v) | |
{ | |
v2f o = (v2f)0; | |
o.pos = UnityObjectToClipPos(v.vertex + normalize(v.normal) * _OutlineWidth); | |
return o; | |
} | |
fixed4 frag(v2f i) : SV_Target | |
{ | |
return 0; | |
} | |
ENDCG | |
} | |
Pass | |
{ | |
Stencil | |
{ | |
Ref 2 | |
Comp always | |
Pass replace | |
} | |
Cull Back | |
ZWrite Off | |
ZTest Off | |
Blend SrcAlpha OneMinusSrcAlpha | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
struct appdata | |
{ | |
half4 vertex : POSITION; | |
half3 normal : NORMAL; | |
}; | |
struct v2f | |
{ | |
half4 pos : SV_POSITION; | |
}; | |
v2f vert(appdata v) | |
{ | |
v2f o = (v2f)0; | |
o.pos = UnityObjectToClipPos(v.vertex); | |
return o; | |
} | |
fixed4 frag(v2f i) : SV_Target | |
{ | |
return 0; | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment