Created
January 29, 2015 15:25
-
-
Save edom18/885e8469ee9affeb48cc to your computer and use it in GitHub Desktop.
[Unity] UnityのShaderでステンシルバッファを試す ref: http://qiita.com/edo_m18/items/95a7f350d1164486e03b
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 "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 | |
} | |
} | |
} |
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
Stencil { | |
Ref 2 | |
Comp always | |
Pass replace | |
ZFail decrWrap | |
} |
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
Ref [整数値] | |
Comp [比較関数] | |
Pass [合格] | |
Fail [不合格] | |
ZFail [合格だが深度テスト不合格] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment