18
属性块介绍
(顶点,片元)Shader一共分为2大块
1、Properties - 属性块
2、SubShader - SubShader块
(统称为语义块)
属性块 :
属性块 声明的变量 会体现在Unity面板中。
属性块中写的只是我们要在Unity中展示的属性,而真正定义变量实在SubShader中
(例如:_MainTex ("Texture",2D) = "white"{ })
_MainTex : 变量名(在Shader中使用)
"Texture" : 体现在Unity检视面板 中的 名称
2D : 类型(2D图片)
“white”: 默认值(白色)
属性块常用基本类型 :
_Int ( "Int" ,Int ) = 2
_Float ( "Float" , float ) = 1.5
_Range ( "Range" , range ( 0.0 , 2.0 )) = 1.0
_MainTex ( "Texture" , 2D ) = " white " { }
_color("Color",color) = (1,1,1,1)
_vector("Vector",Vector)=(1,2,3,4)
_cube("Cube",cube)="white"{}
_3D("3D",3D) = "black"{}
unity属性类型
Int
float
Range(x,y):范围值
Color
Vector (x,y,z,w)
2D
Cube
3D