# Pretransformed Vertices

This topic is 2925 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello!

I want to draw HUD elements with pretransformed vertices (in Direct3D9 with Shaders) and have some questions about them:

1) Right now I think all I have to do is specifying the 2D vertices as 4D vectors in the range [-1,-1] to [1,1] and set the modelViewProjection Matrix to identity. So for example top left would be (-1, 1, 0, 1) and bottom right would be (1,-1, 0, 1). Is this right?

2) What if I wanted to define my pretransformed vertices in the range (0,0) to (1,1) (like texture coordinates), where (0,0) is top left and (1,1) bottom right? The problem is the viewport matrix, which would lead to wrong results. I found this page about the viewport matrix: http://msdn.microsoft.com/en-us/library/aa915188.aspx.
Lets just look at the x-axis: The pretransformed vertices are scaled by width/2 and then translated by (dwX + width/2). I would set dwX to zero, but the result would be wrong. For example the x-coordinate of the top left point would be 0 and after the multiplication with the viewport matrix it would be width/2 ( 0*width/2 + width/2 ), which is wrong. To put a long story short: If I wanted to define the vertices in the (0,0) to (1,1) range, I would need to skip the translation part of the viewport matrix, am I am right? Is there a way to do this?

##### Share on other sites
([0, 1] - 0.5) * 2 = [-1, 1] (or p * 2 - 1)

No need for matrices

• ### Game Developer Survey

We are looking for qualified game developers to participate in a 10-minute online survey. Qualified participants will be offered a \$15 incentive for your time and insights. Click here to start!

• 13
• 30
• 9
• 16
• 12