AutoWFC is a powerful Unity plugin that utilizes the Wave Function Collapse algorithm to generate intricate and diverse tilemaps effortlessly. With AutoWFC, you can create tile-based environments with ease, thanks to its range of features. These features include the ability to learn from existing tilesets and specific regions of a tilemap. Additionally, AutoWFC includes a custom editor window called the "Pattern Explorer," which allows you to visualize and analyze the relationships within the current tileset model.
-
Wave Function Collapse: AutoWFC implements the Wave Function Collapse algorithm, a powerful technique for generating tilemaps based on input constraints. It ensures that the resulting tilemaps obey the provided rules and exhibit the desired patterns.
-
Tileset Learning: AutoWFC allows you to feed it with existing tilesets, enabling the plugin to learn from their patterns and relationships. This learning capability helps the algorithm generate tilemaps that closely resemble the input tilesets.
-
Region-based Learning: In addition to learning from entire tilesets, AutoWFC can focus on specific regions of a tilemap for learning purposes. This feature is particularly useful when you want to maintain the characteristics of a specific area in your generated tilemap.
-
Pattern Explorer: AutoWFC provides a custom editor window called the Pattern Explorer. This tool allows you to explore and visualize the relationships and patterns present in the current tileset model. By examining these patterns, you can fine-tune the behavior of the generation process to achieve the desired results.
To install AutoWFC via the git URL, follow these steps:
- Open the Unity Package Manager (Windows/Package Manager).
- Add
https://github.com/Menchen/AutoWFC.git#upm
to the Package Manager.
To manually install AutoWFC, follow these steps:
- Clone the AutoWFC repository.
- Locate the folder named
Packages/me.menchen.autowfc
in the cloned repository. - Copy the entire
me.menchen.autowfc
folder. - Navigate to the project where you want to install the package.
- Find the
Package
folder within the project. - Paste the copied
me.menchen.autowfc
folder into thePackage
folder.
To get started with AutoWFC, follow these steps:
- Prepare your Tilesets: Move the sprite sheet into a folder named
Resources
. Slice the tileset as you would normally do using the Sprite Editor, and make sure thatRead/Write
is enabled underAdvanced
before saving. - Attach Wfc Helper Component: Add the
Wfc Helper
component to the same game object as theTilemap
. - Set Tile Output Folder: Prepare a folder where the generated tiles will be stored for use by WFC.
- Create Model: Under the
Wfc Helper
, create a new model from the tile set by specifying the tile set in theTile Set
field. Alternatively, you can enable grid selection by clicking onClick Here to toggle grid selection
, select a region by dragging in the scene view, and useCreate new model from selection
. - Generate Tiles: After training a model, select a region in the tile map by enabling
Click Here totoggle grid selection
and then dragging the selection in the scene view. Once you have an active selection, pressGenerate tiles from model
.
During step 5, you can generate variants by pressing Generate tiles from model
again or undo the generation with Ctrl/Cmd-Z
. If you want to train more information into an existing model, you can press Train from selected region
. To delete a relationship, select a region of size 2 and press Unlearn from selection
. Alternatively, you can manually modify the patterns in the Pattern Explorer by pressing Open Pattern Explorer
.
To open the Pattern Explorer, follow these steps:
- Click on
Open Pattern Explorer
in theWfc Helper
or access it through the menu bar by selecting "Windows/WFC Pattern Explorer".
In the Pattern Explorer, you can perform the following actions:
- Selecting a Tile: By dragging a tile to the center position, you can view its neighbors' hash, entropy, frequency, and more. Hovering the mouse over a tile displays the direction it belongs to and its hash. By dragging a tile to one of the four direction buttons, you can toggle its relationship with the center tile in that direction.
If you encounter any issues, bugs, or have suggestions for improvements, please feel free to create an issue. Contributions, pull requests, and feedback from the community are highly appreciated and welcomed.
AutoWFC is released under the MIT License, granting you the freedom to use, modify, and distribute the plugin according to the terms of the license.
AutoWFC was inspired by and built upon the foundational concepts of the Wave Function Collapse algorithm. We would like to express our gratitude to the original creators and contributors of the algorithm for their groundbreaking work.