unity shader中有哪些属性如何使用

来源:互联网 发布:返利机器人源码 编辑:程序博客网 时间:2024/06/06 08:59
Shader"practice/myshader"{

Properties{

_Color("color",Color)=(1,1,1,1)   //颜色,一般用fixed4

_Vector("vector",Vector)=(1,2,3,4) //向量类型,float4 

_Int("int",Int)=123//整数

_Float("float",Float)=5.5 //小数,不像c#里需要加f

_Range("range"Range(1,10))=10  //范围,括号里是范围,本质上就是Float,只是对Float做了一个限制。

_2D("texture",2D)="white"{}  white指的是在没有图片的时候使用的颜色。

_Cube("cube",Cube)="white"{}//这里的cube是天空盒子。

_3D("texture",3D)="white"{}//3d纹理
}

Subshader{
Pass{
CGPROGRAM

//属性使用要重新定义
fixed4 _Color; //已经复制过的,注意分号
float4 _Vector;
float _Int;
float _Float;
float _Range;
sampler2D _2d;
samplerCube _Cube;
sampler3D _3D;

float t1;//可以用float的地方也可以用half和fixed   
//float的范围是 32位存储    half 16位 -6W~+6W  fixed 11位 -2~+2
float2 t2;
float3 t3;
float4 t4;


ENDCG
}}
Fallback"Mobile/VertexLit" 
]
1 0
原创粉丝点击