Building Procedurally in Unity: Techniques for generating diverse structures, materials, geometry, objects, and animations.

Learn Unity Procedural Building

Learn to build procedurally using the Unity game engine. Various techniques will be used from algorithms that work through the process of collapsing grid placements to generating street blocks with diverse building prefabs.

Procedural materials take up less storage space than bitmap textures but must be “baked” during the build process in order to run smoothly. They can however expose variables that can be changed at runtime to offer many variations.

Procedural Materials

Procedural materials are custom scripts that generate textures. Each one has a set of properties that expose variables that can be changed at runtime in much the same way as standard Unity shaders.

These variables can be used to vary the output of the material – for example changing how many courses bricks are in a wall or how dark the mortar is. This allows for infinite variations in a single material.

Procedural textures also tend to take up less space in storage than bitmap images. This can help reduce download times for online games.

Unity provides an easy-to-use scripting interface for creating procedural materials called Substance. This is a industry standard tool from Allegorithmic that is also used in other 3D modeling applications (check out their Asset Store 8 FREE Substances package). There are also a number of procedural texture packages available for sale on the asset store. They can be purchased individually or as a pack and are ideal for getting started.

Procedural Geometry

Rather than building 3D meshes by hand using art software, procedural geometry is modelled in code. It can be computed at runtime (like in the example above where the bridge is generated based on elapsed game time), at edit time (using a script or tool inside the 3D art software) or at build time by using a physics engine.

The BP function that generates the rock is structured slightly differently than the one that generated the plane; instead of allocating and releasing its own computed mesh it takes an existing mesh as an argument and uses a filter to transform it (scale, translate, rotate). It also applies a noise function to the result, which gives the surface a smeary look similar to what you might get when blending two photographs together.

Creating a large building using a procedural system can be tricky because you have to consider collisions between the walls, floors and roofs. Unity includes a feature called ProGen that helps with this.

Procedural Objects

Procedural objects are a class of Unity object that can be generated in various ways. Using these types of objects can help developers to build more complex worlds quickly. For example, a designer might want to create a variety of different tree models for use in a video game level. To do this, the developer can create an “imperfect factory” that generates many similar trees based on a set of deterministic parameters and a random seed.

Most Unity games feature procedurally generated buildings. Examples include Naked Sky’s RoboBlitz that used a custom grid system to maximize content in a less than 50MB downloadable file for the Xbox Live Arcade and Will Wright’s Spore that uses a mix of themes and randomization to create an entire city, including streets, houses, and other structures. Also, many modern survival and open world games use procedural generation to produce a large variety of pixel- or voxel-based biomes. These are often then modified by the player to customize their experience.

Procedural Animation

Procedural animation is the process of automatically generating animation in real-time. It is used to create particle systems (smoke, fire, water), cloth and clothing, rigid body dynamics, hair and fur dynamics, and even character animation.

In the past, animators would create walk cycles manually using a technique called keyframing. This method involves drawing major frames that show prominent changes in the character’s position. The computer then fills in the rest of the frame with smooth interpolation.

In this video we demonstrate how to use Unity’s built in procedural generation system to create a city in your game. This includes generating intersections, bridges, rivers and city blocks with diverse building prefabs. The system also uses a shader to fade buildings that block the player’s line of sight. This helps to make the world feel more realistic and immersive.

Go to the origin page

Leave a Reply

Your email address will not be published. Required fields are marked *