Shader "Custom/OcclusionShader" {
Properties{
_Color("Main Color", Color) = (1,1,1,1)
}
SubShader{
Tags { "RenderType" = "Opaque" }
LOD 100
Pass {
Stencil {
Ref 1
Comp always
Pass replace
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata {
float4 vertex : POSITION;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 pos : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
fixed4 _Color;
v2f vert(appdata v) {
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
return o;
}
fixed4 frag(v2f i) : SV_Target {
return fixed4(0,0,0,0); // Render invisible color
}
ENDCG
}
Pass {
Stencil {
Ref 1
Comp notequal
Pass keep
}
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata {
float4 vertex : POSITION;
float3 normal : NORMAL;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct v2f {
float4 pos : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};
fixed4 _Color;
v2f vert(appdata v) {
v2f o;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_OUTPUT(v2f, o);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.pos = UnityObjectToClipPos(v.vertex);
return o;
}
fixed4 frag(v2f i) : SV_Target {
// Render with object color
return _Color;
}
ENDCG
}
}
FallBack "Diffuse"
}
0 件のコメント:
コメントを投稿