Shader "Custom/Cg shader with two passes using discard"
{
SubShader
{
CGINCLUDE
#pragma vertex vert
#pragma fragment frag
struct vertexInput
{
float4 vertex:POSITION ;
};
struct vertexOutput
{
float4 pos:SV_POSITION;
float4 posInObjectCoords:TEXCOORD0 ;
};
vertexOutput vert(vertexInput input)
{
vertexOutput output;
output.pos = mul(UNITY_MATRIX_MVP,input.vertex);
output.posInObjectCoords = input.vertex;
return output;
}
ENDCG
Pass
{
Cull Front
CGPROGRAM
float4 frag(vertexOutput input):COLOR
{
if(input.posInObjectCoords.y>0.0)
{
discard;
}
return float4(1.0,0.0,0.0,1.0);
}
ENDCG
}
Pass
{
Cull Back
CGPROGRAM
float4 frag(vertexOutput input):COLOR
{
if(input.posInObjectCoords.y>0.0)
{
discard;
}
return float4(0.0,1.0,0.0,1.0);
}
ENDCG
}
}
}
Cg shader with two passes using discard
最新推荐文章于 2017-09-11 14:29:51 发布