Jump to content
  • Advertisement
Sign in to follow this  
paic

Projected vertex

This topic is 4519 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'm playing with a shader which project a texture onto an arbitrary mesh. In order to generate the texture coordinates, I'm multiplying the vertices' position by the "world * view * projection" matrix. But I have a little difficulty in figuring what the result is ... when I use that : oPosition = mul(iPosition, g_mWorldViewProjection); I thought that oPosition.x and oPosition.y were the coordinates of the pixel in screen space, but it doesn't seem to be the case. Could somebody help me to understand what each component of oPosition is ?? Thx in advance.

Share this post


Link to post
Share on other sites
Advertisement
The visible coordinates are in -1...1 range (clip space) after that operation. Thy are scaled to screen space as specified in the device's viewport parameters, after the vertex shader and before the pixel shader.

Share this post


Link to post
Share on other sites
Ok, so you mean that the oPosition.x and oPosition.y should be in [-1, 1] ? That's also what I thought, but it doesn't seem to be the case. I debugged my shader in Visual to see what was going on, and I had values outside [-1, 1]

Edit: Example : I have a quad, aligned on XZ, on Y = 0. My camera is looking on -Y, and is at (0, 760, 0).
The first vertex is at (50, 0, 50) and after multipying it by "world view proj" the result is something like : (113.124, 120.325, 760.851, 761.152). So It seems like the 2 last values are the depth. But why aren't they the same ? And I absolutely don't understand the 2 first values. My viewport is around 400² ... I see no relation between those values and the viewport size ...
And moreover, when I zoom in / out, those values stay the same. Only the 2 last values changes (the depth if I guessed correctly)

I'm completely lost ^^''

Share this post


Link to post
Share on other sites
That fourth value is the 'w' value. Divide the other 3 values by that one and you will get numbers between -1 and 1.

Share this post


Link to post
Share on other sites
Quote:
Original post by Dave Hunt
That fourth value is the 'w' value. Divide the other 3 values by that one and you will get numbers between -1 and 1.


This is true, I forgot to mention this in my last post.

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!