About directx3d vertex format d3dfvf_xyzrhw

Source: Internet
Author: User

What is the difference between d3dfvf_xyzrhw and d3dfvf_xyz? I didn't seem to have thought carefully before. I just saw the saying in beginning directx9: The rhw value, which stands for reciprocal of homogeneous W [1], tells direct3d that the vertices that are being used are already in screen coordinates. this value is normally used in fog and clipping calculations and shocould be set to 1.0.

Today, an experiment was conducted to show that if no rhw exists in the vertex structure, direct3d will perform visual, projection, world, and other transformations and perform Ray computing, then you can get the object you have drawn in the window. When the vertex struct contains rhw, as described in the English section above, it tells direct3d that the vertex used is already in the screen coordinate system and does not perform views, projections, world transformations, and light calculations, because the d3dfvf_xyzrhw Mark tells it that the vertex has been processed and directly performs the grating operation on the vertex, any conversion using settransform will be invalid. However, the origin point is in the upper left corner of the customer zone, where X is right, Y is downward, and Z has changed to the pixel depth of Z-buffer.

It is worth noting that d3dfvf_xyzrhw, d3dfvf_xyz, and d3dfvf_normal cannot coexist because the last two marks are in conflict with the previous one. When using this vertex, the system requires that the vertex position has been transformed. That is to say, X and Y must be in the screen coordinate system, and Z must be the pixel depth in Z-buffer. value range: 0.0-1.0, the closest to the observer is 0.0, And the farthest visible place within the observed range is 1.0 [2].

_______________________

[1] rhw indicates the reciprocal (reciprocal) of the W coordinate of the homogeneous point (X, Y, Z, W) (homogeneous point) of the vertex in the projection space ).

[2] You can create X in a program using the following vertex structure, Y is the same, but Z is 0.0f and 1.0f respectively, to see which color points are blocked by which color points, and then exchange the Z values of the two points to see what the situation is.

// Custome color Vertex
Struct colorvertex
{
Float X;
Float y;
Float Z;
Float rhw;
Float psize;
DWORD color;
Const static DWORD fvf;
};
Const DWORD colorvertex: fvf = d3dfvf_xyzrhw | d3dfvf_psize | d3dfvf_diffuse;

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.