1
$\begingroup$

Orthographic cameras in Blender have the shift_x, shift_y settings:

enter image description here

But these are limited to the value range [-10., 10.]. How can I achieve the same effect as orthographic shift when I need the shift to have magnitude >10?

$\endgroup$
  • $\begingroup$ One option would be to simply move the camera along the axis of the image plane (Transform Orientation set to Local). Not sure if that would be a solution for your particular problem. In what context do you need to use this? $\endgroup$ – Robert Gützkow Aug 28 at 21:25
  • $\begingroup$ That's actually what I've ended up doing (or, at least, I think I have it right; not quite sure yet, hence the question still being open). I was struggling to figure out how to compute the axes, but found I could do so pretty easily with the 4 points returned by docs.blender.org/api/current/…. Context is that I'm procedurally generating 3D buildings composed of individually modeled tiles, then rendering them orthographically, and re-constructing them in a 2D setting outside of Blender to give the illusion of 3D. $\endgroup$ – NeverConvex Aug 28 at 21:26
1
$\begingroup$

I eventually solved this by directly computing a basis for the orthographic plane myself, and moving the camera along the basis vectors as desired. This was relatively easy, thanks to https://docs.blender.org/api/current/bpy.types.Camera.html?highlight=view_frame#bpy.types.Camera.view_frame. For a given camera object cam, I did this by identifying the pair of top-most and left-most vertices in Camera.data.view_frame(), converting these back to world coordinates with Camera.matrix_world, and taking differences to get two orthogonal vectors which correspond to the local X/Y directions in the orthographic plane, but can be manipulated in world-space:

    top_frame_verts = sorted(cam.data.view_frame(), key=lambda v: v.y)[2:]
    left_frame_verts = sorted(cam.data.view_frame(), key=lambda v: v.x)[2:]
    x_axis = cam.matrix_world @ top_frame_verts[1] - cam.matrix_world @ top_frame_verts[0]
    y_axis = cam.matrix_world @ left_frame_verts[1] - cam.matrix_world @ left_frame_verts[0]

I then moved the camera like:

    cam.location -= x_axis * MagnitudeToShiftInX
    cam.location -= y_axis * MagnitudeToShiftInY

These vectors have the further property that setting MagnitudeToShiftInX = 1.0 makes an orthographic camera moved like cam.location -= x_axis * MagnitudeToShiftInX shift a single "camera box" in the indicated direction, so that the new camera frame will just barely border the old camera frame after this translation. That is, they are normalized to the size of the orthographic camera bounding box.

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.