CG Shader常用函数
为了方便自己记忆,将常用的CG函数写于此
转载于 http://www.cppblog.com/lai3d/archive/2008/10/23/64889.html
| Name | Syntax | Description |
|---|---|---|
| abs | abs(x) | Absolute value (per component). |
| acos | acos(x) | Returns the arccosine of each component of x. |
| all | all(x) | Test if all components of x are nonzero. |
| any | any(x) | Test if any component of x is nonzero. |
| asfloat | asfloat(x) | Convert the input type to a float. |
| asin | asin(x) | Returns the arcsine of each component of x. |
| asint | asint(x) | Convert the input type to an integer. |
| asuint | asuint(x) | Convert the input type to an unsigned integer. |
| atan | atan(x) | Returns the arctangent of x. |
| atan2 | atan2(y, x) | Returns the arctangent of of two values (x,y). |
| ceil | ceil(x) | Returns the smallest integer which is greater than or equal to x. |
| clamp | clamp(x, min, max) | Clamps x to the range [min, max]. |
| clip | clip(x) | Discards the current pixel, if any component of x is less than zero. |
| cos | cos(x) | Returns the cosine of x. |
| cosh | cosh(x) | Returns the hyperbolic cosine of x. |
| cross | cross(x, y) | Returns the cross product of two 3D vectors. |
| D3DCOLORtoUBYTE4 | D3DCOLORtoUBYTE4(x) | Swizzles and scales components of the 4D vector x to compensate for the lack of UBYTE4 support in some hardware. |
| ddx | ddx(x) | Returns the partial derivative of x with respect to the screen-space x-coordinate. |
| ddy | ddy(x) | Returns the partial derivative of x with respect to the screen-space y-coordinate. |
| degrees | degrees(x) | Converts x from radians to degrees. |
| determinant | determinant(m) | Returns the determinant of the square matrix m. |
| distance | distance(x, y) | Returns the distance between two points. |
| dot | dot(x, y) | Returns the dot product of two vectors. |
| exp | exp(x) | Returns the base-e exponent. |
| exp2 | exp2(x) | Base 2 exponent (per component). |
| faceforward | faceforward(n, i, ng) | Returns -n * sign(•(i, ng)). |
| floor | floor(x) | Returns the greatest integer which is less than or equal to x. |
| fmod | fmod(x, y) | Returns the floating point remainder of x/y. |
| frac | frac(x) | Returns the fractional part of x. |
| frexp | frexp(x, exp) | Returns the mantissa and exponent of x. |
| fwidth | fwidth(x) | Returns abs(ddx(x)) + abs(ddy(x)) |
| GetRenderTargetSampleCount | GetRenderTargetSampleCount() | Returns the number of render-target samples. |
| GetRenderTargetSamplePosition | GetRenderTargetSamplePosition(x) | Returns a sample position (x,y) for a given sample index. |
| isfinite | isfinite(x) | Returns true if x is finite, false otherwise. |
| isinf | isinf(x) | Returns true if x is +INF or -INF, false otherwise. |
| isnan | isnan(x) | Returns true if x is NAN or QNAN, false otherwise. |
| ldexp | ldexp(x, exp) | Returns x * 2exp |
| length | length(v) | Returns the length of the vector v. |
| lerp | lerp(x, y, s) | Returns x + s(y - x). |
| lit | lit(n • l, n • h, m) | Returns a lighting vector (ambient, diffuse, specular, 1) |
| log | log(x) | Returns the base-e logarithm of x. |
| log10 | log10(x) | Returns the base-10 logarithm of x. |
| log2 | log2(x) | Returns the base-2 logarithm of x. |
| max | max(x, y) | Selects the greater of x and y. |
| min | min(x, y) | Selects the lesser of x and y. |
| modf | modf(x, out ip) | Splits the value x into fractional and integer parts. |
| mul | mul(x, y) | Performs matrix multiplication using x and y. |
| noise | noise(x) | Generates a random value using the Perlin-noise algorithm. |
| normalize | normalize(x) | Returns a normalized vector. |
| pow | pow(x, y) | Returns xy. |
| radians | radians(x) | Converts x from degrees to radians. |
| reflect | reflect(i, n) | Returns a reflection vector. |
| refract | refract(i, n, R) | Returns the refraction vector. |
| round | round(x) | Rounds x to the nearest integer |
| rsqrt | rsqrt(x) | Returns 1 / sqrt(x) |
| saturate | saturate(x) | Clamps x to the range [0, 1] |
| sign | sign(x) | Computes the sign of x. |
| sin | sin(x) | Returns the sine of x |
| sincos | sincos(x, out s, out c) | Returns the sine and cosine of x. |
| sinh | sinh(x) | Returns the hyperbolic sine of x |
| smoothstep | smoothstep(min, max, x) | Returns a smooth Hermite interpolation between 0 and 1. |
| sqrt | sqrt(x) | Square root (per component) |
| step | step(a, x) | Returns (x >= a) ? 1 : 0 |
| tan | tan(x) | Returns the tangent of x |
| tanh | tanh(x) | Returns the hyperbolic tangent of x |
| tex1D | tex1D(s, t) | 1D texture lookup. |
| tex1Dbias | tex1Dbias(s, t) | 1D texture lookup with bias. |
| tex1Dgrad | tex1Dgrad(s, t, ddx, ddy) | 1D texture lookup with a gradient. |
| tex1Dlod | tex1Dlod(s, t) | 1D texture lookup with LOD. |
| tex1Dproj | tex1Dproj(s, t) | 1D texture lookup with projective divide. |
| tex2D | tex2D(s, t) | 2D texture lookup. |
| tex2Dbias | tex2Dbias(s, t) | 2D texture lookup with bias. |
| tex2Dgrad | tex2Dgrad(s, t, ddx, ddy) | 2D texture lookup with a gradient. |
| tex2Dlod | tex2Dlod(s, t) | 2D texture lookup with LOD. |
| tex2Dproj | tex2Dproj(s, t) | 2D texture lookup with projective divide. |
| tex3D | tex3D(s, t) | 3D texture lookup. |
| tex3Dbias | tex3Dbias(s, t) | 3D texture lookup with bias. |
| tex3Dgrad | tex3Dgrad(s, t, ddx, ddy) | 3D texture lookup with a gradient. |
| tex3Dlod | tex3Dlod(s, t) | 3D texture lookup with LOD. |
| tex3Dproj | tex3Dproj(s, t) | 3D texture lookup with projective divide. |
| texCUBE | texCUBE(s, t) | Cube texture lookup. |
| texCUBEbias | texCUBEbias(s, t) | Cube texture lookup with bias. |
| texCUBEgrad | texCUBEgrad(s, t, ddx, ddy) | Cube texture lookup with a gradient. |
| texCUBElod | tex3Dlod(s, t) | Cube texture lookup with LOD. |
| texCUBEproj | texCUBEproj(s, t) | Cube texture lookup with projective divide. |
| transpose | transpose(m) | Returns the transpose of the matrix m. |
| trunc | trunc(x) | Truncates floating-point value(s) to integer value(s) |
CG Shader常用函数的更多相关文章
- unity shader 常用函数列表
此篇博客转自csdn的一位大牛. 中间排版出了一些问题 Intrinsic Functions (DirectX HLSL) The following table lists the intrins ...
- Unity3D -- shader常用函数和变量
最近在学习Unity Shader,写Shader的时候总是忘记Unity为我们提供的函数.变量怎么写的,这里整理一下,方便自己查阅,也提供给网友,学习Shader不易. 1.函数 float3 Wo ...
- Unity Shader常用函数,标签,指令,宏总结(持续更新)
极端常用: UnityObjectToClipPos(v.vertex); 最基本的顶点变换,模型空间 ==>裁剪空间 mul(unity_ObjectToWorld, v.vertex); 顶 ...
- Unity3D -- shader光照常用函数和变量
上一篇记录了shader常用函数和变量,这篇记录一些光照计算时常用函数和变量 1.内置的光照变量 _LightColor0 float4 //该Pass处理的逐像素光源的颜色 _WorldSpaceL ...
- [Unity Shader] 常用的数值类型和语义
书看到第八章,跟随写了一些例子,但有些数值类型的使用还是需要特别注意,经常需要查阅,在这里做一下总结. 1 ShaderLab属性类型和Cg变量类型的匹配关系 Color.Vector:float4, ...
- PHP常用函数总结(180多个)[持续更新中...]
PHP常用函数总结 本文源文件(markdown): https://github.com/yanglr/AlgoSolutions/blob/master/PHP常用函数总结(160多个).md 数 ...
- PHP常用函数总结(二)
PHP常用函数总结 数学函数 1.abs(): 求绝对值 $abs = abs(-4.2); //4.2 数字绝对值数字 2.ceil(): 进一法取整 echo ceil(9.999); // 10 ...
- PHP常用函数总结(180多个)
PHP常用函数总结 数学函数 1.abs(): 求绝对值 $abs = abs(-4.2); //4.2 数字绝对值数字 2.ceil(): 进一法取整 echo ceil(9.999); // 10 ...
- CG 内置函数 和 HLSL 内置函数
CG 内置函数 英伟达官网链接: http://http.developer.nvidia.com/Cg/index_stdlib.html absacosallanyasinatan2atanbi ...
随机推荐
- B.大钉骑马走江湖
江湖是什么,对于在象棋界厮杀的大钉来说,江湖就是一个矩阵,他的目标,就是在江湖之中骑着马,从他的位置出发,走到终点. 当然,大钉的马也遵从中国象棋中的“马走日”的规则,而且在矩阵中,也会有一些障碍物, ...
- Delphi ActiveForm发布全攻略
论坛上很多朋友(也包括我)提到ActiveForm的发布问题,都没有得到很好的解决.下面是本人开发ActiveForm的一点经验,拿出来跟大家分享,开发环境为 Win2000Server,IIS5.0 ...
- YTU 2802: 判断字符串是否为回文
2802: 判断字符串是否为回文 时间限制: 1 Sec 内存限制: 128 MB 提交: 348 解决: 246 题目描述 编写程序,判断输入的一个字符串是否为回文.若是则输出"Yes ...
- 启动tomcat时,经常遇到的问题 8080 端口被占用
启动tomcat失败时,弹出的窗口如上,说明8080被某个进程占用了 需要把占用8080端口的进程给kill掉 Win+R 输入运行cmd 打开命令提示符cmd.exe netstat -ano|fi ...
- MYSQL进阶学习笔记五:MySQL函数的创建!(视频序号:进阶_13)
知识点六:MySQL函数的创建(13) 内置函数: 自定义函数: 首先查看是否已经开启了创建函数的功能: SHOW VARIABLES LIKE ‘%fun%’; 如果变量的值是OFF,那么需要开启 ...
- eclipse新建安卓项目helloworld
第一步:安装JDK. 第二步:配置Windows上JDK的变量环境 . 第三步: 下载安装Eclipse . 第四步:下载安装Android SDK (下载Android SDK Manager工具, ...
- poj 1274 The Perfect Stall 解题报告
题目链接:http://poj.org/problem?id=1274 题目意思:有 n 头牛,m个stall,每头牛有它钟爱的一些stall,也就是几头牛有可能会钟爱同一个stall,问牛与 sta ...
- codeforces 673A A. Bear and Game(水题)
题目链接: A. Bear and Game time limit per test 2 seconds memory limit per test 256 megabytes input stand ...
- [Selenium] Explicit wait 方法
(1) new WebDriverWait(driver, 10). until(ExpectedConditions.elementToBeClickable(locator)); (2) ne ...
- 【POJ 2752】 Seek the Name, Seek the Fame
[题目链接] 点击打开链接 [算法] KMP 沿着失配指针扫一遍即可 [代码] #include <algorithm> #include <bitset> #include ...