Jump to content
  • Advertisement
Sign in to follow this  
deadlyquantizer

Regarding pre-transformed vertices

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I am presently working on a 2D game based on a custom built C++/Lua engine. This engine was using pre-transformed vertices (D3DFVF_XYZRHW). With further development, we are planning to include full screen and render to texture Shader effects in the game. To enable this, I needed to convert the pre-transformed vertices to transformable ones so that it will be passed to the vertex shader. I am having problems while doing this. I shall include the steps I have gone through for this conversion Removed the pre-multiplication of height and width · Converted the SetFVF parameters to XYZ and modified the Vertex2D structure · Added the Projection matrix and setting it to orthographic with the following parameters Width =1.0, height =1.0, clipnear =1, clipfar =100 · Setting look at and updating the view matrix with parameters EyePos(0.5, 0.5,5), lookat(0.5,0.5,0), Up(0,1,0). NOTE: As you can see, I need the view to be centered at (0.5,0.5) and the top left and bottom right as (0,0) and (1,1) respectively. Just to be on the safer side, while flipping Z, I am setting the D3DRS_CULLMODE to D3DCULL_NONE. · Setting world matrix as Identity The main problem I am facing is There is a shift of the center of the view from the original (0.5,0.5) with topleft as (0,0) to a center of (0,0) along with a flip in Y axis. So I am getting the display only in the lower right quadrant. The display is of the upper right quadrant of the game. I get a proper view when I give these values for SetLookAt(math::Vec3(0,0,5), math::Vec3(0,0,0), math::Vec3(0-1,0)) . As you can see the center is shifted. Can you please help me out regarding this? Have I missed out on anything here? What am I doing wrong? How do I proceed with finding the solution? Thanks in advance. Regards, Sharath Sridhar

Share this post


Link to post
Share on other sites
Advertisement
The projection matrix you are using is transforming the vectors into clip space: [-1, -1, 0]-[1, 1, 1]. You can scale the lower-right quadrant to fill the viewport and flip the y-axis with a custom viewport matrix:
 2  0  0  0
0 -2 0 0
0 0 1 0
-1 1 0 1
Apply this after (or post-compose it into) the projection matrix.

(Edit: That needed transposing)

Admiral

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!