Giter Site home page Giter Site logo

syomus / proceduraltoolkit Goto Github PK

View Code? Open in Web Editor NEW
2.5K 114.0 218.0 754.72 MB

Procedural generation library for Unity

Home Page: https://assetstore.unity.com/packages/tools/utilities/procedural-toolkit-16508

License: MIT License

C# 97.78% ShaderLab 0.64% HLSL 1.59%
unity unity3d procedural procedural-generation pcg c-sharp

proceduraltoolkit's Introduction

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.

Donate Donate | 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/

Runtime/Geometry/

See this wiki page for a matrix of available algorithms.

Runtime/Geometry/StraightSkeleton/

Classes used in straight skeleton generation.

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/

Tests/

Tests for the library

Samples

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.

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.

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.

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.

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.

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.

An example demonstrating various noise types from the FastNoise library.

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.

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.

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

MIT

proceduraltoolkit's People

Contributors

basmanovdaniil avatar davidfidge avatar lazymammal avatar stevenvergenz 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  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

proceduraltoolkit's Issues

Building Geometry a mess in Unity 2018.1.0b13

Vertices are all over the place, building is destroyed.

Bug report

Faces are flipped, polys drawn to wrong points?
failproceduralbuilding

Steps to reproduce

Run the Buildings scene, witness the destruction.

Saving Generated Objects as Assets

Hi Syomus,

Thank you for such a great Unity tool. I was hoping that you could explain how to save the objects that I have generated in ProceduralToolkit so I can use them in any scene.

Thanks in advance for your response.

Cheers - Chapmania

How to use the toolkit to create procedural terrain generation?

Hi there,
your toolkit looks really good. I'm actually struggling trying to find a way to procedural generate a 3d low poly terrain for a game I'm developing. I'm new to all these concepts and I would appreciate a guide/direction/tutorial from you on how to integrate the script with Unity3D. Do i need to attach the script to a 'terrain' object in Unity? I need to generate a new terrain every time the game starts a place prefabs on it. Unfortunately there is no too much documentation.

I would appreciate any help. Thanks!

SDF: Easing example is broken in the WebGL build

Easing example doesn't work in the current WebGL build.

Steps to reproduce

  1. Open the WebGL build page
  2. Select "Easing"

Note: Creation of internal variant of shader 'Procedural Toolkit/Examples/Easing' failed.
WARNING: Shader
Unsupported: 'Procedural Toolkit/Examples/Easing' - Pass '' has no vertex shader

Building generator not working in 2017.4.0f1 Personal

The building generator is producing lots of noise as can be seen in the image below.

image

Bug report

Building generator is creating correct size buildings but they are not neatly rendered.

Version

  • Unity: 2017.4.0f1 Personal
  • ProceduralToolkit: 0.2.0 (installed from asset store)

Steps to reproduce

  1. Open Buildings scene
  2. Scene looks OK in the editor
  3. Hit play
  4. Generated building looks like the image above (in both Game window and Editor window)
  5. Adjusting parameters changes building correctly by length, width, floors etc. but similar issues are seen in all cases

Feature request

Behaviour as seen at http://syomus.com/ProceduralToolkit/Buildings is the goal

Question

Depending on whether I find something else suitable I may be willing to try to debug this. However, I'm no Unity expert and have not looked at the code here yet. Any pointers as to what might be wrong will help me (or someone else) should I decide to take a look.

Geometry: 2D Point-Line

  • Distance
  • Distance tests
  • Closest point
  • Closest point tests
  • Intersection
  • Intersection tests

Add missing Geometry algorithms

https://github.com/Syomus/ProceduralToolkit/wiki/Geometry-algorithms
http://www.realtimerendering.com/intersections.html

D - Distance
C - Closest point(s)
I - Intersection

2D Line Ray Segment Circle2
Point D, C, I D, C, I D, C, I D, C, I
Line D, C, I D, C, I D, C, I D, C, I
Ray D, C, I D, C, I D, C, I
Segment D, C, I D, C, I
Circle2 D, C, I
3D Line Ray Segment Sphere Circle3
Point D, C, I D, C, I D, C, I D, C, I -
Line I - - D, C, I -
Ray - - D, C, I -
Segment - D, C, I -
Sphere D, C, I -
Circle3 -

Implement Draw.WirePolyline

Create the following methods and appropriate overloads for DebugE, GizmosE and GLE:
WirePolyline(List<Vector3>)
WirePolylineXY(List<Vector2>)
WirePolylineXZ(List<Vector2>)
WirePolylineYZ(List<Vector2>)

Licensing

One thing that might help people who want to use the toolkit is if you explicitly include an open-source license, such as the MIT license. That way, most of the legal questions people might have are already covered, and people will hopefully feel more confident about submitting code to be included.
(If you haven't checked it out before http://choosealicense.com/ is useful.)

Geometry: 2D Point-Ray

  • Distance
  • Distance tests
  • Closest point
  • Closest point tests
  • Intersection
  • Intersection tests

Mesh collider for low poly terrain?

Experimenting with the low poly terrain example, I've added a mesh collider to the "TerrainGenerator" object, as well as a test player to the scene. It appears that the mesh collider is doing something, in that my player isn't falling infinitely, but it's clear that the mesh collider doesn't match the actual rendered "terrain" - my player is essentially up its head, as I walk around the terrain does vary in height, but I soon fall through.

I hoped you might have an idea what could be causing this before I go digging in and debugging.

Implement Draw.WireCircleSector

Create the following methods and appropriate overloads for DebugE, GizmosE and GLE:
WireCircleSectorXY(Vector3 position, float radius)
WireCircleSectorXY(Vector3 position, Quaternion rotation, float radius)
WireCircleSectorXZ(Vector3 position, float radius)
WireCircleSectorXZ(Vector3 position, Quaternion rotation, float radius)
WireCircleSectorYZ(Vector3 position, float radius)
WireCircleSectorYZ(Vector3 position, Quaternion rotation, float radius)

Geometry: 2D Line-Line

  • Distance
  • Distance tests
  • Closest point
  • Closest point tests
  • Intersection
  • Intersection tests

Add Boids Predators ?

Hello,
i just download procedural tool kit, i have to make a group of fishs, they must avoid predators.
I wan't to use boids for that i started to check your boids exemples, how can i introduce predators for the group of objects. I really don't know where to start.

Thanks you

Implement Draw.WirePolygon

Create the following methods and appropriate overloads for DebugE, GizmosE and GLE:
WirePolygon(List<Vector3>)
WirePolygonXY(List<Vector2>)
WirePolygonXZ(List<Vector2>)
WirePolygonYZ(List<Vector2>)

Documentation

In the version history for v0.1.1, it says "improved documentation", but I can't find the documentation anywhere. Is it still available?

Thank you!

MeshDraft.FlatRevolutionSurface throws ArgumentOutOfRangeException with generateUV = false

Both lowerRingUV and upperRingUV are empty:

var draft = new MeshDraft {name = "Flat revolution surface"};
for (int y = 0; y < ringsVertices.Count - 1; y++)
{
var lowerRingVertices = ringsVertices[y];
var upperRingVertices = ringsVertices[y + 1];
var lowerRingUV = ringsUV[y];
var upperRingUV = ringsUV[y + 1];
for (int x = 0; x < horizontalSegments; x++)
{
Vector3 v00 = lowerRingVertices[x + 1];
Vector3 v01 = upperRingVertices[x + 1];
Vector3 v11 = upperRingVertices[x];
Vector3 v10 = lowerRingVertices[x];
Vector2 uv00 = lowerRingUV[x + 1];
Vector2 uv01 = upperRingUV[x + 1];
Vector2 uv11 = upperRingUV[x];
Vector2 uv10 = lowerRingUV[x];
draft.AddQuad(v00, v01, v11, v10, true, uv00, uv01, uv11, uv10);
}
}
return draft;

Geometry: 2D Ray-Ray

  • Distance
  • Distance tests
  • Closest point
  • Closest point tests
  • Intersection
  • Intersection tests

Add a uvmap for MeshDraft.Dodecahedron

All other primitives have a more or less sensible uvmap, Dodecahedron should have one too. Also, it will have to be constructed in some other way, AddFlatTriangleBand is not very convenient in this case.

public static MeshDraft Dodecahedron(float radius)
{
const float magicAngle1 = 52.62263590f;
const float magicAngle2 = 10.81231754f;
const float segmentAngle = 72;
float lowerAngle = 0;
float upperAngle = segmentAngle/2;
var lowerCap = new Vector3[5];
var lowerRing = new Vector3[5];
var upperCap = new Vector3[5];
var upperRing = new Vector3[5];
for (var i = 0; i < 5; i++)
{
lowerCap[i] = Geometry.PointOnSphere(radius, lowerAngle, -magicAngle1);
lowerRing[i] = Geometry.PointOnSphere(radius, lowerAngle, -magicAngle2);
upperCap[i] = Geometry.PointOnSphere(radius, upperAngle, magicAngle1);
upperRing[i] = Geometry.PointOnSphere(radius, upperAngle, magicAngle2);
lowerAngle += segmentAngle;
upperAngle += segmentAngle;
}
var draft = new MeshDraft {name = "Dodecahedron"}
.AddTriangleFan(upperCap, Vector3.up)
.AddFlatTriangleBand(upperRing, upperCap, false)
.AddFlatTriangleBand(lowerRing, upperRing, false)
.AddFlatTriangleBand(lowerCap, lowerRing, false)
.AddTriangleFan(lowerCap, Vector3.down, true);
return draft;
}

Geometry: 2D Line-Ray

  • Distance
  • Distance tests
  • Closest point
  • Closest point tests
  • Intersection
  • Intersection tests

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.