This Python script generates textures using the Wave Function Collapse algorithm. The configuration for the generation process is done through a config.toml
file.
- Clone the repository:
git clone https://github.com/Schleifinho/wave-function-collapse-texture-generator.git
- Navigate to the project directory:
cd wave-function-collapse-texture-generator
- (Optional) Create and activate a virtual environment:
python3 -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts\activate`
- Install the required dependencies:
pip install -r requirements.txt
Run the script with the following command:
python main.py
Ensure that config.toml is present in the same directory as the script.
The configuration file config.toml
allows customization of various parameters. Below is the structure and explanation of each section in the configuration file.
- NUMBER_OF_TILES: Number of tiles to be used in the generation (default: 7).
- WIDTH: Width of the generated texture in tiles (default: 32).
- HEIGHT: Height of the generated texture in tiles (default: 32).
- TILE_SIZE: Size of each tile in pixels (default: 64).
- BG_COLOR: Background color for the texture (default: 0).
- BORDER_MODE: Mode for handling borders (default: 1, None = 0, Seamless = 1).
- IMAGE_PATH: Path to save the final generated image (default: "final.jpg").
Defines the adjacency rules for tiles in the North-South direction.
- row1 to row7: Lists of boolean values representing valid adjacencies.
Defines the adjacency rules for tiles in the East-West direction.
- row1 to row7: Lists of boolean values representing valid adjacencies.
- FOLDER: Path to the folder containing tile images.
- TILE_IMGS: List of filenames for tile images.
An example config.toml
:
[DEFAULT]
NUMBER_OF_TILES = 7
WIDTH = 32
HEIGHT = 32
TILE_SIZE = 64
BG_COLOR = 0
BORDER_MODE = 1
IMAGE_PATH = "final.jpg"
[NORTH_SOUTH]
row1 = [true, false, false, true, true, false, true]
row2 = [false, true, true, false, false, true, false]
row3 = [true, false, false, true, true, false, true]
row4 = [false, true, true, false, false, true, false]
row5 = [false, true, true, false, false, true, false]
row6 = [true, false, false, true, true, false, true]
row7 = [true, false, false, true, true, false, true]
[EAST_WEST]
row1 = [true, false, true, true, false, false, false]
row2 = [false, true, false, false, true, true, true]
row3 = [false, true, false, false, true, true, true]
row4 = [false, true, false, false, true, true, true]
row5 = [true, false, true, true, false, false, false]
row6 = [true, false, true, true, false, false, false]
row7 = [false, true, false, false, true, true, true]
[TILES]
FOLDER = "./ex_tiles"
TILE_IMGS = ["0.png", "1.png", "2.png", "3.png", "4.png", "5.png", "6.png"]
This project is licensed under the MIT License. See the LICENSE file for details.