Page 1 of 1

Derivation of cegui projection matrix

Posted: Fri Nov 19, 2010 05:46
by fedyakin
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

Re: Derivation of cegui projection matrix

Posted: Sat Nov 20, 2010 14:01
by CrazyEddie
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

Re: Derivation of cegui projection matrix

Posted: Sat Dec 04, 2010 19:37
by fedyakin
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.