Hugin tutorial - Creating tileable textures

Hugin can be used to create seamless tileable textures. All you need is a photo of a repeating pattern.
This tutorial has been prepared using hugin-2015.0.0, but will be the same for any version of hugin from hugin-2013.0.0.

Here is a copy of an image of a repeating pattern. The image is of a tiled wall in the Alhambra palace and fortress in Granada.

tile

A 1D linear tile

To create a 1D linear tileable texture we will be joining images left to right.

The first thing we need to do is ensure that the photo is straight, so after loading the image into hugin we add some vertical and horizontal control points.

straighten

Load the photo again (Photos tab, Add images...) so it is in the project twice, and check the details in the photos tab to ensure that both images have identical lens and position parameters.

Ensure that you are in the Expert interface, as we are going to need access to optimisation tools that are only available in that interface. Add some control points between the two images. Locate your control points so that the images align correctly on the repeating pattern and so that the seam avoids any features in the image that might interfere with the repeating pattern.

Here we locate the control points so the overlap avoids the corner at the left of the photo.

join

In the Photos tab set Optimize -> Custom parameters, then open the Optimizer tab and lock Yaw, Pitch and Roll for both images. This can be done by right mouse click on each of the headings and choosing Unselect all. We only need to optimise TrX for the second image, so right mouse click on X(TrX) and choose Select all, then click on Optimize now!.
Open the Fast Panorama preview window, go to the Crop tab and select Autocrop.
We can now stitch the panorama to get an extra wide double version of our straightened photo with a nice blended seam down the middle.
To get better tonal variation in the blended seam we can raise the number of blending levels setting the enblend option to -l 29. We do this in the Stitcher tab by clicking on the enblend Options button and adding -l 29 to the Command line options, then click OK.
Click on Calculate Optimal Size then Stitch!.
In an image editor, crop the stitched image so that the seam is still down the middle and the left and right edges are the same.

2D tiles

We can't use four copies of our 1D tile for 2D tiling as the enblend seams won't line up at each end, so what we need to do is load our 1D linear tile into a new hugin project and align it vertically to create a 2D tileable texture.

2d-align

This time we optimise TrY

optimise

and after stitching and cropping we have a 2D tile. Note that when cropping the left and right edges should be the same, as should the top and bottom edges to ensure seamless tiling.

2Dtile

This tutorial has used materials provided by Bruno Postle. Bruno's notes are available here, and images and other resources are available here (note this is approx 23MB zip file).
Tutorial has been prepared by Terry Duell, May 2015.