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 ...
随机推荐
- C++11标准库中cstdio头文件新增的5个格式化I/O函数学习
刚开始学网络编程,稍微扩展书上的简单C/S程序时,发现以前太忽略标准I/O这一块,查官网发现C++11新增了几个格式化I/O函数. snprintf 将格式化输出写入到有大小限制的缓存中 vfs ...
- Eclipse中创建新的Spring Boot项目
本文转载自:http://blog.csdn.net/clementad/article/details/51334064 简单几步,在Eclipse中创建一个新的spring Boot项目: 1.E ...
- yii 获取当前ip
<?php //当前域名 echo Yii::app()->request->hostInfo; //除域名外的URL echo Yii::app()->request-> ...
- php中将数组转换为指定符号分割的字符串
如想将一个数组转换为以“,”分割的字符串,只需如下: implode(',', arr);
- if、while中变量的作用域问题
我们知道,函数.类会改变当前变量的作用域.if,while等分支循环结构会继承外部作用域,即外部变量对分支循环结构内部可见. 但是C语言不支持if,while等分支循环结构内部作用域对外可见,而PHP ...
- node的socket.io的之基本使用方法.
使用socket.io的使用创建一个socket.io服务器即可.但是该服务器依赖于一个已经创建的http服务器. 在http服务器运行之后,使用listen方法为该http服务器附加一个socket ...
- Mybatis扩展
分页插件PageHelper 其实Mybstis内部有实现逻辑分页的功能,但是较为麻烦和难用.这里记录一个分页插件PageHelper的使用,我们可以在它的github地址https://github ...
- Futures
Futures is a framework for expressing asynchronous code in C++ using the Promise/Future pattern. Ove ...
- AOP 动态织入的.NET实现
AOP(面向切面编程:Aspect Oriented Programming)为诸如日志记录.性能统计.安全控制.事务处理.异常处理等与具体业务逻辑无关,却需要在全局范围进行执行的功能提供了一种良好重 ...
- Python - 第一个 Django 项目
Django 的安装: pip3 install django==1.11.11 pip3 install -i https://pypi.tuna.tsinghua.edu.cn/simple/ d ...