Jump to content

  • Log In with Google      Sign In   
  • Create Account


need help with doing viewport transformation in vertex shader


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 grunt123   Members   -  Reputation: 177

Like
0Likes
Like

Posted 27 November 2012 - 02:22 PM

Hi,

I'm trying to do manual viewport transformation in vertex shader ...

first, i'm setting an identity viewport matrix by doing the following

D3D11_VIEWPORT vp;
vp.Width = 2;
vp.Height = -2;
vp.TopLeftX = -1;
vp.TopLeftY = 1;
vp.MaxDepth = 1.0f;
vp.MinDepth = 0.0f;
g_grcCurrentContext->RSSetViewports( 1, &vp );


and then, in vertex shader, after doing world/view/projection transformation, i do the following (given that i want to render into 1024x1024 viewport with 1.0 maxz and 0.0 minz)

OUT.pos.x = OUT.pos.x * 512.0f + 512.0f * OUT.pos.w;
OUT.pos.y = OUT.pos.y * -512.0f + 512.0f * OUT.pos.w;

I can't think of anything else that i need to do to get this working .... i'd appreciate any help, thx

Sponsor:

#2 AliasBinman   Members   -  Reputation: 413

Like
0Likes
Like

Posted 28 November 2012 - 03:44 PM

The viewport is in pixel coordinates and is used to convert the normalized pixel coordinates from the VS after perspective project into screenspace.

THE VS then shouldn;t need to know anything of the size of the viewport. For a fullscreen effect then the x and Y are in the range -OUT.pos.w to +OUT.pos.w;




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS