shader基础教程

来源:互联网 发布:淘宝直播预告已过期 编辑:程序博客网 时间:2024/06/18 06:04
Shader "Custom/Test11-07" {

SubShader {
pass
{
   CGPROGRAM
#pragma vertex vert    //顶点函数
#pragma fragment frag //片段函数
struct v2f//结构体
{
   fixed4 col:COLOR;
float4 pos:POSITION;
};
void vert(in float2 objpos:POSITION,out fixed4 col:COLOR,out float4 pos:POSITION)//切记 col 要放在pos之前
{
      pos=float4(objpos,1,1);
  col=pos;
  if(objpos.x<0)
  {
     col=fixed4(1,0,0,1);
  }
  else
  {
    col=fixed4(0,0,1,1);
  }
 
}
void frag(inout fixed4 col5:COLOR)//需要填写inout 否则进行颜色输出
{
   
//col=fixed4(1,0,0,1);
//v.col=col;
//return v.col;

}
ENDCG
}
}

}
原创粉丝点击