高级着色语言HLSL入门(6)
来源:互联网 发布:中国美容行业大数据 编辑:程序博客网 时间:2024/05/16 06:30
高级着色语言HLSL入门(6)
16.7内建函数
HLSL有一个丰富的内建函数的集合,它们对3D图形来说非常有用。下表是一个删减了的列表,注意:要得到更多的参考,可以参看DirectX文档中内建HLSL函数的完整列表。
以下表格中,//<variable>//表示变量variable的模(例如向量的绝对值)。
函数
描述
abs(x)
返回 |x|
ceil(x)
返回 ≥ x 的最小整数
clamp(x, a, b)
Clamps x to the range [a, b] and returns the result.
cross(u, v)
返回 u × v(叉积)
degrees(x)
转换 x 从弧度到角度
determinant(M)
返回矩阵M的行列式det(M)
distance(u, v)
返回u点和v点之间的距离||v - u||
dot(u, v)
返回 u · v(点积)
floor(x)
返回 ≤ x 的最大整数
length(v)
返回 ||v||
lerp(u, v, t)
在u和v之间线性插值,参数 t 在[0, 1 ]之间变化。
log(x)
返回 ln(x)
log10(x)
返回 log10(x)
log2(x)
返回 log2(x)
max(x, y)
如果x ≥ y,则返回 x;否则返回 y
min(x, y)
如果 x ≤ y,返回x;否则返回 y
mul(M, N)
返回矩阵乘积 MN. 注意:矩阵乘积必须是已定义的. 如果M是一个向量,它被作为一个行向量,则向量-矩阵(vector-matrix)乘法是已定义的。类似的,如果N 是一个向量,他被作为一个列向量,则矩阵-向量(matrix-vector)乘法是已定义的。
normalize(v)
返回 v/∥v∥
pow(b, n)
返回 bn
radians(x)
转换 x 从 角度 到 弧度
reflect(v, n)
给定向量v和表面法线n,计算其反射向量
refract(v,n, eta)
给定向量v、表面法线n和两种材质的两个索引的比率eta,计算其折射向量. 翻看一下物理书中Snell的规则或者在互联网上搜索一下关于refraction(反射)的信息
rsqrt(x)
返回x的平方根的倒数
saturate(x)
返回clamp(x, 0.0, 1.0)
sin(x)
返回x的正弦,其中x单位为弧度
sincos(in x, out s, out c)
返回x的正弦和余弦,其中x单位为弧度
sqrt(x)
返回x的平方根
tan(x)
返回x的正切,其中 x 单位为弧度
transpose(M)
返回M的转置
abs (Direct3D 9 HLSL)
Computes the absolute value of each component.
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
ceil (Direct3D 9 HLSL)
Returns the smallest integer which is greater than or equal to x.
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
clamp (Direct3D 9 HLSL)
Clamps x to the range [min, max].
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
cross (Direct3D 9 HLSL)
Returns the cross product of two 3D vectors.
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
degrees (Direct3D 9 HLSL)
Converts x from radians to degrees.
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
determinant (Direct3D 9 HLSL)
Returns the determinant of the square matrix m.
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
distance (Direct3D 9 HLSL)
Returns the distance between two points x and y.
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
dot (Direct3D 9 HLSL)
Returns the • product of two vectors, x and y.
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
floor (Direct3D 9 HLSL)
Returns the greatest integer which is less than or equal to x.
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
length (Direct3D 9 HLSL)
Returns the length of the vector x.
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
lerp (Direct3D 9 HLSL)
Returns x + s(y - x). This linearly interpolates between x and y, such that the return value is x when s is 0, and y when s is 1.
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
log (Direct3D 9 HLSL)
Returns the base-e logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF.
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
log10 (Direct3D 9 HLSL)
Returns the base-10 logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF.
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
log2 (Direct3D 9 HLSL)
Returns the base-2 logarithm of x. If x is negative, the function returns indefinite. If x is 0, the function returns +INF.
Syntax
Where:
Minimum Shader Version
This intrinsic function is supported in the following (or above) shader versions:
- 高级着色语言HLSL入门(6)
- 高级着色语言HLSL入门(6)
- 高级着色语言HLSL入门(1)
- 高级着色语言HLSL入门(2)
- 高级着色语言HLSL入门(3)
- 高级着色语言HLSL入门(4)
- 高级着色语言HLSL入门(5)
- 高级着色语言HLSL入门(7)
- 高级着色语言HLSL入门(4)
- 高级着色语言HLSL入门(5)
- 高级着色语言HLSL入门
- 高级着色语言HLSL入门
- 《高级着色语言HLSL入门》系列文章
- DirectX11 高级着色器语言HLSL入门
- HLSL 高级着色语言基础
- HLSL高级顶点着色语言基础(1)
- HLSL高级顶点着色语言基础(2)
- Directx 中HLSL高级着色器语言 脑补一下吧
- 高级着色语言HLSL入门(4)
- 启用IIS的Gzip压缩功能
- c# 数据库访问静态类 支持多条SQL语句事务操作
- 网络钓鱼(Phishing)攻击方式
- 高级着色语言HLSL入门(5)
- 高级着色语言HLSL入门(6)
- 高级着色语言HLSL入门(7)
- OV3640 的解析
- linux下追踪函数调用堆栈
- 文明5的dx11应用
- 网吧 组策略管理单元受到策略限制,请与管理员联系
- Visual Studio 2005 注册码
- 如何在线打开word文档并高亮显示指定关键字
- 好的磁盘管理工具Acronis Disk Director Suite 10.0英文原版 + 注册机 + 使用图文介绍