Wang Tiles Grid generator

Overview

Wang Tiles Grid generator

thumbnail

Quick Start

The project is using nobuild build system.

$ cc -o nobuild nobuild.c
$ ./nobuild
$ ./wang -live

Goal

Trying to generate a random grid of 2-colored Wang Tiles based on a single function definition:

typedef struct { float c[2]; } Vec2f;
typedef struct { float c[3]; } Vec3f;
typedef Vec2f UV;
typedef Vec3f RGB;
typedef uint32_t BLTR;

RGB wang(BLTR bltr, UV uv);

where

  • bltr is a 4 bit mask encoding the specific Wang Tile. Each bit represents a side of the tile in the following order: Bottom, Left, Top, Right. 0 is the first color, 1 is the second one.
  • uv is a 2D vector that represents a point on the tile. Top-Left corner is [0.0, 0.0], Bottom-Right corner is [1.0, 1.0]. Coordinates are normalized and resolution-independant.
  • The result of the function is a 3D vector that represents an RGB color of a pixel on the tile bltr at uv.

Think of it as a Fragment Shader that generates a Texture for a Wang Tile based on its bitmask description.

Phases

The whole rendering is split into roughly 3 phases and done entirely on CPU.

Phase 1. Atlas Rendering

Given the "Shader" function described in the Goal section we generate an atlas (spritesheet) of all 16 Wang Tiles. (4 sides, 2 colors, 2⁴ = 16)

atlas-00 atlas-01

Phase 2. Grid Generation

Given the size of the grid in tiles we generate 2D array of BLTR-s (defined in the Goal section) satisfying the Wang Tile constraints between the tiles (the adjacent side of the tiles must have the same color).

Phase 3. Grid Rendering

After the Atlas and the Grid are generated we iterate over each BLTR in the Grid and copy the corresponding tiles from the Atlas into the final Grid image.

grid-00 grid-01

Screencasts

The development was streamed on Twitch. Here is an archive of screencasts: https://www.youtube.com/playlist?list=PLpM-Dvs8t0VYgJXZyQzWjfYUm3MxcvqR0

You might also like...
Fast, hierarchical, sparse Voxel Grid
Fast, hierarchical, sparse Voxel Grid

Treexy is a library that implements a compact hierarchical data structure that can store and manipulate volumetric data, discretized on a three-dimens

Treexy is a library that implements a compact hierarchical data structure that can store and manipulate volumetric data, discretized on a three-dimensional grid
Treexy is a library that implements a compact hierarchical data structure that can store and manipulate volumetric data, discretized on a three-dimensional grid

Treexy is a library that implements a compact hierarchical data structure that can store and manipulate volumetric data, discretized on a three-dimens

Fast, hierarchical, sparse Voxel Grid
Fast, hierarchical, sparse Voxel Grid

Treexy is a library that implements a compact hierarchical data structure that can store and manipulate volumetric data, discretized on a three-dimens

Real-Time Rendering with Lighting Grid Hierarchy I3D 2019 Demo
Real-Time Rendering with Lighting Grid Hierarchy I3D 2019 Demo

Real-Time Rendering with Lighting Grid Hierarchy I3D 2019 Demo Daqi Lin This demo is for the I3D 2019 paper Real-Time Rendering with Lighting Grid Hie

power-grid-model is a Python library for steady-state distribution power system analysis

Power Grid Model power-grid-model is a Python library for steady-state distribution power system analysis. The core of the library is written in C++.

a simple RPC wrapper generator to C/C++ functions

This project initiated from the following practical problem. To control experimental equipment via computers, manufactures provide software drivers wi

JSON parser and generator for C/C++ with scanf/printf like interface. Targeting embedded systems.

JSON parser and emitter for C/C++ Features ISO C and ISO C++ compliant portable code Very small footprint No dependencies json_scanf() scans a string

A fast JSON parser/generator for C++ with both SAX/DOM style API
A fast JSON parser/generator for C++ with both SAX/DOM style API

A fast JSON parser/generator for C++ with both SAX/DOM style API Tencent is pleased to support the open source community by making RapidJSON available

CLASS Project Generator

zproject - CLASS Project Generator Contents Overview Scope and Goals Tutorial Installation Getting started Setup your project environment Configuratio

Google Protocol Buffers tools (C code generator).

About Google Protocol Buffers tools in Python 3.6+. C source code generator. Rust source code generator ( 🚧 🚧 🚧 under construction 🚧 🚧 🚧 ). prot

C-code generator for docopt language.

C-code generator for docopt language Note, at this point the code generator handles only options (positional arguments, commands and pattern matching

OC EFI Generator for Windows, Coded in C#
OC EFI Generator for Windows, Coded in C#

Opencore EFI Generator for Windows THIS APP IS NOT READY YET, NO FUNCTIONS OR ANYTHING IS ADDED A Utility to create EFI Folder for Opencore bootloader

Single-header, ranges-compatible generator type built on C++20 coroutines

generator Single-header, ranges-compatible generator type built with C++20 coroutines. A generator allows implementing sequence producers which are te

RapidJSON is a JSON parser and generator for C++.
RapidJSON is a JSON parser and generator for C++.

A fast JSON parser/generator for C++ with both SAX/DOM style API

a very based, minimal, and flexible static site generator written in pure C89 with no external deps.

based-ssg is a very based, minimal, and flexible static site generator written in pure C89 with no external deps.

Run-time program generator embedded in C++

Run-time program generator embedded in C++

Generic parse tree, configurable lexer, `lemon` parser generator, wrapped for C++17 and Python 3.
Generic parse tree, configurable lexer, `lemon` parser generator, wrapped for C++17 and Python 3.

This project augments the Lemon parser generator with a high-level parse tree interface, grammar action DSL, and an integrated, configurable lexer allowing the creation of an entire standalone, object-oriented parser from a single input grammar file. The entire parser is written in native C/C++, and the parser interface is made comfortably available to both C++ and Python3 applications.

GPU 3D signed distance field generator, written with DirectX 11 compute shader
GPU 3D signed distance field generator, written with DirectX 11 compute shader

GPU SDF Generator GPU 3D signed distance field generator, written with DirectX 11 compute shader Building git clone --recursive https://github.com/Air

C# bindings for Sokol using Sokol's binding generator

C# bindings for Sokol using Sokol's binding generator

Comments
  • wang-tiles -live runs choppy

    wang-tiles -live runs choppy

    wang-tiles -live runs choppy, even though the rendering takes about 3 ms according to the builtin profiler.

    We shipped this shit, and the customer is really mad. Do you even have QA?!

    1 star.

    opened by samo296 1
Owner
Tsoding
Recreational Programming
Tsoding
Ipsys Particle System Yey letS go, very cool particle system generator and fast renderer

ipsys - Ipsys Particle System Yey letS go About Ipsys is a piece of software that focuces on running and displaying cool randomly generated particule

Anima Libera 5 May 26, 2022
GPU Texture Generator

Imogen GPU/CPU Texture Generator GPU Texture generator using dear imgui for UI. Not production ready and a bit messy but really fun to code. This is a

Cedric Guillemet 709 Nov 21, 2022
Indexes points and lines and generates map tiles to display them

Datamaps This is a tool for indexing large lists of geographic points or lines and dynamically generating map tiles from the index for display. Depend

Eric Fischer 329 Nov 22, 2022
Interactive, thoroughly customizable maps in native Android, iOS, macOS, Node.js, and Qt applications, powered by vector tiles and OpenGL

Mapbox GL Native A C++ library that powers customizable vector maps in native applications on multiple platforms by taking stylesheets that conform to

Mapbox 4.2k Nov 24, 2022
experimental project to create PBF vector tiles

Vector tiles producer This is an experimental project to create vector tiles. What does this do? This creates vector tiles based on the mapnik proto f

vross 31 Nov 25, 2022
This project is a small 2D game with minilibx. You'll learn about textures, sprites and tiles.

(੭。╹▿╹。)੭ so_long This project is a small 2D game with minilibx. You'll learn about textures, sprites and tiles. Preview How play the game To play thi

ChloeKim 10 Aug 16, 2022
This repository contains path planning algorithms in C++ for a grid based search.

This repository contains path planning algorithms in C++ for a grid based search.

null 239 Nov 30, 2022
Off The Grid (OTG) Messenger is an easy way for people to communicate through text messages when in remote areas.

Off The Grid (OTG) Messenger is an easy way for people to communicate through text messages when in remote areas. With a theoretical transmission range of 10 miles (16kms), OTG messenger can be used by groups of people to stay connected when they are in areas not serviced by mobile connectivity.

Trevor Attema 492 Dec 3, 2022
A robot simulation that reads QR codes and uses it for navigation through a grid system.

PathingRobotSim This bad boy gonna read QR code to navigate through a grid system in a simulated enviroment. This is part of my Bachelor's conclusion

Renato Ferreira 2 Nov 17, 2021