Matrix

  通常像下面这样定义Matrix:

int1x1    iMatrix;   // integer matrix with 1 row,  1 column
int4x1 iMatrix; // integer matrix with 4 rows, 1 column
int1x4 iMatrix; // integer matrix with 1 row, 4 columns
double3x3 dMatrix; // double matrix with 3 rows, 3 columns float2x2 fMatrix = { 0.0f, 0.1, // row 1
2.1f, 2.2f // row 2
};

  也可以像下面这样定义Matrix:

matrix <Type, Number> VariableName
matrix <float, , > fMatrix = { 0.0f, 0.1, // row 1
2.1f, 2.2f // row 2
};

  Member access for matrix types

_m00, _m01,_m02, _m03 

_m10, _m11,_m12, _m13 

_m20, _m21,_m22, _m23 

_m30, _m31,_m32, _m33 

or

_11, _12,_13, _14 

_21, _22,_23, _24 

_31, _32,_33, _34 

_41, _42,_43, _4

参考:http://msdn.microsoft.com/en-us/library/windows/desktop/bb509623(v=vs.85).aspx

Vector

  通常像下面这样定义Vector:

bool    bVector;   // scalar containing 1 Boolean
int1 iVector = ;
float3 fVector = { 0.2f, 0.3f, 0.4f };

  也可像下面这样定义:

vector <Type, Number> VariableName

vector <int,    > iVector = ;
vector <double, > dVector = { 0.2, 0.3, 0.4, 0.5 };

Scalar

  • bool - true or false.
  • int - 32-bit signed integer.
  • uint - 32-bit unsigned integer.
  • dword - 32-bit unsigned integer.
  • half - 16-bit floating point value. This data type is provided only for language compatibility. Direct3D 10 shader targets map all half data types to float data types. A half data type cannot be used on a uniform global variable (use the /Gec flag if this functionality is desired).
  • float - 32-bit floating point value.
  • double - 64-bit floating point value. You cannot use double precision values as inputs and outputs for a stream. To pass double precision values between shaders, declare each double as a pair of uint data types. Then, use the asdouble function to pack each double into the pair of uints and the asuint function to unpack the pair of uints back into the double.

Per-Component Math Operations

  可以单独取出Vector中的分量进行计算:

float4 pos = float4(,,,);
float2 f_2D;
f_2D = pos.xy; // read two components
f_2D = pos.xz; // read components in any order
f_2D = pos.zx; f_2D = pos.xx; // components can be read more than once
f_2D = pos.yy;

  读取matrix的某一行:

float2 temp;
float2x2 fMatrix;
temp = fMatrix[] // read the first row

参考:http://msdn.microsoft.com/en-us/library/windows/desktop/bb509634(v=vs.85).aspx

最新文章

  1. c语言的简易日历
  2. 不能用100%ie6不兼容
  3. Python多线程学习笔记
  4. Retrofit2.0+OkHttp打印Request URL(请求地址参数)
  5. 【Sort】多种排序
  6. Java对数函数及Java对数运算
  7. python的 a,b=b,a+b 和 a=b b=a+b 的区别(经典)
  8. python的单、双、多分支流程控制
  9. PHP获取新插入的主键id
  10. A1制作文件夹目录
  11. 洛谷P3620 数据备份
  12. hbase大规模数据写入的优化历程 ,ZZ
  13. JDK 升级问题小结
  14. 牛客OI周赛7-提高组
  15. 9、SQL逻辑查询语句执行顺序
  16. Python中的对象行为与特殊方法(二)类型检查与抽象基类
  17. Python基础4--一看就会的选择与循环
  18. flask session,蓝图,装饰器,路由和对象配置
  19. vue注册全局属性
  20. Spring Boot中使用JavaMailSender发送邮件

热门文章

  1. 【angularJS】$Scope
  2. 字符编码:ASCII,Unicode和UTF-8
  3. 定义文档兼容性、让IE按指定版本解析我们的页面
  4. python运算符一些注意项
  5. 洛谷1527(bzoj2738)矩阵乘法——二维树状数组+整体二分
  6. 登录MySQL非默认3306端口号的语句
  7. Unit04: JSP基本语法 、 JSP运行原理
  8. c#实现QQ群成员列表导出及邮件群发之邮件群发
  9. Hibernate学习5—Hibernate操作对象2
  10. struts2学习(5)拦截器简介以及例子执行过程