Skip to content
Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
52 lines (41 sloc) 952 Bytes
Shader "Tutorial/022_stencil_buffer/write"{
//show values to edit in inspector
Properties{
[IntRange] _StencilRef ("Stencil Reference Value", Range(0,255)) = 0
}
SubShader{
//the material is completely non-transparent and is rendered at the same time as the other opaque geometry
Tags{ "RenderType"="Opaque" "Queue"="Geometry-1"}
//stencil operation
Stencil{
Ref [_StencilRef]
Comp Always
Pass Replace
}
Pass{
//don't draw color or depth
Blend Zero One
ZWrite Off
CGPROGRAM
#include "UnityCG.cginc"
#pragma vertex vert
#pragma fragment frag
struct appdata{
float4 vertex : POSITION;
};
struct v2f{
float4 position : SV_POSITION;
};
v2f vert(appdata v){
v2f o;
//calculate the position in clip space to render the object
o.position = UnityObjectToClipPos(v.vertex);
return o;
}
fixed4 frag(v2f i) : SV_TARGET{
return 0;
}
ENDCG
}
}
}
You can’t perform that action at this time.