• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            天行健 君子當(dāng)自強(qiáng)而不息

            高級(jí)著色語(yǔ)言HLSL入門(mén)(6)

            16.7內(nèi)建函數(shù)

            HLSL有一個(gè)豐富的內(nèi)建函數(shù)的集合,它們對(duì)3D圖形來(lái)說(shuō)非常有用。下表是一個(gè)刪減了的列表,注意:要得到更多的參考,可以參看DirectX文檔中內(nèi)建HLSL函數(shù)的完整列表。

            以下表格中,//<variable>//表示變量variable的模(例如向量的絕對(duì)值)。

            函數(shù)

            描述

            abs(x)

            返回 |x|

            ceil(x)

            返回 ≥ x 的最小整數(shù)

            clamp(x, a, b)

            Clamps x to the range [a, b] and returns the result.

            cross(u, v)

            返回 u × v(叉積)

            degrees(x)

            轉(zhuǎn)換 x 從弧度到角度

            determinant(M)

            返回矩陣M的行列式det(M)

            distance(u, v)

            返回u點(diǎn)和v點(diǎn)之間的距離||v - u||

            dot(u, v)

            返回 u · v(點(diǎn)積)

            floor(x)

            返回 ≤ x 的最大整數(shù)

            length(v)

            返回 ||v||

            lerp(u, v, t)

            在u和v之間線(xiàn)性插值,參數(shù) 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是一個(gè)向量,它被作為一個(gè)行向量,則向量-矩陣(vector-matrix)乘法是已定義的。類(lèi)似的,如果N 是一個(gè)向量,他被作為一個(gè)列向量,則矩陣-向量(matrix-vector)乘法是已定義的。

            normalize(v)

            返回 v/∥v∥

            pow(b, n)

            返回 bn

            radians(x)

            轉(zhuǎn)換 x 從 角度 到 弧度

            reflect(v, n)

            給定向量v和表面法線(xiàn)n,計(jì)算其反射向量

            refract(v,n, eta)

            給定向量v、表面法線(xiàn)n和兩種材質(zhì)的兩個(gè)索引的比率eta,計(jì)算其折射向量. 翻看一下物理書(shū)中Snell的規(guī)則或者在互聯(lián)網(wǎng)上搜索一下關(guān)于refraction(反射)的信息

            rsqrt(x)

            返回x的平方根的倒數(shù)

            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的轉(zhuǎn)置

             

            abs (Direct3D 9 HLSL)

            Computes the absolute value of each component.

            Syntax

            ret abs(x)

            Where:

            Name In/Out Template Type Component Type Size
            x in scalar, vector, or matrix float, int any
            ret out same as input x same as input x same dimension(s) as input x

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_1_4

             

             

            ceil (Direct3D 9 HLSL)

            Returns the smallest integer which is greater than or equal to x.

            Syntax

            ret ceil(x)

            Where:

            Name In/Out Template Type Component Type Size
            x in scalar, vector, or matrix float any
            ret out same as input x float same dimension(s) as input x

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_2_0

             

             

            clamp (Direct3D 9 HLSL)

            Clamps x to the range [min, max].

            Syntax

            ret clamp(x, min, max)

            Where:

            Name In/Out Template Type Component Type Size
            x in scalar, vector, or matrix float, int any
            min in same as input x float, int same dimension(s) as input x
            max in same as input x float, int same dimension(s) as input x
            ret out same as input x float, int same dimension(s) as input x

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_1_4

             

            cross (Direct3D 9 HLSL)

            Returns the cross product of two 3D vectors.

            Syntax

            ret cross(x, y)

            Where:

            Name In/Out Template Type Component Type Size
            x in vector float 3
            y in vector float 3
            ret out vector float 3

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_1_4

             

             

            degrees (Direct3D 9 HLSL)

            Converts x from radians to degrees.

            Syntax

            ret degrees(x)

            Where:

            Name In/Out Template Type Component Type Size
            x in scalar, vector, or matrix float any
            ret out same as input x float same dimension(s) as input x

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_2_0

             

             

            determinant (Direct3D 9 HLSL)

            Returns the determinant of the square matrix m.

            Syntax

            ret determinant(m)

            Where:

            Name In/Out Template Type Component Type Size
            m in matrix float any (number of rows = number of columns)
            ret out scalar float 1

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_1_4

             

            distance (Direct3D 9 HLSL)

            Returns the distance between two points x and y.

            Syntax

            ret distance(x, y)

            Where:

            Name In/Out Template Type Component Type Size
            x in vector float any
            y in vector float same dimension(s) as input x
            ret out scalar float 1

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_2_0

             

            dot (Direct3D 9 HLSL)

            Returns the • product of two vectors, x and y.

            Syntax

            ret dot(x, y)

            Where:

            Name In/Out Template Type Component Type Size
            x in vector float, int any
            y in vector float, int same dimensions(s) as input x
            ret out scalar float, int 1

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_1_1

             

             

            floor (Direct3D 9 HLSL)

            Returns the greatest integer which is less than or equal to x.

            Syntax

            ret floor(x)

            Where:

            Name In/Out Template Type Component Type Size
            x in scalar, vector, or matrix float any
            ret out same as input x float same dimension(s) as input x

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_2_0

             

             

             

            length (Direct3D 9 HLSL)

            Returns the length of the vector x.

            Syntax

            ret length(x)

            Where:

            Name In/Out Template Type Component Type Size
            x in vector float any
            ret out scalar float 1

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_2_0

             

             

            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

            ret lerp(x, y, s)

            Where:

            Name In/Out Template Type Component Type Size
            x in scalar, vector, or matrix float any
            y in same as input x float same dimension(s) as input x
            s in same as input x float same dimension(s) as input x
            ret out same as input x float same dimension(s) as input x

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_1_4

             

             

            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

            ret log(x)

            Where:

            Name In/Out Template Type Component Type Size
            x in scalar, vector, or matrix float any
            ret out same as input x float same dimension(s) as input x

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_2_0

             

            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

            ret log10(x)

            Where:

            Name In/Out Template Type Component Type Size
            x in scalar, vector, or matrix float any
            ret out same as input x float same dimension(s) as input x

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_2_0

             

             

            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

            ret log2(x)

            Where:

            Name In/Out Template Type Component Type Size
            x in scalar, vector, or matrix float any
            ret out same as input x float same dimension(s) as input x

            Minimum Shader Version

            This intrinsic function is supported in the following (or above) shader versions:

            Vertex Shader Pixel Shader
            vs_1_1 ps_2_0

            posted on 2008-04-05 18:05 lovedday 閱讀(7776) 評(píng)論(0)  編輯 收藏 引用


            只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   Chat2DB   管理


            公告

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            隨筆分類(lèi)(178)

            3D游戲編程相關(guān)鏈接

            搜索

            最新評(píng)論

            久久青草国产手机看片福利盒子| 亚洲精品午夜国产VA久久成人| 久久久亚洲AV波多野结衣| 麻豆av久久av盛宴av| 国产69精品久久久久9999APGF| 国产亚洲精品美女久久久| 久久97久久97精品免视看| 亚洲综合伊人久久大杳蕉| 欧美777精品久久久久网| 香蕉aa三级久久毛片| 国产成人无码久久久精品一| 日批日出水久久亚洲精品tv| 久久国产精品77777| 久久人妻少妇嫩草AV蜜桃| AV色综合久久天堂AV色综合在| 性做久久久久久久久| 99精品国产在热久久| 久久婷婷五月综合97色| 日产久久强奸免费的看| 热久久这里只有精品| av色综合久久天堂av色综合在| 精品水蜜桃久久久久久久| 2021久久国自产拍精品| 日产精品久久久一区二区| 国产美女亚洲精品久久久综合| 欧美激情精品久久久久久久九九九| 精品国产VA久久久久久久冰| 国产成人精品三上悠亚久久| 少妇熟女久久综合网色欲| 青青热久久国产久精品| 久久精品无码一区二区日韩AV| 久久香综合精品久久伊人| 久久这里只精品99re66| 亚洲国产成人精品久久久国产成人一区二区三区综 | 国内精品久久久久久野外| 欧美熟妇另类久久久久久不卡| 久久久国产打桩机| 亚洲午夜无码久久久久| 久久精品欧美日韩精品| 国产精品久久久久无码av| 久久免费线看线看|