Shadder and Effect - 2.2 Vertection Data Purpose

zhaozj2021-02-16  54

2.2 Vertection Data Purpose

Read this article shows that you have agreed to the statement

Consider this vertex statement:

D3DVERTEXELEMENT9 DECL [] =

{

{0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_

Position, 0},

{0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_

Normal, 0},

{0, 24, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_

Normal

, 1},

{0, 36, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_

Normal, 2},

D3DDECL_END ()

}

We need a way to define a vertex declared element to the data member of the vertex shader input structure. We define this mapping by specifying the semantics of each data member in the input structure (: usage-type [usage-index]). Semantics pass the type of use and use index identifies an element in the vertex statement. The vertex element of the semantic identifier of the data is an element that is mapped to the data member. For example, the input structure corresponding to the previous vertex declaration is:

Struct vs_INPUT

{

Position: position;

VECTOR NORMAL: NORMAL0;

Vector Facenormal1: Normal1;

Vector Facenormal2: Normal2;

}

Note: If we miss the use index, it means that the use index is zero. For example, position and position0 are the same thing.

The element 0 in DECL is identified by the use of Position and the use index 0, which is mapped to the position. The element 1 in DECL is identified by the use Normal and the use index 0, which is mapped to Normal. Elements 2 in DECLs, identified by Normal and Use Index 1, which are mapped to Facenormal1. Elements 3 in DECLs, identified by use Normal and use index 2, which are mapped to Facenormal2.

Supported vertex shader inputs (INPUT USAGE) Yes:

n position [n] - position

N BlendWeights [N] - Hybrid Weight

n blendindices [n] - mixed index

n Normal [N] - Fifer Vector

n psize [n] - vertex size

n Diffuse [N] - Scattering Color

n Specular [N] - Mirror Color

n texcoord [n] - texture coordinates

Where n is an optional integer located in the interval [0, 15].

Note: Repeat it again, and a few in these use types are not mentioned in this book, such as: BlendWeights, Tangent, Binormal, Blend Indices, and TestFactor.

In addition, for the output structure, we must specify what each member is used. For example, is the data member should be treated as a position vector, color, texture coordinate, etc. The graphics card has no idea unless you enforce it. This also needs to be completed by the semantics of the grammatical:

Struct vs_output

{

Position: position;

Vector Diffuse: Color0;

Vector Specular: Color1;

The supported vertex shader output is:

n position-position

N psize-vertex size

n fog-fog mixed value

n color [n] - vertex color. Note: You can have multiple vertex colors to be output, and these colors can be mixed together to produce the final color.

n texcoord [n] - vertex texture coordinates. Note: Multiple vertex texture coordinates can be output.

Where n is an optional integer located in the interval [0, 15].

[Declaration]: Introduction to 3D Game Programming With DirectX 9.0 "in this article, it is limited to the translator level, and it is inevitable that there is a mistake in the text. Welcome all netizen criticism; this article is only used for learning exchange and reference usage, not to use In any form of commercial use; if you need to reprint the author's consent of the author and the translator, maintain the integrity of the article, indicate the author, translator and source, the author retains all rights to translation. For the consequences of violating the above terms, the translator is not responsible for this. My MSN is raymond_king123@hotmail.com, welcome 3D graphics and games, and friends with a certain graphic programming exchange.

转载请注明原文地址:https://www.9cbs.com/read-23175.html

New Post(0)