Question

I would like to know if any of you, knows a way to compute two camera matrices (left and right) from a simple camera matrix? In order to have a stereoscopic effect (simulating both eyes of a human being).

Thanks for your help.

Was it helpful?

Solution

All you need to do is move each camera slightly to the left and right of the current camera where "left" and "right" are defined by the camera's view direction.

Given the matrix of the main camera you just need to offset the stereo cameras by half the distance between the eyes. In pseudo code:

leftMatrix.offset.x -= 0.5 * separation;
rightMatrix.offset.x += 0.5 * separation;

Where leftMatrix and rightMatrix are originally copies of the main camera matrix. You may have to swap the +/- over depending on whether you want the model to appear in front or behind the screen.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top