Building a Better Camera in Blender

Edit: Here is the video with the “Breathing Lens” camera rig shot at the end.

Perhaps “better” is not as accurate as “more realistic”. For a long time, I have wished that Blender’s cameras were more like the real world cameras I use. I know other Blender users might share my interests in a more advanced camera, so I thought why not see if we can work together to solve some of the issues we experience?

One such issue I am interested in resolving is DOF in Blender. Specifically, I’m talking about the lens movement that occurs when you pull focus.
The closer you set the focus of a lens, the larger the image becomes, and vice-versa. On most lenses, you will see that the front element physically moves back and forth (Maybe this is true of all lenses; I don’t know if there are any where all the movement occurs internally within the lens.)

In Blender, there exists no mechanism to recreate this characteristic. So, I have made a simple rig to try to compensate for it. Here are my initial results, and in the next post I will explain how I’ve set it up.



This rig is built using constraints. Most of the constraints are simple “child-of”.

First, I have set a master object, which I call “camera_base”. Everything moves when this object moves.
Next, I have an empty called “focus_point”, and an object called “front_element”. Both of these have the child-of constraint, targeted to “camera_base”.
And lastly, I have the camera, which is a child of “front_element”, not “camera_base”.

Now, the only bit that makes the rig useful at all is the “copy location” constraint. This is applied to “front_element” and targeted to “focus_point”. The constraint is only enabled to one axis; in this case it is the Y-axis. It is also set to be inverted.
This means that when you move the “focus_point” empty closer to the camera, the “front_element” object will move in the opposite direction, closer to the empty. And since the camera is parented to that object, it too will also move.
I have deliberately chosen not to move the camera itself, so that you can still apply a noise modifier to the camera’s position if you choose to.



I’ve only just begun to play with constraints, and using armatures is also very new to me. As such, I’m sure that a more robust rig could be built to acheive this very simple action. As it is, when I rotate the “camera base” object, the whole thing gets a bit wonky. Additionally, the amount of movement you want will depend on the scale of your scene.

Having said that, what are your thoughts? I’m currently rendering an animation which makes use of this rig, which will be on my youtube channel later this week.

Did you know that the effect is called “Lens Breathing”? Each lens would have different characteristics and it would be nice to find a way to make a usable table of lenses based on their unique effect. This way you could integrate a Cycles lens pull with a video background plate.

I was going to chime in on breathing too. Most lenses do it, except the really expensive cinema lenses which must be already emulated in Blender :wink: An interesting idea though, and adding ‘imperfections’ like breathing could add something to certain shots.

Yes and it’s ‘really’ bad when using an anamorphic lens!

Maybe I’m missing something (and I probably am) but wouldn’t this be as ‘simple’ as controlling the focal length of the camera with the focal distance using a driver?

mexicoxican- Your add-on looks very handy, I will be checking it out!
And you’re right, I don’t like the clutter that it adds to the scene. I don’t know how drivers work (besides my printer driver!) but I will be googling them soon! Thanks for the suggestion!

3pointEdit and Hammers- Ah, so that’s what lens breathing is! That is a coincidence, I had only first heard the term about a week or two ago, but had no idea what it meant. It did happen to be while I was reading a description of some new cinema lenses on borrowlenses.com

I do like the idea of some kind of table of lens presets that could be used to emulate real-world lenses. That would be an ideal solution. At the moment, I have no idea how to make something like that for Blender, but am more than happy to contribute research toward it.

I managed to whip up a very basic prototype using my incredibly limited knowledge of drivers.

Using this method you only need a camera and an empty acting as the focal point (click the image below to enlarge)
http://i.imgur.com/2RCmI0Ll.jpg

The empty is called “focal”, it is parented to the camera and locked so that it can only move in the local Y-axis. Then I added a driver to the camera’s “Distance” in the DoF tab, the only thing that driver does is that it replaces the distance value with the Y location of the empty based on the distance from the camera.
After that I added another driver to the “Focal length” which is taking the default value of 38.000 and subtracting the distance to the focal point which gives it a correct-looking result. The only problem I have is that the focal length varies slightly based on the camera’s location and I don’t know how to fix that :frowning:

And here’s the blend file in the hopes that someone with a little more knowledge than me can fix it so it behaves properly (it is just an early prototype after all)
http://www.pasteall.org/blend/21562

Outstanding work, NinthJake! I’m sorry, I didn’t see your previous comment until just now.

To answer your first post; I think technically the most accurate way to portray this lens breathing effect is to move the camera, rather than increasing or decreasing the focal length. However, if adjusting the focal length is an easier solution than moving the camera, it would be more than adequate I’m sure. I imagine the visible difference between the two techniques would likely be too subtle to matter greatly.

And I will be checking out your work as soon as I get back home tonight! You worked very quickly!

Check this out http://www.dpreview.com/forums/post/51476166

The Field Of View (FOV) doesn’t always get wider with close focus, it depends on the elements that move. And yes the lens itself gets a little wider or narrower, depending on the construction.

1st, most lenses change FOV when going through the focus range. That is not linked to internal focussing or not. It is not linked to 1:1 ability either. Nor do all lenses, IF or not, show a widening of the FOV at closer focus distances. Some lenses show a widening, some lenses show a narrowing of the FOV. In fact, I am not able to find any clear pattern in focus breathing and lens construction.
2nd misconception: Focal length is not 1:1 linked to FOV. When the focal length of a lens remains steady, you get a clear narrowing of the FOV at close focus. Most people do not realize this. So you should not say that the focal length gets wider, but the FOV (or view angle) gets wider. A lens that shows no focus breathing will change the focal length through the focus range by just the right amount. A reason why cinematic lenses that show no focus breathing are so expensive.

And a great detailed article on why and how:

And a simple on (good for me):

EDIT:
I noticed that the ‘true focal length’ is accurate when focused on infinity (longest barrel of lens?)

It shouldn’t be that hard to switch it around so that the empty controls the camera movement instead of the focal length. I’ll have a look at it soon.

Also thanks for the links @3pointEdit. I’m not really all that familiar with cameras that so I will be taking a look at the simplified version :stuck_out_tongue:

Bottom line is that the focus elements effectively change the length of the lens. So moving the camera wouldn’t be as correct I guess.

truth is, lenses are fantastically complicated optical beasts. trying to model all of the possible variations and understand all of the effects might be an exercise in frustration, for a relatively limited payoff. I’d say, read enough to understand the gist, and get good references to compare to. It’d be fairly easy to get some calibrating shots off of a camera and build a rig to match the effects of the individual lens. this effort would definitely be worth it for compositing into camera tracked footage. I’m just not sure a fully flexible system to control lens breathing would save more time than it would take to create.

Very interesting reading, 3pointEdit! It looks as though you were completely correct NinthJake; adjusting the focal length of the lens itself seems a totally valid method. I stand corrected!

So it would seem that the amount of “breathing” a lens may exhibit is not something that is so simple for us to calculate based off just a few variables.

I agree with you mexicoxican, trying to create presets for even a handful of lenses would likely take a great deal of work. Most likely it is better for us just to “eyeball” our work and approximate the method. That being said, I do still like the idea of having the option to approximate lens breathing.

Perhaps in the near future we will have a slew of animations abusing the “lens breathing” effect in Blender. We could be right up there next to aperture diffraction and solar flares! :eyebrowlift:

I thought breathing was the result of the mechanical nature of lens elements within a single lens when the lens helicoil changes direction? So you would need to pick a specific lens, then model all the glass pieces for that lens with correct raytrace IOR materials and place them stack in front of the Blender camera so it covers the entire FOV. Then it makes sense to link drivers to the Y-location of these glass pieces. As a camera repair technician I have taken apart and reassembled many lenses and the zoom movement is far from linear, however. There is a helicoid shaped guide pattern that each element rides upon sometimes the outer lens moves farther than the inner one. Most lenses have a special notch in the helicoil to lock lens elements in place for macro shots as well.

http://www.popsci.com/files/imagecache/article_image_large/articles/Screen%20Shot%202012-01-13%20at%203.02.29%20PM_0.png

True that. I’m terrified of seeing super exaggerated dolly zooms every single time the focus shifts. though, I will say that I haven’t seen too many people abusing dof blur all that much. I’m almost disappointed. it seems like everyone got their willies out on the old node-based defocus system (which usually looks almost unacceptable), and by the time we got legitmate, realistic dof in cycles, everybody was bored with the effect.

Alright then, I edited my previous scene a bit (actually I remade it from scratch again) so that the focal point (Empty) can’t travel behind the camera because it gave problematic results. I also thought that the zooming on the previous one was a bit extreme so I divided it by 2 and grouped the camera and empty so that you can just append it to any scene, drivers intact and everything.

http://www.pasteall.org/blend/21589

@NinthJake: Cool, that is a nice little rig. When you pull focus, you can see the scale of the object change slightly.

Awesome work, NinthJake! You should be very proud of your work; you came up with a solution that is both effective and elegantly simple. Great job!

If it is alright, I’d like to use your rig to create some extra shots in the new video that I was unable to create with my rig.

Thanks :slight_smile:

@James Candy, sure, you can use it for whatever you want. Beware though that moving the camera changes the focal length will change slightly and I still have no idea why. Also this is by no means physically accurate or anything, I have just kinda winged the settings.