DirectX RHW and viewport

Source: Internet
Author: User

We know that viewport is used to set the position and size of the rendered scene in render target, that is, the scene is stretched to the specified viewport. But once used with the pre transformed coordinates, that's another matter. RHW, reciprocal homogeneous W, when we specify the pre transformed vertex coordinates, the W component is called RHW. Usually, after the projection transformation of the vertex in the clip space, the DX will be the coordinates of the clip,clip based on the vertex coordinates of the W component, at the end of the transformation will not be a perspective except. Once the pre transformed coordinates are used, we omit the model, view, projection these transformations, because we tell DX that the coordinates we provide are transformed and have been transformed to the screen coordinates. But DX will still be clipping, so what DX will do is to combine our pre transformed coordinates with RHW value, and viewport transform back to clip space for clipping.

We know that after the projection, we will then pivot the viewport transformation. Then the inverse transformation is multiplied by the inverse of the viewport, then multiplied by the RHW value.

Suppose we have the pre transformed vertex (0, 1), the viewport size is (150, 50), the coordinates of the viewport coordinates are (--), and according to the inverse of the above can be transformed to clip space with the coordinate of (-1, 1, 0, 1). You can see that the coordinates are the upper left corner of clip space.

As you can see from the actual effect, if you use the pre transformed vertex, if you change the viewport position, the effect is similar to clipping, rather than the effect of using a non-convertible vertex as a simple stretch and pan.

I used the DX9 vetices example during the test.

Reference:

Viewports and Clipping (DirectX 9)

DirectX Transformation Pipeline


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.