Tools

Procedural Toolkit

Procedural Toolkit 0.2.2

Procedural Toolkit is a procedural generation library for the Unity game engine.

Warning: This is a programming toolkit, editor support is limited.

Donate Donate | GitHub | Asset Store | Issues | Support email

Installation instructions

Requires Unity 2018.1 or later. Tested on Windows, WebGL, Android and iOS.

You can install Procedural Toolkit from any of the following sources:

  1. Import from the Asset Store
  2. Download from the Releases page. Same packages as in the Asset Store.
  3. Clone/download the repository from GitHub and put it in a subfolder (preferably /Assets/ProceduralToolkit).

If you have any previous versions of the toolkit installed it is highly recommended to delete them before importing a newer version.

Renaming or moving toolkit’s folder from the default path (/Assets/ProceduralToolkit) will break .cginc includes in the example shaders, otherwise it is safe to move the toolkit however you want.

The folder containing example classes and scenes (ProceduralToolkit/Examples) can be safely removed. The same is true for ProceduralToolkit/Shaders, if you are not using examples.

Getting started

After installation you can import ProceduralToolkit namespace and start building your own PCG systems:

using UnityEngine;
using ProceduralToolkit;

public class ReadmeExample : MonoBehaviour
{
    private void Update()
    {
        Debug.Log(string.Format("<color=#{0}>{0}</color>", RandomE.colorHSV.ToHtmlStringRGB()));
    }
}

I have a problem with Procedural Toolkit

First, please search the open issues and closed issues to see if your issue hasn’t already been reported. If it does exist, add a 👍 to the issue to indicate this is also an issue for you, and add a comment to the existing issue if there is extra information you can contribute.

If you can’t find a matching issue, open a new issue, choose the right template and provide us with enough information to investigate further. Alternatively, you can send a message to the support email.

Contributing

See CONTRIBUTING for a full guide on how you can help.

If you’re looking for something to work on, check out the help wanted label.

If you just want to show your appreciation, you can send a donation through PayPal or Ko-fi.

Toolkit structure

Scripts/

  • ArrayE: Various Array and List extensions, such as looped getters/setters and flood fills.
  • CellularAutomaton: Generic cellular automaton for two-state rulesets. Common rulesets can be found in CellularAutomaton.Ruleset.
  • ClipperUtility: Utility class for conversion of Clipper data from and to Unity format.
  • ColorE: Color extensions, HTML colors, Gradient constructors.
  • ColorHSV: Serializable representation of color in HSV model.
  • CompoundMeshDraft: Helper class for mesh generation supporting large meshes and submeshes.
  • DebugE: Collection of drawing methods similar to Debug.DrawLine.
  • Directions: Enum with direction flags along three axes.
  • Draw: Collection of generic vector drawing algorithms.
  • DrawRaster: Collection of generic raster drawing algorithms.
  • GizmosE: Collection of drawing methods similar to Gizmos.
  • GLE: Collection of GL drawing methods similar to Gizmos.
  • MeshDraft: Helper class for mesh generation.
  • MeshDraftPrimitives: Constructors for MeshDraft primitives.
  • MeshE: Mesh extensions.
  • PathClipper and PathOffsetter: Clipper library wrappers.
  • PTUtils: Various useful methods and constants.
  • RandomE: Class for generating random data. Contains extensions for arrays and other collections.
  • RendererProperties: Serializable Renderer properties, use Renderer.ApplyProperties extension to apply them to a target renderer.
  • Tessellator: LibTessDotNet library wrapper.
  • TextureE: Texture extensions.
  • VectorE: Vector extensions.

Scripts/Buildings/

Scripts/Geometry/

See this wiki page for a matrix of available algorithms.

Scripts/Geometry/StraightSkeleton/

Classes used in straight skeleton generation.

Scripts/Clipper/

The Clipper library. Use PathClipper and PathOffsetter for seamless interoperability with Unity.

Scripts/LibTessDotNet/

The LibTessDotNet library. The recommended use is through the wrapper class Tessellator.

Scripts/Editor/

Shaders/

  • Common.cginc: Collection of shaping and debug functions.
  • Easing.cginc: Normalized easing functions.
  • SDF.cginc: Collection of signed distance functions.
  • Transitions.cginc: Collection of transition animations.
  • Gradient Skybox: Simple gradient skybox.
  • Debug folder: Debug shaders for some of the most common mesh channels.
  • VertexColor folder: Textureless shaders for use with color information from the vertices.

Examples

Buildings

A fully procedural building generator, creates an entire mesh from scratch and paints it’s vertices. Keep in mind that the generated mesh has no uv map so using it with Standard shader is pointless.

  • BuildingGeneratorComponent: A simple minimal example on how you can use BuildingGenerator
  • BuildingGeneratorConfigurator: A configurator for BuildingGenerator with UI and editor controls.
  • BuildingGeneratorReuse: An example on how you can reuse the same generator to generate multiple buildings.
  • ProceduralFacadePlanner: A facade planning strategy, controls the layouts of the facades.
  • ProceduralFacadeConstructor: A facade construction strategy, used in conjunction with ProceduralFacadePlanner.
  • ProceduralRoofPlanner: A roof planning strategy, generates a roof description based on the input config.
  • ProceduralRoofConstructor: A roof construction strategy, used in conjunction with ProceduralRoofPlanner.
  • ProceduralFacadeElements: A collection of fully procedural facade panels for the building generator.
  • PolygonAsset: A ScriptableObject container for vertices.
  • BuildingGeneratorConfiguratorEditor: A custom inspector for BuildingGeneratorConfigurator.

Chairs

A fully procedural chair generator, creates an entire mesh from scratch and paints it’s vertices.

  • ChairGenerator: Main generator class. Generates chairs based on input configuration.
  • ChairGeneratorConfigurator: Configurator for ChairGenerator with UI and editor controls.
  • ChairGeneratorConfiguratorEditor: Custom inspector for ChairGeneratorConfigurator.
  • Armrests, Backs, Stretchers: Chair parts constructors.

Low Poly Terrain

A simple Perlin noise based low poly terrain generator. Doesn’t support chunking or anything like that, just an example of how you can use a noise function in a plane generation algorithm.

  • LowPolyTerrainGenerator: Main generator class. Generates terrain based on input configuration.
  • LowPolyTerrainGeneratorConfigurator: Configurator for LowPolyTerrainGenerator with UI and editor controls.
  • LowPolyTerrainGeneratorConfiguratorEditor: Custom inspector for LowPolyTerrainGeneratorConfigurator.

Signed Distance Functions

A collection of shaders showing how you can utilise functions from the shader library.

  • StarPolygon: A simple shader that draws a star polygon and shows a difference between “normal” and “cheap” functions.
  • Shapes: A demonstration of some of the available shapes.
  • DistanceOperations: A square and a circle combined with different functions.
  • Easing: All easing functions in one shader showing the ease curve and the easing motion.
  • Transitions: An example showing the sequencing and animation techniques.
  • Animation: A more complex example on how you can create patterns and animate them in shader.

Cellular Automata

A demonstration of CellularAutomaton from the main library, draws the automaton simulation on a texture. Note that some of the rulesets need noise value different from the default setting.

  • CellularAutomatonConfigurator: Configurator for the automaton with UI controls.

Mazes

A generic maze generator, draws the maze generation process on a texture.

  • MazeGenerator: Main generator class. Generates mazes based on input configuration.
  • MazeGeneratorConfigurator: Configurator for MazeGenerator with UI controls.
  • Maze: Maze graph representation.

Breakout

A Breakout clone with procedurally generated levels.

  • Breakout: Game engine and level generator.
  • BreakoutConfigurator: Configurator for the game with UI controls.
  • Brick: Disables game object on collision.

Characters

A simple 2D character generator. Sprites made by Kenney.

  • Character: A container for sprite renderers
  • CharacterGenerator: Generates a sprite set and a name for character.
  • CharacterGeneratorConfigurator: Configurator for CharacterGenerator.
  • NameGenerator: Generates a random name from a large array of names.

Primitives

A demonstration of some of the available MeshDraft primitives.

  • Cylinder, Dodecahedron, FlatSphere, Hexahedron…: Mesh generators that can be configured via the inspector.

Drawing

Three identical shapes made with three different methods: DebugE, GLE and GizmosE.

Clipper

A simple example demonstrating the api’s of PathClipper and PathOffsetter.

Tessellator

An example showing the usage of Tesselator.

StraightSkeleton

An StraightSkeletonGenerator example showing how you can generate a straight skeleton from a polygon and use the result.

Examples/Resources

UI prefabs and the skybox material used in examples.

Examples/Common

  • SkyBoxGenerator: Skybox generator, assuming that scene uses gradient skybox shader, animates transitions to new parameters every few seconds.
  • ButtonControl, SliderControl, TextControl, ToggleControl: UI controls for generators.
  • CameraRotator: Orbiting camera controller.
  • ConfiguratorBase: Base class for configurators.

License

MIT