Is it possible to apply xy lens offsets to a camera, effectively shearing the camera frustum? I fear this functionality is not built in.
Here’s how this is handled in cinder:
For now, I am passing lens shift offsets from UCameraComponent all the way down to the FReversedPerspectiveMatrix, like so:
FORCEINLINE FReversedZPerspectiveMatrix::FReversedZPerspectiveMatrix( float HalfFOVX, float HalfFOVY, float MultFOVX, float MultFOVY, float MinZ, float MaxZ, FVector2D shift )
: FMatrix(
FPlane( MultFOVX / FMath::Tan( HalfFOVX ), 0.0f, 0.0f, 0.0f ),
FPlane( 0.0f, MultFOVY / FMath::Tan( HalfFOVY ), 0.0f, 0.0f ),
FPlane( -shift.X, -shift.Y, ((MinZ == MaxZ) ? 0.0f : MinZ / (MinZ - MaxZ)), 1.0f ),
FPlane( 0.0f, 0.0f, ((MinZ == MaxZ) ? MinZ : -MaxZ * MinZ / (MinZ - MaxZ)), 0.0f )
)
{ }
This appears to be working as expected. (Not sure why the signs have to be flipped.) The debug draw frustums are unchanged however. This may require further modifications.
Thank you for providing such a solution.
Can you be more specific in UCameraComponent detail how to change it? Thank you~
When using this, it appears as if my camera is rotated at the same time and doesn’t correctly line up with the shift I am applying?