# [3D Printing Lens Hoods: The Maths Behind a Parametric Tool](https://blog.hirnschall.net/canon-lens-hood/)

author: [Sebastian Hirnschall](https://blog.hirnschall.net/about/)

meta description: How long can a 3D printed lens hood be before it vignettes? AOV maths, tulip and tubular hood geometry, and a parametric OpenSCAD tool for Canon EF/EF-S.

meta title: 3D Printed Lens Hoods — Optimal Length Maths (Canon)

date published: 25.05.2026 (DD.MM.YYYY format)
date last modified: 25.05.2026 (DD.MM.YYYY format)

---

Motivation
----------

If you are into both photography and 3D printing, you will sooner or later think about printing lens hoods for your lenses. After all, they are not that cheap and just a plastic cylinder.

However, after measuring and drawing the mounting system, the real problem becomes apparent: how long can the hood be before we get vignetting?

Answering this question is not easy, as the manufacturer provides little information about the lens and basically none for the commercially available hoods.

In this article we will explore the maths behind camera AOV, how long an optimal lens hood can be before it blocks light from hitting the sensor, and the differences between tubular and tulip hoods. Furthermore, we implement a parametric [OpenSCAD tool hosted on Thingiverse for basically all Canon EF and EF-S lenses (both tubular and tulip)](https://www.thingiverse.com/thing:7357205).

Naming Conventions
------------------

For this project we will position the coordinate system at the first lens vertex. \(z\) will point towards the image plane, \(y\) will point upwards, and \(x\) will point to the right. Some projects, especially in computer graphics, have \(y\) pointing downwards. As long as we know the used convention, it does not matter.

Furthermore, we will measure angles in degrees, not radians.

FOV Cone Apex Position
----------------------

Looking online, we can quickly find that the camera sees a cone with angle of view \(\varphi\). Its apex is positioned at the entrance pupil.

However, after talking to Bill Claff, I learned that this is apparently still a simplification.

### Off-Axis Parallel (Marginal) Rays

In addition to the chief ray, we need to consider off-axis parallel rays (marginal rays) that may hit the sensor at different angles. If we were to construct the hood using the AOV and entrance pupil as the apex position, we would block these rays. This is something we do not want.

### Vignetting

If we make the hood too large or long, we will start to see vignetting, i.e. the corners of the image will be darker than the center as the hood starts blocking light from the corners in.

Optical Data and Ray Tracing
----------------------------

As mentioned in the motivation, the data we need is not provided by the manufacturer directly. There is, however, [the Photons to Photos Optical Bench](https://www.photonstophotos.net/GeneralTopics/Lenses/OpticalBench/OpticalBench.htm), which we can use to compute basically all the necessary optical data from the lens patent information.

The optical bench tool does this by doing ray tracing using Snell's law of refraction.

More information on this approach can be found in the [Photons to Photos optics primer](https://www.photonstophotos.net/GeneralTopics/Lenses/Optics_Primer/Optics_Primer.htm).

For our use case we will do some additional postprocessing using python.

Tulip vs. Tubular Hoods
-----------------------

The two main types of lens hoods are tubular and tulip-shaped. Both have their place, but in general a tulip is closer to the optimal shape.

Let's look at both designs, their advantages, and when to use which. We start with the simpler, tubular design.

### Tubular Hoods

There are several reasons you might choose a tubular hood:

* **Rotational symmetry**: When the lens hood mounting flange rotates during use, e.g. on lenses that do not have internal focusing like the EF-S 18-55mm kit lens, we must use a rotationally symmetric hood.
* **Long focal length**: For lenses with a long focal length, the AOV becomes narrow and thus the theoretically possible hood becomes extremely long. If we cap the length at some reasonable value, we end up with a tubular hood.

#### Maximum Hood Length

As the lens is rotationally symmetric, the image is a circle with radius \(r\). So, we can compute the AOV and compensate for off-axis parallel rays by tracing them from their starting position at the image plane with height \(y\_{IP}=r\).

Once we have found the AOV and the cone apex position, we can compute the maximum hood length starting at the hood mounting flange. For this we first have to compute the distance from the first lens vertex to the hood mounting flange as

$$\begin{align}
R &:= P +(I -44-L\_{measured}) - \tau + \tilde{d}
\end{align}$$

where \(P\) is the entrance pupil location, \(I\) is the sensor location, \(44\) is the distance between the sensor and the EF mounting flange, \(L\_{measured}\) is the measured distance from the hood mounting flange to the EF mounting flange, \(\tau\) is an additional safety margin, and \(\tilde{d}\) is the distance between the chief ray and the outermost parallel off-axis ray in the \(z\)-direction. This is illustrated in fig. 1.

![Distance from the first lens vertex to the hood mounting flange](https://blog.hirnschall.net/canon-lens-hood/resources/img/recess.jpg)


Figure 1: Distance from the first lens vertex to the hood mounting flange

Now, given the AOV \(\varphi\) and the inner diameter of the hood \(D\_{inner}\), we can compute the maximum hood length as

$$\begin{align}
L\_{\max} = \frac{D\_{inner}}{2} \tan(90-\varphi/2) - R.
\end{align}$$

Looking at fig. 2 we see where the above equation comes from.

![Maximum tubular hood length in the x-z plane](https://blog.hirnschall.net/canon-lens-hood/resources/img/hood-x-z.jpg)


Figure 2: Maximum tubular hood length in the x-z plane

### Tulip Hoods

Compared to a tubular hood design, the tulip shape conforms more closely to the actual image the camera sees. The main reasons to use this design are:

* **Better performance**: In theory, this design should block more unwanted light than a tubular hood. How much this actually improves performance in practice is something I am not sure about.
* **Wide-angle lenses**: For wide-angle lenses a tubular hood is basically useless. A tulip shape blocks unwanted light in the \(y\) direction while not blocking the wide angle of view in the \(x\) direction.

#### Hood Shape and Length

The construction is somewhat similar to the tubular hood. However, we will differentiate between \(x\) and \(y\) directions. Furthermore, we will not use the image circle radius as a starting position for the chief and off-axis rays, but rather the half sensor size, again in both \(x\) and \(y\) directions. To make things even more complicated, we will do so for both APS-C and full-frame sensors.

After we have computed the AOV \(\varphi\) and the distance between the chief ray and the outermost parallel off-axis ray \(\tilde{d}\), we can start to construct the actual FOV cone in 3D CAD. Note that we will use the subscripts \(x\) and \(y\) to distinguish between the two directions.

Once the FOV cone is constructed, we can subtract it from a tubular hood with a user-defined length \(L\_{\max,\text{user}}\). This way \(L\_{\max,\text{user}}\) is the maximum length for the tulip hood.

As a final touch, we can cut the tips of the tulip hood to avoid thin, hard-to-print walls that would result from cutting the tubular hood at a sharp angle. To do so we can compute the correct height to cut as

$$\begin{align}
R &= P +(I -44-L\_{measured}) - \tau + \tilde{d}\_y \\
h\_x &= \frac{D\_{inner} \tan(90-\varphi\_x/2)}{2}\\
d\_y &= \frac{h\_x}{\tan(90-\varphi\_y/2)}.
\end{align}$$

Note: In practice we will compute \(h - R\), for \(h\in\lbrace h\_x, h\_y\rbrace \) directly by intersecting the outermost marginal ray with the \(z\) axis.

Again, the figure below (fig. 3) illustrates the equations above.

![Tulip hood tip clipping in the y-z plane](https://blog.hirnschall.net/canon-lens-hood/resources/img/hood-y-z.jpg)


Figure 3: Tulip hood tip clipping in the y-z plane

Hood Mounting Geometry
----------------------

Unfortunately, the hood mounting geometry seems to not be standardized among Canon lenses (as far as I know). There are two- and three-lug designs.

For now, the user will have to measure the lug diameter themselves. The video shows what we have to measure. For two lenses measuring takes about three minutes.

OpenSCAD
--------

For this project I have decided to go with OpenSCAD for the 3D modeling. This way we can upload a parametric model to Thingiverse and have it be customizable without download.

However, OpenSCAD, especially 2019.5 used by Thingiverse, has aged poorly when compared to e.g. a modern OpenCascade wrapper.

For this project the lack of a revolve function for less than \(360^\circ\) was a hiccup. To fix this, we can work around it by doing \(360^\circ\) revolves and intersecting them with a circle segment of the desired angle.

In OpenSCAD, this can be achieved as shown below.

```
module angle_wedge(angle, r) {
    polygon(concat(
        [[0, 0]],
        [for (a = [0 : 10 : angle]) [r * cos(a), r * sin(a)]],
        [[r * cos(angle), r * sin(angle)]]
    ));
}

module partial_rotate_extrude(angle) {
    intersection() {
        rotate_extrude()
            children();
            
      translate([0,0,-500])
        linear_extrude(1000)
            angle_wedge(angle, 1000);
    }
}
```

Hoods Printed so Far
--------------------

So far, I have printed and tested hoods for the following lenses:

* [Canon EF 70-300mm F4-5.6 IS II USM](https://www.thingiverse.com/thing:7357680)
* [Canon EF 28-80mm F3.5-5.6 II](https://www.thingiverse.com/thing:7357679)
* [Canon EF-S 18-55mm F3.5-5.6 IS II](https://www.thingiverse.com/thing:7357678)
* [Canon EF 50mm F1.8](https://www.thingiverse.com/thing:7357641)

Conclusion
----------

For my first project dealing with real-world optics, the parametric hood design worked out great!

Furthermore, I got the chance to talk with and learn from other people who know much more than me when it comes to this topic, which is always the biggest upside.

For now the tool only supports Canon EF/EF-S lenses as that's what I own. The hood shape calculation is not dependent on the specific lens model or manufacturer; the hood mounting geometry is.

If a hood mount does not rotate, the tulip shape seems to be optimal. If the user specifies a small \(L\_{\max,\text{user}}\), the shape will degenerate into a tubular hood by design.

Lastly, we have successfully compensated for marginal rays. In practice we take the outermost marginal ray's free-space segment (before it enters the first element), extend it, and intersect it with the \(z\) axis. The intersection point is the effective cone apex for that field angle. This sidesteps the entrance pupil entirely, along with the field-angle dependence of its apparent position.