0
votes

I'm trying to use the GLM mathematics library to warp the projection matrix such that multiple cameras (e.g. a left eye and a right eye) are viewing the same view, but the camera frustum is distorted.

This is what I am trying to do with my cameras using GLM:

image enter image description here

Note: One of the challenges I have for my camera, is that I only have in my OpenGL Graphics API a read-only view matrix and projection matrix. So even once I have the view and projection matrix, I can only move my camera using x,y,z for eye position, and then yaw,pitch,roll for view direction. Then I have standard OpenGL calls, but I am not sure how to shift or warp the projection matrix as shown below.

I think this second picture also accurately shows what I am trying to achieve with OpenGL.

Any tips on how to approach this problem? Do I need to implement a special lookAt function, or is there something built into GLM that can help me compute the right view?

enter image description here

1
"I can only move my camera using x,y,z for eye position," - To achieve the above affect, you need to move the camera position and change (tilt) the line of sight. - Rabbid76
@genpfault what is the difference? - Makogan

1 Answers

0
votes

A possible way to do this is:

  • Assume that X is the position of the "nose" (the half point between the 2 eyes).

  • Let V be the direction orthogonal to the left eye - right eye line.

  • The function X + t * V describes the "line of sight" in your last picture.

  • Take t > 0 and set that as your look at point P/

  • Create 2 cameras with centers at the eyes, both with the exact same up direction, then use glm::lookat to look at P.