Giter Club home page Giter Club logo

unity-wave-function-collapse's Introduction

Unity WaveFunctionCollapse

A fork of https://github.com/mxgmn/WaveFunctionCollapse with tools for the Unity Game engine.

Installation

Clone this repo under your projets Assets directory, or import a unity package asset from http://selfsame.itch.io/unitywfc.

Usage

video tutorial

https://www.youtube.com/watch?v=CTJJrC3BAGM

Training

Training components define sample data from their child objects. The contained objects must have a prefab connection. Rotation of objects are recorded. The OverlapWFC component will auto compile it's training on Start, in editor mode you will need to use the compile button.

Whitespace (no object) is recorded for the OverlapWFC, but ignored for the SimpleTiledWFC.

NOTE: for SimpleTiledWFC all prefabs must be located within an Assets/Resources directory!

TilePainter

Simple tilemap painting utility to help create training data. To paint, assign it's color prefab property and hover over the canvas region with the TilePainter's object selected.

Adding objects to the palette array will show them below the canvas area, palette or painted tiles can be sampled by holding the [s] key and clicking on them.

Note: You can drag a folder of prefabs from under Assets/Resources onto the palette array!

OverlapWFC

Generates output from a Training sample. On Start will compile it's training component, generate, and run.

NOTE: Using rotation specific tiles will only give nice results for symmetry 1 generation. Personally I like to use rotation for the overlap model, with a larger training area to make up for the loss of symetry variants.

  • seed: 0 for randomized
  • N: size of the overlap patterns (this is hidden in the inspector, as higher values can often freeze Unity)
  • Periodic Input: repeating sample pattern
  • Periodic Output: repeating output pattern
  • Symmetry: sample grid re-read with additional rotation/reflection variations. Note: rotation of sample tiles will only make sense for symmetry-1 output
  • Iterations: 0 will run until finished/unfinishable. Also used by incremental output.
  • Incremental: Runs iterations every update in play mode.

SimpleTiledWFC

This model uses XML data representing legal tile neighbors. The Training component has a "record neighbors" command to generate these files, the file is saved to "Assets/{{trainingGameObject.name}}.xml".

Whitespace is ignored in the neighbor scan, and can be used as margins to isolate neighbors. Training components have a weight array for neighbor xml.

NOTE: Prefabs must be located within Assets/Resources or a subdirectory within.

X I T L

Tile symmetry class can be declared via the last letter of the prefab name, for example "GroundX" or "Road-T".

Note: L tiles have an initial orientation of

OO
OX

API

Both models have a public GameObject[,] rendering; 2d array that stores their output.

unity-wave-function-collapse's People

Contributors

selfsame avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

unity-wave-function-collapse's Issues

better overlap prefab connections

The overlap model instantiates tiles from the sample, meaning that changes to the source prefab will not carry over to existing training samples. Fix this.

Add an option to flip between x-y and x-z plane

The current forced x-y plane from the last commit does not work for generating tiles of models on the x-z plane. To do that it requires reverting to before a62fbda

My suggestion is to add a checkbox somewhere that lets you flip between the 2 planes. If I get around to it I might do it myself and make a pull request :)

SimpleTiledWFC doesn't generate anything

I'm having some trouble getting this to work.

My XML file is generating just fine (https://pastebin.com/8yQQbyKa), however nothing happens if I press generate (or RUN).

Here's a video of me trying to generate from tiles.
https://youtu.be/NRF8oz0E3pg

I also zipped up the project and uploaded it to drive if that helps.

I don't think I'm doing anything wrong, the simple example works just fine. I tried the scripts both before and after running Unity's automatic API update system but the result is the same in both cases.

Very sorry to bother with this since it's probably my fault, but please let me know if I'm doing something wrong.

Need help converting Gridsize to float?

How would I convert Gridsize to float on all the script without getting errors? When I tried to change gridsize to a float in the Traning script, I get

"error CS0266: Cannot implicitly convert type float' to int'. An explicit conversion exists (are you missing a cast?)"

Not sure what to do.

I really need to make my character smaller than 1 meter.

How to use?

Feel free to ask general questions in this issue!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.