A C++ port of Wave Function Collapse Tiling

Related tags

Graphics wfc
Overview

Wave Function Collapse in C++

This is a C++ port of https://github.com/mxgmn/WaveFunctionCollapse.

All sample images come from https://github.com/mxgmn/WaveFunctionCollapse

License

This software is dual-licensed to the public domain and under the following license: you are granted a perpetual, irrevocable license to copy, modify, publish, and distribute this file as you see fit.

The sample images are from https://github.com/mxgmn/WaveFunctionCollapse, so they are NOT covered by the above license.

How to get started

git clone [email protected]:emilk/wfc.git
cd wfc
./main.cpp

./main.cpp starts with a shell script that downloads dependencies, build, links, and finally runs the program.

This works on Mac and Linux.

Requirements

C++14. Nothing more, really.

All required third-party libraries are included or downloaded by running ./main.cpp. These are:

Performance

The sample configuration finishes 25% faster than the original version (50 vs 40 seconds).

Tested on a Linux VM, speed may be better on an installed distribution.

Limitations

This port supports everything in https://github.com/mxgmn/WaveFunctionCollapse (as of October 2016), though with slightly different input (.cfg files over .xml, for instance).

The code is not optimized nor well-documented. It could also do with some further cleanup.

Comments
  • Linker fails on Linux

    Linker fails on Linux

    The linking stage fails on Linux (Linux eenie 4.6.0-1-amd64 #1 SMP Debian 4.6.4-1 (2016-07-18) x86_64 GNU/Linux) with the following error:

    /usr/bin/ld: build/main.o: undefined reference to symbol 'floor@@GLIBC_2.2.5' //lib/x86_64-linux-gnu/libm.so.6: error adding symbols: DSO missing from command line collect2: error: ld returned 1 exit status

    Adding -lm to the linker command line solves the issue for me.

    opened by ojensen5115 2
  • Unable to find

    Unable to find ".bmp" on Linux

    When I attempt to run wfc.bin with no arguments causes it to exit with the following error:

    date       time         ( uptime  ) [ thread name/id ]                   file:line     v| 
    2016-10-03 15:13:44.435 (   0.000s) [main thread     ]             loguru.hpp:1620     0| arguments: ./wfc.bin
    2016-10-03 15:13:44.435 (   0.000s) [main thread     ]             loguru.hpp:1623     0| Current dir: /home/ojensen/bin/WaveFunctionCollapse/c-port/wfc
    2016-10-03 15:13:44.435 (   0.000s) [main thread     ]             loguru.hpp:1625     0| stderr verbosity: 0
    2016-10-03 15:13:44.435 (   0.000s) [main thread     ]             loguru.hpp:1626     0| -----------------------------------
    2016-10-03 15:13:44.435 (   0.000s) [main thread     ]               main.cpp:1085     0| Running all samples in samples.cfg
    2016-10-03 15:13:44.435 (   0.000s) [main thread     ]               main.cpp:1091     0| { 
    Stack trace:
    5             0x405dda ./wfc.bin() [0x405dda]
    4       0x7f21d619b2b1 __libc_start_main + 241
    3             0x4051d5 ./wfc.bin() [0x4051d5]
    2             0x446c9e ./wfc.bin() [0x446c9e]
    1             0x443dd8 ./wfc.bin() [0x443dd8]
    0             0x442ad4 ./wfc.bin() [0x442ad4]
    ------------------------------------------------
    [ErrorContext]                main.cpp:780   loading sample image: ".bmp"
    ------------------------------------------------
    2016-10-03 15:13:44.435 (   0.000s) [main thread     ]               main.cpp:783   FATL| .   CHECK FAILED:  rgba != nullptr   
    Aborted
    

    It appears that paths to the bmp files are not getting constructed correctly on this platform, leading the program to attempt to load ".bmp" which does not exist. Copying one of the sample bmps into the current directory and renaming it to ".bmp" allows it to be processed, provided that the "output" directory is also manually created.

    opened by ojensen5115 1
  • Added virtual destructor -- works now on my mac

    Added virtual destructor -- works now on my mac

    Hi Emil. Thanks for your code, it worked for me with just one change.

    On my mac, llvm was complaining about the virtual destructor and also the program was crashing. Adding the destructor actually fixed both.

    opened by olegklimov 0
  • Running ./main.cpp results in illegal instruction message

    Running ./main.cpp results in illegal instruction message

    Tried running ./main.cpp without any modifications to the program. The following output was generated:

    image

    I am running this on Mac, with C++17.

    Wondering if I am missing certain specifications or if there is something I can do to fix this.

    opened by amylh 0
  • Running ./main.cpp doesn't work with alternative shells

    Running ./main.cpp doesn't work with alternative shells

    Having the script in the .cpp file with no shebang makes the file unexecutable with an alternative shell like fish.

    Easily fixable by adding #!/bin/bash

    opened by mtizim 0
  • fails with same input while C#

    fails with same input while C# "original" generates results

    i wrote a script to generate the neighbor relations automatically based on faces of the tiles and some other inout i generate data for circuits as .xml and .cfg and run the WaveFunctionCollapse(C#) and wfc(C++) binaries

    WaveFunctionCollapse(C#) generates new patterns every time while wfc does not

    for different data.. namely by removing a few tiles from the generated data.cfg wfc generates it just fine

    i uploaded the sample directory i used as well as the data and samples files here http://nikky.moe/wfc/ this is the latest generated stuff i made sure it generates xml and cfg in parallel from the same input

    could somone either fix whatever behaves differently or point me to which lines in the data.cfg break it so that i can adjust my script?

    i doubt it matters but i compile and run the binaries on linux 64bit

    opened by NikkyAI 1
  • Add a Travis CI config

    Add a Travis CI config

    I also suggest to add this fancy badge in the README.md:

    Build Status

    [![Build Status](https://travis-ci.org/emilk/wfc.svg?branch=master)](https://travis-ci.org/emilk/wfc)
    
    opened by yvan-sraka 1
  • Support JSON config files

    Support JSON config files

    Make this project able to accept configuration in XML just like the original, so that porting of config files isn't necessary. As for the library, TinyXML 2 might be a good candidate.

    opened by VelocityRa 15
Owner
Emil Ernerfeldt
Rust coder at Embark Studios. Previously worked with physics simulation, games, 3D scanning and cyber security. I am @ernerfeldt on Twitter
Emil Ernerfeldt
Epoxy is a library for handling OpenGL function pointer management for you

Epoxy is a library for handling OpenGL function pointer management for you. It hides the complexity of dlopen(), dlsym(), glXGetProcAddress(), eglGetP

Eric Anholt 577 Dec 19, 2022
Single-header single-function C/C++ immediate-mode camera for your graphics demos

Single-header single-function C/C++ immediate-mode camera for your graphics demos

Nicolas Guillemot 106 Oct 20, 2022
A minimal Direct3D 12 example that draws an animated triangle, written entirely in C-style C++, and all taking place inside a single function.

A minimal Direct3D 12 example that draws an animated triangle, written entirely in C-style C++, and all taking place inside a single function.

Taoufik Rida Bouftass 7 May 3, 2022
Nintendo Switch port of https://github.com/fgsfdsfgs/max_vita

Max Payne Mobile Nintendo Switch port This is a wrapper/port of the Android version of Max Payne Mobile. It loads the original game binary, patches it

fgsfds 31 Dec 10, 2022
Axel Gneiting 1.5k Dec 31, 2022
Port of Doom 3 for PSVITA. (Based on https://github.com/emileb/d3es-multithread )

ABOUT Combination of the excellent dhewm3 and d3wasm projects, now with multithreaded frontend and backend renderering. Forked from: https://github.co

Rinnegatamante 32 Nov 29, 2022
C++17 port of three.js (r129)

threepp (Work in progress) Cross-platform C++17 port of the popular Javascript 3D library three.js r129. Current state of the project Most of the core

Lars Ivar Hatledal 392 Jan 2, 2023
Port of Wolfenstein 3D to the PSP with improved controls, autorun, automap and correct aspect ratio.

wolf3Dpsp Fork of Wolfenstein 3D port for the PSP by Zack and Chilly Willy with improved controls, autorun enabled by default, automap and correct asp

Wesley Daflita 4 Nov 29, 2022
Android port of 3D Pinball for Windows – Space Cadet

SpaceCadetPinball Android port of 3D Pinball for Windows – Space Cadet Based on: https://github.com/k4zmu2a/SpaceCadetPinball TODO Add proper controls

Iscle 108 Dec 31, 2022
A Celeste Classic port for the TI-84+CE and TI-83PCE graphing calculators.

CEleste A Celeste Classic port for the TI-84+CE and TI-83PCE graphing calculators. Usage (A video tutorial for the following steps is also available h

John Cesarz 44 Dec 11, 2022
Wave Function Collapse library in C, plus a command-line tool

wfc Single-file Wave Function Collapse library in C, plus a command-line tool License: MIT Version: 0.01 This is an early version that supports the ov

krychu 314 Dec 29, 2022
Superposition Wave Function Visualization for free particle

Superposition Wave Function Visualization for free particle This is a cross platform software that visualizes the Amplitude(the square root of PDF) an

Mohammad Ali 4 Nov 27, 2022
Sway/I3 inspired tiling window manager for Wayfire

Swayfire Sway/I3 inspired tiling window manager for Wayfire. This project aims to emulate and improve upon sway/i3wm features as a plugin for the Wayf

Javier Pollak 156 Dec 16, 2022
Maintained fork of the Openbox WM with support for tiling and others

Maintained fork of the Openbox WM with support for tiling and others

null 10 Jun 27, 2022
Hypr is a tiling window manager written in modern C++.

Hypr is a Linux tiling window manager for Xorg. It's written in XCB with modern C++ and aims to provide easily readable and expandable code. !WARNING:

vaxerski 709 Jan 4, 2023
Port-Fin(port finder) is a tool which scans for open and closed port on a website/host.

Port-Fin(port finder) is a tool which scans for open and closed port on a website/host. This tool scans the state of the well known/common ports.

AnonabdulJ 4 Dec 14, 2021
Control connected devices with the wave of a finger.

FUI (Finger User Interface) is a part of the TensorFlow Lite for Microcontroller Experiments, a collection of open source, interactive projects designed to demonstrate some fun ways to combine Arduino and TensorFlow Lite for Microcontrollers.

Google Creative Lab 42 Nov 21, 2022
Comparing the performance of Wave Digital Filter implementations

WDF Bakeoff Comparing performance between Wave Digital Filters implemented in C++ and Faust. Building First clone the repository and submodules: git c

null 12 Dec 4, 2022
digital audio workstation, instrument and effect plugins, wave editor

Stargate Stargate is a holistic audio production solution, everything you need to make music on a computer. To understand what Stargate is, and why, r

null 303 Jan 1, 2023
The HarmonicExciter is based on a half wave clipper, allow to add harmonics to the source by mix them in.

HarmonicExciter.lv2 The HarmonicExciter is based on a half wave clipper, allow to add harmonics to the source by mix them in. Dependencys libcairo2-de

Hermann 9 Jan 2, 2022