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
need help with doing viewport transformation in vertex shader
Started by grunt123, Nov 27 2012 02:22 PM
1 reply to this topic
Sponsor:
#2 Members - Reputation: 323
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;
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;






