Thanks again for the formula. I have always wondered how to use real f-stop values.
It is possible to modify the Cycles AddOn script to do the calculation automatically.
If you do this modification wrong your Cycles may not work any longer.(so make a backup of the scripts you alter.)
Navigate to the python code of the Cycles AddOn.
You need to modify two files. properties.py and ui.py.
In properties.py you are adding a new property that triggers a def when it’s value changes.
In ui.py you are displaying the new property that you have just added above.
In properties.py at approximately line #225 replace the class with this one.
# This def gets called when one of the properties changes state.
lens_in_mm = 35.0
self.aperture_size = (lens_in_mm / self.true_fstop) / 200 #(200 is conversion from diameter to radius and meters at same time)
bpy.types.Camera.cycles = PointerProperty(
name="Cycles Camera Settings",
description="Cycles camera settings",
cls.aperture_size = FloatProperty(
description="Radius of the aperture for depth of field",
cls.aperture_blades = IntProperty(
description="Number of blades in aperture for polygonal bokeh (at least 3)",
cls.aperture_rotation = FloatProperty(
description="Rotation of blades in aperture",
cls.true_fstop = FloatProperty(
description="Calculate aperture size based upon this true f-stop value.",
In ui.py go to line # approximately 273 and add the new property from the class. Remember to make sure the indents match or a python error will occur and Cycles will not load at all.
sub.prop(ccam, "true_fstop", text="F-Stop")
If you do it right, however, you get a new property in the Cycles camera panel with a True F-stop value that calculates the aperture size when you change the f-stop.
NOTE: In this example I have hard coded the Lens to 35mm. Until I can figure out how to read the actual lens data in the updateFstop def this hard code will have to do.