user1020905
user1020905

Reputation: 141

GLSL - perspective correction for stereo view

I'm trying to fix the perspective in GLSL from incorrect

Incorrect

to correct

Correct

In VS I added:

float gradient = 0.5;
mat4 transformGeometry = mat4(1.0, 0.0, gradient, 0.0,
                              0.0, 1.0, 0.0,      0.0,
                              0.0, 0.0, 1.0,      0.0,
                              0.0, 0.0, 0.0,      1.0);
gl_Position = mvp_matrix * transformGeometry * a_position;

I think the result looks ok

Result


BUT after rotating 90 degree right, it doesn't look like as I expected.

Rot90r


After next rotation 90 degree down, it looks even worse.

Rot90d

Upvotes: 2

Views: 217

Answers (1)

user1020905
user1020905

Reputation: 141

Solved - it should be

projectionMatrix * transformGeometry * modelView

instead of the

MVP * transformGeometry

Upvotes: 1

Related Questions