Derivation of cegui projection matrix

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

fedyakin
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Thu Apr 17, 2008 06:13
Location: Arizona, United States of America

Derivation of cegui projection matrix

Postby fedyakin » Fri Nov 19, 2010 05:46

Hello,
I've been trying to reverse engineer the values in the projection matrix created in OgreRenderTarget::updateMatrix and failing. There are a few things that have me stumped so far.
1) The location of non-zero values in the projection matrix don't match those in my (very limited) understanding of perspective and ortho projection matrices.
2) There are two magic numbers that I can't figure out the meaning behind.
Below is my best guess at what is in the matrix

Code: Select all

k1 = 3.732050808
k2 = 0.267949192431123
(k1*w)/h,      0,      0,            -h/(2*k2)
0,             -k1,    0,             h/(2*k2)
0,             0,      -1.666666,     0
0,             0,       1,            h/(2*k2)


The reason I am trying to figure this out, is I believe the projection matrix might be slightly wrong. I have been testing our engine using nvidia's stereo 3d and all but the interface work perfectly. My best theory is that the projection matrix is resulting in incorrect w values. In case it matters this is using cegui 0.7.2 and "CEGUI::OgreRenderer - Official OGRE based 2nd generation renderer module".

Can anyone shed some light on how the transformation matrix was derived?

ps: The -1.66666 is the result of a fair bit of math involving the near and far distances, but all the terms cancel out and the result is -5/3

User avatar
CrazyEddie
CEGUI Project Lead
Posts: 6760
Joined: Wed Jan 12, 2005 12:06
Location: England
Contact:

Re: Derivation of cegui projection matrix

Postby CrazyEddie » Sat Nov 20, 2010 14:01

Off the top of my head, I can't actually remember. I'll try to remember to look at it and report back when I have some information :lol:

CE

fedyakin
Not too shy to talk
Not too shy to talk
Posts: 22
Joined: Thu Apr 17, 2008 06:13
Location: Arizona, United States of America

Re: Derivation of cegui projection matrix

Postby fedyakin » Sat Dec 04, 2010 19:37

I have made a little progress on getting things working in stereo 3d. There is a note in nvidia's best practices paper (http://developer.download.nvidia.com/whitepapers/2010/NVIDIA%203D%20Vision%20Automatic.pdf) that states that scissor clipping is not performed per eye. I happened to notice that the geometry buffer enables scissor clipping, so I commented out that line. Once I did that, some of the interface renders correctly in stereo 3d. :)

I'm still investigating the remaining broken windows, but perhaps blaming the projection matrix was hasty. Thanks for looking at it, and I hope you didn't waste to much time.

// I think that the 3.732050808 in the projection matrix might be the cot (a/2) with a=30 degrees.


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 6 guests