Skip to content

Instantly share code, notes, and snippets.

@edom18
Created January 29, 2015 15:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save edom18/885e8469ee9affeb48cc to your computer and use it in GitHub Desktop.
Save edom18/885e8469ee9affeb48cc to your computer and use it in GitHub Desktop.
[Unity] UnityのShaderでステンシルバッファを試す ref: http://qiita.com/edo_m18/items/95a7f350d1164486e03b
Shader "Red" {
SubShader {
Tags { "RenderType"="Opaque" "Queue"="Geometry"}
Pass {
Stencil {
Ref 2
Comp always
Pass replace
ZFail decrWrap
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
struct appdata {
float4 vertex : POSITION;
};
struct v2f {
float4 pos : SV_POSITION;
};
v2f vert(appdata v) {
v2f o;
o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
return o;
}
half4 frag(v2f i) : COLOR {
return half4(1,0,0,1);
}
ENDCG
}
}
}
Stencil {
Ref 2
Comp always
Pass replace
ZFail decrWrap
}
Ref [整数値]
Comp [比較関数]
Pass [合格]
Fail [不合格]
ZFail [合格だが深度テスト不合格]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment