- Home /
Off center projection matrix does not move skybox
Hello all,
in the Android app I'm currently writing I have two views of the same scene next to each other in landscape mode. I'm using 2 cameras (one for each eye), each using half of the view port. The cameras have an offset to each other to get a real 3D effect. Everything works fine up to this point.
Now I need to take different eye distances into account. For a display of 4" width, the default eye distance is 2". My eye distance for example is more than 2.5". To accomodate for this, I move the center of the view off center of the view port to the outside (or to the inside for a smaller-than-default eye width).
For this, I change the projectionMatrix of the camera like this:
void moveProjectionMatrix(float _flShiftValue)
{
Matrix4x4 m4x4Left = m_m4x4OriginalProjectionLeft;
m4x4Left.m02 += _flShiftValue;
m_cameraLeft.projectionMatrix = m4x4Left;
Matrix4x4 m4x4Right = m_m4x4OriginalProjectionRight;
m4x4Right.m02 -= _flShiftValue;
m_cameraRight.projectionMatrix = m4x4Right;
}
I call moveProjectionMatrix()
in Update()
and set the global variables
m_m4x4OriginalProjectionLeft = m_cameraLeft.projectionMatrix;
m_m4x4OriginalProjectionRight = m_cameraRight.projectionMatrix;
in Start()
which works fine. The only problem is, that the skybox is not offset like the cameras. I've read several posts how to fix this, e. g.
http://forum.unity3d.com/threads/152428-Setting-camera-projection-matrix-breaks-shadows-and-skybox http://answers.unity3d.com/questions/17305/Off-centre-projection-matrix-breaks-cascaded-shadows.html
but my mathematical knowledge about matrices etc. isn't good enough to figure out how to fix this.
Any hints would be highly appreciated!
Thanks in advance!
Andreas
Your answer
Follow this Question
Related Questions
Flipping projection matrix problem: It flips everything but the Skybox. How do I fix this? 1 Answer
Skybox not moving (camera issue?) 1 Answer
Screen is 2 cameras with each different properties. 1 Answer
Camera cuts to behind player as I rotate around 1 Answer
Getting other cameras coordinates 1 Answer