Shader "GK/Test"
{
SubShader
{
pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#define MACROFL FL4(fl4.ab,fl3.zy);//支持宏定义
typedef float4 FL4;//支持别名
struct v2f//支持结构体
{
float2 uv;
float4 pos;
}
void vert(in float2 objPos:POSITION,out float4 pos:POSITION)
{
pos=float4(objPos,0,1);
}
void frag(out float4 col:color)
{
fixed r=1;
fixed g=1;
fixed b=0;
fixed a=0.5;
col=fixed4(r,g,b,a);
bool b1=false;
col=b1?col:fixed4(0,1,0,1);
float2 fl2=float2(1,0);
float3 fl3=float3(1,0,1);
float4 fl4=float4(0.54,0,1,1);
FL4 fl=MACROFL
col=fl;
col=float4(fl3.xy,fl2);//,swizzle操作
float2x4 M2x4={fl4,{0,1,0,1}};//矩阵
col=M2x4[0];
float arr[4]={1,0.4,0.4,1};
col=float4(arr[0],arr[1],arr[2],arr[3]);//数组
v2f o;
o.pos=fl4;
o.ui=fl2
}
ENDCG
}
}
}
发表评论