Game Development Reference
In-Depth Information
513, 1025, all four corners are set to the same initial height [ Figure 7.18 (1)].
The second step, the diamond step, locates the central vertex where the
diagonals from the initial vertices intersect. Step 3 creates squares between
the central point and previous initial points. Now imagine fold lines
between the red points and the height values assigned to the blue
points shown in green in Figure 7.18 . Blue points determine height,
and green lines are where the mesh is allowed to fold.
The Diamond-Square method continues creating diamonds to find
midpoints and squares for lowering and raising until all points in
the grid have height values associated with them.
Unity Specifics
Unity has a terrain editor plugin that employs the Diamond-Square
algorithm for creating realistic-looking terrains without all the hard work
of sculpting and painting. You can check it out by downloading the
package from
terrain-toolkit .
Perlin Noise is another popular algorithmic way to generate landscapes. It is
used in the next workshop to produce a natural-looking terrain from a plane
object in Unity.
Unity Hands On
Generating a Terrain Procedurally
Step 1. Create a new Unity project and import the Character
Controller package.
Step 2. Add a plane to the scene and a first person controller (FPC).
Position the FPC just above the plane and add a directional light as
shown in Figure 7.19 . Scale the plane's x and z size to 10.
If you want a smoother, more detailed terrain, you will need to use a plane
with more vertices than the one supplied with Unity. To do this, using
Blender or your favorite 3D modeling program, create a plane and apply
subdivisions to give it the number of polygons you desire.
Search Nedrilad ::

Custom Search