0

I'm trying to render a box where the near face stays perfectly aligned to the corners of the display, but the rest can shear (with perspective) kind of like a parallax effect. Basically exactly like this one.

I found that multiplying my projection matrix by this shear matrix produces the right effect:

Shear = {
   1   0  -cot(theta) 0
   0   1  -cot(phi)   0
   0   0       1      0
   0   0       0      1
}

however the view volume seems to shear around the center of the volume, so as soon as you start rotating, the front face of the box sways outside of the display area.

Maybe I could transform the model or the viewport to compensate, but that seems like cheating. Can this be done with the right projection matrix, or is there a good way to calculate some other translation that needs to be applied to the model view matrix?

1 Answers1

0

first translate the center of the wanted shear to the center, then do the shear and then translate back.

ratchet freak
  • 47,288
  • 5
  • 68
  • 106