Sign in to follow this  
schupf

Pretransformed Vertices

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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this