shader 变量类型fixed half float

CG类型

CG支持7种数据类型:

float 32位浮点数
half 16位浮点数
int   32位整形数
fixed 12位定点数
bool  布尔数据
sampler 纹理对象的句柄 共有:sampler、sampler1D、sampler2D、sampler3D、samplerCUBE、和samplerRECT六种。
string 字符串,其实没有必要在CG中用到字符串
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8

此外,CG还支持矩阵数据类型 如:

float2×4 matrix; //表示2×4阶矩阵,包含8个float类型数据
  • 1
  • 2

类型使用技巧:

 1.精度够用就好
 2.颜色和单位向量,使用fixed
 3.其他情况,尽量使用half(即范围在[-6万,+6万]、精确的小数点3.3位);否则才使用用float

猜你喜欢

转载自blog.csdn.net/a133900029/article/details/80558332