Changing the "output offset" of a 3D camera #15506
Unanswered
kozanryusui
asked this question in
Q&A
Replies: 1 comment
-
For what it's worth, this is my current working solution.
It's basically a copy of PerspectiveProjection that will offset its output in the same way that changing a transform for an orthographic projection would. There is some aspect ratio magic going on to adjust for different FoVs of different maps, so that the offset property can have the same units as the othographic projection's transform. All 3D models require to be spawned with the NoFrustumCulling component because I couldn't be bothered to adjust get_frustum_corners accordingly. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using a mix of orthographic and Pbr cameras to intermingle 3D models and 2D sprites. All backgrounds and various objects are rendered using an orthographic projection, and all 3D objects need the correct perspective that results from the 3D camera being located in a specific position. The 3D camera cannot be moved because the change in 3D perspective would break the coherence between the 2D and 3D objects.
I now want to implement scrolling as the player moves across the field. For the 2D camera this is easy because I can just move the camera around via its Transform without changing the 2D objects.
The only practical solution I found for the 3D camera (which I assume works but have not tried yet) would be to create a new CameraProjection. The new projection would be same as PerspectiveProjection except for its get_clip_from_view function, which would return a modified projection matrix that also translates everything by the same amount that the 2D camera's position has been changed. This should preserve the perspective of all 3D objects and just move the camera's output around.
Is there another more straightforward way of achieving the same result?
Beta Was this translation helpful? Give feedback.
All reactions