I recently used Ogre::Camera::setCustomProjectionMatrix to add Camera skew to my project by modifying slightly the Projection matrix generated by Ogre.
When I give back that custom matrix to Ogre there is a problem concerning the rendering of my shader based skybox that wasn't there before.
(Ogre 2.1 branch, under linux with, of course, OpenGL 3+ and glsl shader)
After investigation I found that Ogre::Frustum::calcProjectionParameters seems to be wrong when a custom projection matrix is used :
Code: Select all
if (mCustomProjMatrix)
{
// Convert clipspace corners to camera space
Matrix4 invProj = mProjMatrix.inverse();
Vector3 topLeft(-1.0f, 1.0f, 0.0f);
Vector3 bottomRight(1.0f, -1.0f, 0.0f);
topLeft = invProj * topLeft;
bottomRight = invProj * bottomRight;
left = topLeft.x;
top = topLeft.y;
right = bottomRight.x;
bottom = bottomRight.y;
}
Code: Select all
if (mCustomProjMatrix)
{
// Convert clipspace corners to camera space
Matrix4 invProj = mProjMatrix.inverse();
Vector3 topLeft(-0.5f, 0.5f, 0.0f);
Vector3 bottomRight(0.5f, -0.5f, 0.0f);
topLeft = invProj * topLeft;
bottomRight = invProj * bottomRight;
left = topLeft.x;
top = topLeft.y;
right = bottomRight.x;
bottom = bottomRight.y;
}
Thanks to this modification, my skybox was corrected.
To verify it, simply check the result of left, top, right and bottom values for custom projection matrix by calling
Code: Select all
myCamera->setCustomProjectionMatrix(true, myCamera->getProjectionMatrix() );
Could someone merge this modification ?