D3DVERTEXELEMENT9的详细解释

struct D3DVERTEXELEMENT9 {
WORD Stream; //Stream No
WORD Offset; //Start of this element in bytes
BYTE Type; //Element type (float1 ... float4, D3DCOLOR, etc.)
BYTE Method; //Tesselation method
BYTE Usage; //Usage of element (position, normal, color, etc.)
BYTE UsageIndex; //Suffix number used in the vertex shader
};
Stream
The stream number is nothing more than an index to the data stream from which this
element will be interpreted. During rendering it is possible to have several active
streams at the same time. With the concept of multiple streams it becomes possible
to mix and match data from several sources (vertex buffers) to the final vertex shader.
Offset
This is the byte offset in the data input stream to the data you want interpreted to a
specific vertex element. In a vertex buffer, for example, the position data is usually
in the beginning of each element (i.e., at offset zero). The position contains three
float values each containing four bytes. This means that whatever vertex data follows
the position data, it will be located at offset 12.
Type
The type of the vertex element tells the vertex shader how to interpret the data
stream. It also tells the vertex shader how much data to read in from the stream
(since each type also has a corresponding size). The list of different vertex element
types is long—see the DirectX documentation for the entire list. However, some of
the most important types are listed in Table 8.1. Knowing these are enough for you
to understand the examples in this book.
Method
The method member in the vertex element structure deals with tessellation only
and is beyond the scope of this book.
Usage
More important than the type is the usage of the data. The value of this member in
the D3DVERTEXELEMENT9 structure will define how the vertex shader uses the data.
The ones you need to know for this book are listed in Table 8.2 (of course there are
more than these; again, see the DirectX documentation for the entire list).
TABLE 8.1 VERTEX ELEMENT TYPES
Type Description
D3DDECLTYPE_FLOAT1 A single float value
D3DDECLTYPE_FLOAT2 Two float values corresponding to the D3DXVECTOR2 structure
D3DDECLTYPE_FLOAT3 Three float values corresponding to the D3DXVECTOR3 structure
D3DDECLTYPE_FLOAT4 Four float values corresponding to the D3DXVECTOR4 structure
D3DDECLTYPE_D3DCOLOR Four bytes (DWORD) mapped to RGBA in the shader
D3DDECLTYPE_UBYTE4 Four unsigned bytes
TABLE 8.2 VERTEX ELEMENT USAGE
Type Description
D3DDECLUSAGE_POSITION Position of the vertex (X, Y, Z)
D3DDECLUSAGE_COLOR Color of the vertex (R, G, B, A)
D3DDECLUSAGE_NORMAL Vertex normal (X, Y, Z)
D3DDECLUSAGE_TEXCOORD Texture coordinate (U, V)
D3DDECLUSAGE_BLENDWEIGHT Blend weights for hardware skinning
D3DDECLUSAGE_BLENDINDICES Blend indices for hardware skinning
UsageIndex
The usage index tells the vertex shader which index the data belongs to. For example,
in the case of multiple positions being sent to the same vertex shader, the UsageIndex
is used to tell them apart. They are then referred to POSITION0, POSITION1, POSITION2,
etc. according to the usage index.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值