著色器設計工具節點Shader Designer nodes

文件這節中的文章包含可用來建立圖形效果之各種著色器設計工具節點的資訊。The articles in this section of the documentation contain information about the various Shader Designer nodes that you can use to create graphics effects.

節點和節點類型Nodes and node types

著色器設計工具會以圖形呈現視覺效果。The Shader Designer represents visual effects as a graph. 這些圖形是透過節點所建置,而這些節點是特別選擇並以精確方式連線,來達到預期的效果。These graphs are built from nodes that are specifically chosen and connected in precise ways to achieve the intended effect. 每個節點都代表資訊片段或數學函式,而其間的連線代表資訊如何流經圖表來產生結果。Each node represents either a piece of information or a mathematical function, and the connections between them represent how the information flows through the graph to produce the result. 著色器設計工具提供六種不同的節點類型 (篩選、紋理節點、參數、常數、公用程式節點和數學節點) 以及數個屬於每種類型的個別節點。The Shader Designer provides six different node types—filters, texture nodes, parameters, constants, utility nodes, and math nodes—and several individual nodes belong to each type. 本節的其他文章會詳述這些節點和節點類型。These nodes and node types are described in the other articles in this section. 如需詳細資訊,請參閱本文件結尾的連結。For more information, see the links at the end of this document.

節點結構Node structure

所有節點都是由通用項目組合所構成。All nodes are made up of a combination of common elements. 每個節點在其右側都至少有一個輸出終端機 (代表著色器輸出的最終色彩節點除外)。Every node has at least one output terminal on its right-hand side (except the final color node, which represents the output of the shader). 代表計算或紋理取樣器的節點在其左側會有輸入終端機,但代表資訊的節點沒有任何輸入終端機。Nodes that represent calculations or texture samplers have input terminals on their left-hand sides, but nodes that represent information have no input terminals. 輸出終端機會連線至輸入終端機,以將資訊從某個節點移至另一個節點。Output terminals are connected to input terminals to move information from one node to another.

輸入的提升Promotion of inputs

因為著色器設計工具最終必須產生 HLSL 原始程式碼,以在遊戲或應用程式中使用效果,所以著色器設計工具節點受限於 HLSL 所使用的類型提升規則。Because the Shader Designer must ultimately generate HLSL source code so that the effect can be used in a game or app, Shader Designer nodes are subject to the type-promotion rules that HLSL uses. 因為圖形硬體主要作用於浮點值,所以不同類型之間的類型提升 (例如,從 intfloat 或從 floatdouble) 並不常見。Because graphics hardware operates primarily on floating-point values, type promotion between different types—for example, from int to float, or from float to double—is uncommon. 相反地,因為圖形硬體同時對多個資訊片段使用相同的作業,所以在較短的輸入數目加長以符合最長輸入大小時進行不同類型的提升。Instead, because graphics hardware uses the same operation on multiple pieces of information at once, a different kind of promotion can occur in which the shorter of a number of inputs is lengthened to match the size of the longest input. 加長方式取決於輸入類型和運算本身:How it is lengthened depends on the type of the input, and also on the operation itself:

  • 如果較小的類型是純量值,則:If the smaller type is a scalar value, then:

    純量值會複寫至大小等於較大輸入的向量。The value of the scalar is replicated into a vector that is equal in size to the larger input. 例如,不論運算為何,在最大運算輸入是三項目向量時,純量輸入 5.0 會變成向量 (5.0, 5.0, 5.0)。For example, the scalar input 5.0 becomes the vector (5.0, 5.0, 5.0) when the largest input of the operation is a three-element vector, regardless of what the operation is.

  • 如果較小的類型是向量,而且運算是乘法 (*、/、% 等等),則:If the smaller type is a vector, and the operation is multiplicative (*, /, %, and so on), then:

    向量的值會複製至大小等於較大輸入之向量的前置項目,而且尾端項目設為 1.0。The value of the vector is copied into the leading elements of a vector that is equal in size to the larger input, and the trailing elements are set to 1.0. 例如,向量輸入 (5.0, 5.0) 乘上四項目向量時,會變成向量 (5.0, 5.0, 1.0, 1.0)。For example, the vector input (5.0, 5.0) becomes the vector (5.0, 5.0, 1.0, 1.0) when it's multiplied by a four-element vector. 這會使用乘法單位 1.0 保留輸出的第三個和第四個項目。This preserves the third and fourth elements of the output by using the multiplicative identity, 1.0.

  • 如果較小的類型是向量,而且運算是加法 (+、- 等等),則:If the smaller type is a vector, and the operation is additive (+, -, and so on), then:

    向量的值會複製至大小等於較大輸入之向量的前置項目,而且尾端項目設為 0.0。The value of the vector is copied into the leading elements of a vector that is equal in size to the larger input, and the trailing elements are set to 0.0. 例如,向量輸入 (5.0, 5.0) 加上四項目向量時,會變成向量 (5.0, 5.0, 0.0, 0.0)。For example, the vector input (5.0, 5.0) becomes the vector (5.0, 5.0, 0.0, 0.0) when it's added to a four-element vector. 這會使用加法單位 0.0 保留輸出的第三個和第四個項目。This preserves the third and fourth elements of the output by using the additive identity, 0.0.

標題Title 描述Description
常數節點Constant nodes 描述您可用來代表著色器計算之常值和插補頂點狀態資訊的節點。Describes nodes that you can use to represent literal values and interpolated vertex-state information in shader calculations. 因為插入頂點狀態 (因此,每個像素都會不同),所以每個像素著色器執行個體都會收到不同版本的常數。Because vertex-state is interpolated—and therefore, is different for each pixel—each pixel-shader instance receives a different version of the constant.
參數節點Parameter nodes 所描述的節點可以用來代表著色器計算中的觀景窗位置、材質屬性、光源參數、時間以及其他應用程式狀態資訊。Describes nodes that you can use to represent camera position, material properties, lighting parameters, time, and other app-state information in shader calculations.
紋理節點Texture nodes 所描述的節點可用來對各種紋理類型和幾何形狀取樣,並以一般方式產生或轉換紋理座標。Describes the nodes that you can use to sample various texture types and geometries, and to produce or transform texture coordinates in common ways.
數學節點Math nodes 所描述的節點可用來執行代數、邏輯、三角,以及直接對應至 HLSL 指令的其他數學運算。Describes the nodes that you can use to perform algebraic, logic, trigonometric, and other mathematical operations that map directly to HLSL instructions.
公用程式節點Utility nodes 所描述的節點可用來執行常見光源計算,以及未直接對應至 HLSL 指令的其他常見運算。Describes the nodes that you can use to perform common lighting calculations and other common operations that do not map directly to HLSL instructions.
篩選節點Filter nodes 所描述的節點可用來執行紋理篩選和色彩篩選。Describes the nodes that you can use to perform texture filtering and color filtering.