• Create Account

Inverted Projection / Rendertarget Problems

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.

5 replies to this topic

#1Carandiru  Members   -  Reputation: 212

Like
0Likes
Like

Posted 04 January 2007 - 01:29 PM

#2Carandiru  Members   -  Reputation: 212

Like
0Likes
Like

Posted 05 January 2007 - 12:17 AM

Geez could someone say something?

#3Schrompf  Prime Members   -  Reputation: 950

Like
0Likes
Like

Posted 05 January 2007 - 12:30 AM

Have a closer look at the coordinate space section of the D3D documentation. As far as I know, the post-projected Y coordinate is growing down to up, being inverted in respect to the normal texture coord projection you might use. There's no way to achieve a inversion with rotations only. Maybe insert a D3DXMatrixScaling() into the beginning of your projection matrix.

Just guessing, sorry. I remember having that problem one time or the other, too, but I can't dig up the places in my source where I solved it. So it's only a vague hint.

Bye, Thomas

#4Carandiru  Members   -  Reputation: 212

Like
0Likes
Like

Posted 05 January 2007 - 05:22 PM

Well I'm assuming this, but these seems to more of proper way of doing it, and makes more sense.

Rather than rotating the model, I'm just setting a look at matrix to do basically the same thing, but more "naturally".

D3DXMATRIXA16 matView, matProj;

D3DXMatrixOrthoOffCenterLH(&matProj, -RT256, RT256, -RT256, RT256, 0.0f, 5000.0f);
D3DXMatrixLookAtLH( &matView,
&D3DXVECTOR3(0.0f, 5000.0f, 0.0f),
&D3DXVECTOR3(0.0f, 0.0f, 0.0f),
&D3DXVECTOR3(0.0f, 0.0f, 1.0f) );

D3DXMatrixMultiply(&const_cast<D3DXMATRIXA16&>(m_matViewProjOrthoRTx512),
&matView, &matProj);

D3DXMatrixTranslation(&matModel, 0.0f, 0.0f, 0.0f);
D3DXMatrixScaling(&matScale, RT512/RT64, RT512/RT64, RT512/RT64);
D3DXMatrixMultiply(&matModel, &matScale, &matModel);

// Final Model View Projection Matrix //
D3DXMatrixMultiply(&matModelViewProj, &matModel, &m_matViewProjOrthoRTx512);

So I'm assuming this a more proper way of doing this. But really man, it still is inverted, changing the parameters to D3DXMatrixOrthoOffCenterLH be reversed, and negating the up vector in D3DXMatrixLookAtLH still gives me the same confusing problem.

Messing with these parameters gives me different mirrored combinations.

Mirrored X, Mirrored Z
Mirrored X, Correct Z
Correct X, Mirrored Z

But never:
Correct X, Correct Z

Mind bogling confusing. It is probably REALLY simple too I bet. If anyone can lend a helping hand I might just have to honor you as the bestest online buddy I've ever had!

:P

Thanks again,

#5Carandiru  Members   -  Reputation: 212

Like
0Likes
Like

Posted 06 January 2007 - 05:35 AM

bump

#6TheAdmiral  Members   -  Reputation: 1118

Like
0Likes
Like

Posted 06 January 2007 - 06:58 AM

Are you sure you're actually using a left-handed coordinate system? It sounds like you'd be better off using D3DXMatrixOrthoRH. This will flip the direction of your z axis, so you should be able to attain your 'Correct X, Correct Z'.