Skip to content

Instantly share code, notes, and snippets.

View namkazt's full-sized avatar
🗿

Nguyen Dac Nam namkazt

🗿
View GitHub Profile

Generating Procedural Game Worlds with Wave Function Collapse

Wave Function Collapse (WFC) by @exutumno is a new algorithm that can generate procedural patterns from a sample image. It's especially exciting for game designers, letting us draw our ideas instead of hand coding them. We'll take a look at the kinds of output WFC can produce and the meaning of the algorithm's parameters. Then we'll walk through setting up WFC in javascript and the Unity game engine.

sprites

The traditional approach to this sort of output is to hand code algorithms that generate features, and combine them to alter your game map. For example you could sprinkle some trees at random coordinates, draw roads with a brownian motion, and add rooms with a Binary Space Partition. This is powerful but time consuming, and your original vision can someti

@ciro-unity
ciro-unity / MainLightNode.cs
Last active October 24, 2020 06:47
A custom node for Unity's ShaderGraph to capture lighting and use it into the shader. Works as of July 2018, but the APIs might change!
//This API to create new nodes has been deprecated in early 2019.
//This means that if you are on a more recent version of Shader Graph and Universal Render Pipeline, you should use instead a pre-made node, which acts like a container that allows you to inject custom HLSL code into Shader Graph without the need to create a node from scratch.
//Please use the new node, not the C# API described here.
//
//You can find more details about that node in the Docs: https://docs.unity3d.com/Packages/com.unity.shadergraph@6.7/manual/Custom-Function-Node.html
//I also blogged about it here: https://connect.unity.com/p/adding-your-own-hlsl-code-to-shader-graph-the-custom-function-node
//
//If you are still on a very old version of Lightweight Render Pipeline (you shouldn't!!), you can still see the C# code for this custom node by rolling back to a previous version.