Roughly a week ago, I uploaded my second extension for automatic1111’s Stable Diffusion Web UI called Seamless Tile Inpainting. It uses Stable Diffusion’s inpainting model to turn regular texture images into perfectly connecting, seamless tiles.
How it Works
If you select “horizontal only” or “vertical only” for Tiling Direction, the process behind the scenes is somewhat simple:
- The original image is split into two halves (either vertically or horizontally depending on your setting) and the halves are swapped.
- The seam in between the two halves is inpainted over (the size of the inpainting mask is determined in the extension settings).
- Optionally, the two halves of the image are swapped back again (the result will be seamless either way).
However, if you select “both directions” for Tiling Direction, things get more complicated:
- The original image is split into 4 parts, and they are rearranged like this:
2. A plus-shaped mask is applied to the image to be inpainted (the size of the mask is determined in the extension settings):
3. Optionally, after inpainting, the image is split and swapped back into its original place:
Note that when using “both directions” as your Tiling Direction, there are very tiny seams visible where the pieces reconnect:
This is not intentional, and it’s only an issue when using “both directions” as your Tiling Direction (“horizontal only” and “vertical only” work perfectly). I will try to fix this at some point by automatically doing another round of inpainting along the affected areas, but for now the tiles generated with “both directions” will merely be “seam-less” rather than perfectly seamless.
Use Cases
This tool will be useful for anyone working on a tile-based video game, or anyone designing a product with repeating patterns. Here are some ideas specifically for video games:
- Create a tileset for a top-down or side-scrolling game.
- Make unique tiles for ladders or other vertical structures, even in a game that’s not strictly tile-based.
- Use for texturing with 3D models.
- Make seamlessly-connecting textures in a game engine using a BSP (Binary Space Partitioning) map editor, like the Source engine or Doom.
Inspiration
I was inspired to make this extension while working on Package Panic for Ludum Dare 53. You can read my blog post here to see my whole workflow for that game jam, but this part in particular is what made me think to make this tool: