Top Related Projects
Level design tools for Unity
Quick Overview
The Syomus/ProceduralToolkit is a collection of C# scripts and utilities for procedural content generation in Unity. It provides a set of tools and algorithms for creating various types of procedural content, such as terrain, vegetation, buildings, and more.
Pros
- Extensive Functionality: The toolkit offers a wide range of features and algorithms for generating different types of procedural content, making it a versatile tool for game development.
- Customizable: The toolkit allows for a high degree of customization, enabling developers to tailor the generated content to their specific needs.
- Well-Documented: The project has detailed documentation, which makes it easier for developers to understand and use the toolkit effectively.
- Active Development: The project is actively maintained, with regular updates and bug fixes, ensuring its continued relevance and reliability.
Cons
- Unity-Specific: The toolkit is designed specifically for use within the Unity game engine, which may limit its applicability for developers working with other game engines.
- Steep Learning Curve: The toolkit's extensive functionality and customization options can make it challenging for new users to get started, especially if they are not familiar with procedural content generation.
- Performance Considerations: Depending on the complexity of the generated content, the toolkit may have performance implications, which developers need to be mindful of.
- Limited Community Support: While the project is actively maintained, the community around the toolkit may be smaller compared to more popular Unity packages, which could make it harder to find support and resources.
Code Examples
Here are a few code examples demonstrating the usage of the Syomus/ProceduralToolkit:
Generating Terrain
// Create a new terrain generator
var terrainGenerator = new TerrainGenerator();
// Set the terrain parameters
terrainGenerator.Seed = 1234;
terrainGenerator.Size = new Vector2Int(256, 256);
terrainGenerator.Frequency = 0.01f;
terrainGenerator.Lacunarity = 2f;
terrainGenerator.Persistence = 0.5f;
terrainGenerator.Octaves = 6;
// Generate the terrain
float[,] heightMap = terrainGenerator.GenerateHeightMap();
This code demonstrates how to use the TerrainGenerator
class to generate a heightmap for a terrain.
Generating Voronoi Cells
// Create a new Voronoi generator
var voronoiGenerator = new VoronoiGenerator();
// Set the Voronoi parameters
voronoiGenerator.Seed = 5678;
voronoiGenerator.Size = new Vector2Int(512, 512);
voronoiGenerator.PointCount = 50;
voronoiGenerator.PointRadius = 0.1f;
// Generate the Voronoi cells
List<VoronoiCell> cells = voronoiGenerator.GenerateCells();
This code demonstrates how to use the VoronoiGenerator
class to generate a set of Voronoi cells.
Generating Maze
// Create a new maze generator
var mazeGenerator = new MazeGenerator();
// Set the maze parameters
mazeGenerator.Seed = 9012;
mazeGenerator.Size = new Vector2Int(20, 20);
mazeGenerator.Complexity = 0.75f;
mazeGenerator.Randomness = 0.5f;
// Generate the maze
bool[,] maze = mazeGenerator.GenerateMaze();
This code demonstrates how to use the MazeGenerator
class to generate a maze.
Getting Started
To get started with the Syomus/ProceduralToolkit, follow these steps:
-
Install the Package: You can install the Syomus/ProceduralToolkit package in your Unity project using the Unity Package Manager. Search for "Procedural Toolkit" in the package registry and install the latest version.
-
Explore the Documentation: The project's documentation provides a wealth of information on the various features and utilities available in the toolkit. Take some time to familiarize yourself with the documentation and the different generators and tools provided.
-
Start Experimenting: Begin by creating a new Unity project and importing the Proce
Competitor Comparisons
Level design tools for Unity
Pros of SabreCSG
- Specialized for CSG (Constructive Solid Geometry) operations in Unity
- Provides a visual editor for real-time CSG manipulation
- Offers advanced features like UV unwrapping and vertex coloring
Cons of SabreCSG
- Limited to CSG operations, less versatile for general procedural generation
- Steeper learning curve due to its specialized nature
- May have performance limitations with very complex geometry
Code Comparison
SabreCSG example:
// Creating a cube brush
Brush cubeBrush = new Brush();
cubeBrush.Bounds = new Bounds(Vector3.zero, Vector3.one);
cubeBrush.Mode = CSGMode.Add;
ProceduralToolkit example:
// Generating a cube mesh
Mesh cubeMesh = MeshDraft.Cube(1f).ToMesh();
GameObject cube = new GameObject("Cube");
cube.AddComponent<MeshFilter>().mesh = cubeMesh;
cube.AddComponent<MeshRenderer>();
While SabreCSG focuses on CSG operations with a brush-based approach, ProceduralToolkit offers more general-purpose mesh generation capabilities. SabreCSG is better suited for level design and prototyping, while ProceduralToolkit excels in algorithmic mesh creation and manipulation.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
Procedural Toolkit 0.2.4-preview
Procedural Toolkit is a procedural generation library for the Unity game engine.
Warning: This is a programming toolkit, editor support is limited.
| GitHub | Asset Store | Issues | Support email
Installation instructions
Requires Unity 2022.3 LTS or later. Tested on Windows, WebGL, Android and iOS.
There are several ways to install Procedural Toolkit:
Package Manager
The best way is to install this library as a Git package using the Package Manager. First, make sure that you to have Git installed and available in your system's PATH.
Then you can add the package using the link below, notice the upm branch at the end of the line:
https://github.com/Syomus/ProceduralToolkit.git#upm
If you don't want to use Git, you can download this library as an archive and install it as a local package.
Asset Store or .unitypackage
The other way is to import a package from the Asset Store or the Releases page. If you have any previous versions of the toolkit installed, it is highly recommended to delete them before importing a newer version.
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()));
}
}
If you are using Assembly Definitions,
you will also need to add ProceduralToolkit
as a reference.
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 :thumbsup: to the issue to indicate this is also an issue for you, and add a comment 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
Runtime/
- 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.
Runtime/Buildings/
- BuildingGenerator: The main generation class. Generates buildings based on input configuration and strategies, reusable. See examples for details.
- ILayout, ILayoutElement, IConstructible, Layout, HorizontalLayout, VerticalLayout: Interfaces and classes used in facade layout generation.
- IFacadePlanner, IFacadeConstructor, IRoofPlanner, IRoofConstructor: Interfaces for strategies controlling the details of the building generation process.
- FacadePlanner, FacadeConstructor, RoofPlanner, RoofConstructor: Serializable wrappers for strategy interfaces.
- ProceduralRoofs: A collection of roof constructors for the building generator.
Runtime/Geometry/
See this wiki page for a matrix of available algorithms.
- Circle2, Circle3, Sphere, Line2, Line3, Segment2, Segment3: Representations of geometric primitives.
- Geometry: Utility class for computational geometry algorithms, contains various point samplers and helper methods.
- Closest2D, Closest3D: Collection of closest point(s) algorithms.
- Distance2D, Distance3D: Collection of distance calculation algorithms.
- Intersect2D, Intersect3D: Collection of intersection algorithms.
- IntersectionType: Enum used in intersection algorithms.
- Intersections folder: Structures containing information about intersections.
Runtime/Geometry/StraightSkeleton/
Classes used in straight skeleton generation.
- StraightSkeletonGenerator: A straight skeleton generator, computes a straight skeleton for the input polygon, reusable. The generation algorithm is loosely based on the work of Tom Kelly (2014) Unwritten procedural modeling with the straight skeleton.
- StraightSkeleton: A straight skeleton representation.
- Plan: Representation of the active plan during generation process.
Runtime/ClipperLib/
The Clipper library. Use PathClipper and PathOffsetter for seamless interoperability with Unity.
Runtime/LibTessDotNet/
The LibTessDotNet library. The recommended use is through the wrapper class Tessellator.
Runtime/FastNoiseLib/
The FastNoise library.
Shaders/
Depending on the installation type, the shader library can be used like this:
#include "Packages/com.syomus.proceduraltoolkit/Shaders/SDF.cginc"
Or like this:
#include "Assets/ProceduralToolkit/Shaders/SDF.cginc"
- 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.
Editor/
- ColorHSVDrawer: PropertyDrawer for ColorHSV.
- MeshFilterExtension: Mesh saving utility available at
MeshFilter context menu > Save Mesh
. - ProceduralToolkitMenu: Submenu with constructors for primitives at
GameObject > Procedural Toolkit
. - RulesetDrawer: PropertyDrawer for CellularAutomaton.Ruleset.
Tests/
Tests for the library
Samples
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 low poly terrain generator based on fractal noise. 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.
- LowPolyTerrainExample: Configurator for LowPolyTerrainGenerator with UI and editor controls.
- LowPolyTerrainExampleEditor: Custom inspector for LowPolyTerrainExample.
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.
Noise
An example demonstrating various noise types from the FastNoise library.
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.
Common
UI prefabs and the skybox material used in examples.
- 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
Top Related Projects
Level design tools for Unity
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot