官术网_书友最值得收藏!

There's more...

Where swizzling really shows its full potential is when it's applied to packed matrices. Cg allows types such as float4x4, which represents a matrix of floats with four rows and four columns. You can access a single element of the matrix using the _mRC notation, where R is the row and C is the column:

float4x4 matrix; 
// ... 
float first = matrix._m00; 
float last = matrix._m33; 

The _mRC notation can also be chained:

float4 diagonal = matrix._m00_m11_m22_m33; 

An entire row can be selected using squared brackets:

float4 firstRow = matrix[0]; 
// Equivalent to 
float4 firstRow = matrix._m00_m01_m02_m03; 
主站蜘蛛池模板: 宁乡县| 将乐县| 清流县| 竹山县| 遵义市| 保靖县| 华池县| 临洮县| 务川| 兴城市| 章丘市| 开阳县| 平罗县| 丹阳市| 平乡县| 民和| 南昌市| 景德镇市| 香格里拉县| 彰武县| 宜州市| 英山县| 金门县| 锡林浩特市| 靖宇县| 五台县| 鸡泽县| 太谷县| 嘉义县| 花莲县| 平果县| 光山县| 永修县| 平泉县| 望谟县| 利津县| 阿拉尔市| 玛曲县| 栖霞市| 拜城县| 三门峡市|