CG中的类型
【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
CG中的类型的更多相关文章
- CG中的数据变量类型
CG 中的数据变量类型有三: float:高精度浮点值,通常是32位. half:中精度浮点值.通常是16位,范围是-60000至+60000,它适合存储UV坐标,颜色值等. fixed:低精度浮点值 ...
- 详解Java 8中Stream类型的“懒”加载
在进入正题之前,我们需要先引入Java 8中Stream类型的两个很重要的操作: 中间和终结操作(Intermediate and Terminal Operation) Stream类型有两种类型的 ...
- SQL 中不同类型的表连接
http://www.linuxidc.com/Linux/2012-08/68035.htm 1.简介 在关系型数据库中,join操作是将不同的表中的数据联合在一起时非常通用的一种做法.首先让我们看 ...
- Object-C中动态类型对象相关操作汇总
Object-C(以后简称OC)中有id类型,相对于明确定义类型的静态类型,称为动态类型. 使用动态类型,配合多态(不同类型拥有同名方法),动态绑定(运行时决定实际调用的方法)可以将很多判断延迟到运行 ...
- MYSQL中 ENUM 类型
MYSQL中 ENUM 类型的详细解释 ENUM类型 ENUM 是一个字符串对象,其值通常选自一个允许值列表中,该列表在表创建时的列规格说明中被明确地列举. 在下列某些情况下,值也可以是空串(&quo ...
- 第66课 C++中的类型识别
1. 类型识别 (1)在面向对象中可能出现下面的情况 ①基类指针指向子类对象 ②基类引用成为子类对象的别名 ▲静态类型——变量(对象)自身的类型(定义变量类型时类型或参数类型) ▲动态类型——指针(引 ...
- 【翻译自nikic大神】PHP中原生类型的方法
引言 第一次,翻译别人的文章,用四级英语的水平来翻译~~囧,可能有很多不太恰当的地方,尽管拍砖(有些地方实在想不到恰当的翻译,我同时贴出了原文和自己很low的翻译). 翻译这篇文章用了我3个晚上一个中 ...
- SQL批量更新数据库中所有用户数据表中字段类型为tinyint为int
--SQL批量更新数据库中所有用户数据表中字段类型为tinyint为int --关键说明:--1.从系统表syscolumns中的查询所有xtype='48'的记录得到类型为[tinyint]的字段- ...
- NET中的类型和装箱/拆箱原理
谈到装箱拆箱,DebugLZQ相信给位园子里的博友一定可以娓娓道来,大概的意思就是值类型和引用类型的相互转换呗---值类型到引用类型叫装箱,反之则叫拆箱.这当然没有问题,可是你只知道这么多,那么Deb ...
随机推荐
- asp.net远程调用WebService的两种方法(转载)
一,静态方法在“解决方案‘项目名’” -> 相应的文件夹,如“Web References” ->右键“添加WEB引用”->在URL里写入地址.二,动态方法在“解决方案‘项目名’” ...
- ubuntu :安装好了搜狗输入法但是没法用
用 im-config 命令打开一个配置器窗口 默认是ibus,需要修改为 fcitx 重启 ubuntu 系统就可以了.
- Unit05: WEB项目的开发模式 、转发 和 Unit09: EL、JSTL
Unit05: WEB项目的开发模式 .转发 和 Unit09: EL.JSTL dao package dao; import java.io.Serializable; import jav ...
- 结合示例说明C++中const和指针结合时怎么理解
在之前随笔<C++中const使用要点(一)>中简单叙述了const int*.int* const和const int* const的区别,记住三句话就能在实际运用时用对,但是看书时发现 ...
- ubuntu64,ndk-r9 编译 ffmpeg 2.1.1的config文件
#!/bin/bash NDK_ROOT=/home/wjh/fox/android-ndk-r9c/ PREBUILT=${NDK_ROOT}toolchains/arm-linux-android ...
- Servlet 前端后台交互
一. URL地址传值 1.1. 地址传值 http://localhost:8080/xj/123/name.json servlet 对应接受方法 @RequestMapping(value=& ...
- Druid.io系列(三): Druid集群节点
原文链接: https://blog.csdn.net/njpjsoftdev/article/details/52955937 1 Historical Node Historical Node的职 ...
- 浏览器工作原理(三):js运行机制及Event Loop
参考:https://segmentfault.com/a/1190000012925872#articleHeader4 一.为什么有Event Loop Javascript设计之初就是一门单线程 ...
- C++ 单链表操作总结
第一.单链表的定义和操作 #include <iostream> using namespace std; template <typename T> struct Node ...
- 新学一招,使用热门的Git
1.安装Git 1.本文所用版本为Git-1.8.0-preview20121022.exe , http://msysgit.googlecode.com/files/Git-1.8.0-prev ...