How to tell which ortho view you're looking through

I’m building a third-party renderer add-on and am having trouble figuring out how to get orthographic views to work right in the viewport. I’m pulling data from context.space_data.region_3d, and my perspective camera is working alright but I have no idea how to figure out how to get similar data for the orthographic views. Any tips would be appreciated!

I’m going to answer my own question here - basically, I wasn’t fully understanding how to read the data from the viewport. An inverted view_matrix will give you the world matrix of the camera (which is 0, 0, 0 for an orthographic camera) then you have to do some fun math with the view_distance, lens, and sensor size to figure out the ortho_scale value (which is more or less the “depth” component, if you can even call it that).

Apparently every render engine has a different solution for this, and mine looks nothing like what I’ve seen others like Renderman or LuxCoreRender do. Because it’s so different for everyone I won’t post my own maths to avoid confusing people.

But, ultimately, the inverted view_matrix will give you everything you need as far as orientation goes for your ortho camera.

1 Like