# OpenGL Projection matrix for 'Angled' display?

This topic is 5399 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi guys, I'm working on a project involving more than one monitor producing a 3d scene. To simplify things however, I'll keep the example to one display. Basically the issue is that the user will not be looking head-on to the monitor. I want to take this into account in the projection calcs. In a raycaster this is easy to do - simply project from the eye position through the viewport onto the scene, where the eye is NOT necessarily looking straight through the viewport (it may be a metre to the right, for example). I wanted to take the example through to OpenGL, but my knowledge of matrices doesn't help me all the way there. The perspective matrix generation functions assume (naturally) that the viewport moves when the eye does - not what I need. Does anyone have any suggestions? Thanks!

##### Share on other sites
It seems to me that you need a different modelview matrix for each monitor, not a new projection matrix. Unless I have totally misunderstood your problem of course...

##### Share on other sites
Interesting. Sounds like an approach towards some form of "holograms" where each monitor shows a slightly different angle? But i might be totally of here.

if that is the case however, i'd say an ok way to simulate this would be to share all objects towards the left/right along the "right arm" axis of the viewer. This might create the desired effect. But is probably very similar to simply rotating the viewport a bit.

What are you planning to do actually?

##### Share on other sites
Well, basically..

If you look at your screen from the left or right (at a 45 degree angle).. the display should correct itself so it's not distorted, but it draws the image correct (for your viewpoint). So to anyone looking at the display head-on, it would of course look distorted.

A little like those paintings where you have to look at them from a strange angle for everything to come into perspective.

So basically I need to specify the eye position relative to the viewport!

##### Share on other sites
interesting problem indeed. it would surely provide a very cool effect, and really give the feeling your monitor is a window from which youre looking into the scene.

isnt it just a matter of skewing your camera projection matrix? or wouldnt that work considering the homogeneous part of a camera transform matrix?

##### Share on other sites
I'm sure that's the case, I just don't know what I'd need to do to the matrix. My knowledge doesn't quite go deep enough though..

##### Share on other sites
Hmmmmm....

At first glance I thought you'd just want to multiply the standard perspective transform by a rotation matrix, but it's a little more complicated than that, I realise. The reason it's not that simple is because while the sides of your view volume may have been moved around, the near plane is still in the same place - the screen.

You might be able to get it through taking four point-point mappings and then using inverse matrix methods to find the matrix that produces that mapping. You'd probably need to choose your points carefully though (i.e. so that only one mapping could produce them).

##### Share on other sites
Ohh I see. Now it sounds like an attempt to do some form of Screen corection according to the Head position using Motion tracking or similar? Or am i on the wrong track again...

##### Share on other sites
Try using PS as your projection matrix, where S is a skew matrix of the form

1  0 tx 0ty 1 0  0 0  0 1  00  0 0  1

tx=tan(x_skew_angle), ty=tan(y_skew_angle), and P is the normal projection matrix.

I think that should work, with the caveat that you need to reverse the sign of the shew factors to get the expected effect.

##### Share on other sites
i agree with gamecat: that would probably work. why not give it a shot, its easy enough to try.

• 21
• 13
• 9
• 17
• 13