You are on page 1of 3

Source Code - https://bitbucket.

org/twntduff/directx-11-terrain/src

Perlin Noise Generation


The height map used for generating the terrain is first created using Perlin
Noise. The texture generation algorithm can be used to create many realistic
looking materials including; clouds, terrains, fire, water, marble, tree bark, and
many other materials. The noise maps that I am using are generated before runtime
by a stand-alone Perlin Noise generator I have written in C++. The map that is
generated is determined by the variables set including; amount of octaves,
amplitude, frequency, and persistence.
Height Map
The height map is read in using the generated Perlin Noise texture. To give it
more of a smooth look, depending on the map generated, you may need to set an
offset for the X and Z coordinates and normalize the Y coordinate to reduce sharp
edges. It is recommended that you spend more time perfecting you Perlin Noise
map before runtime so that there are no mutations needed to create something
realistic. This all depends on if you are generating random terrains at runtime or
using prebuilt terrain maps.

Managers
Texture Manager:
The texture manager is used to manage the texture assets that are loaded into
memory at any given time. Loading only the relevant texture allows the clearing up
of memory for other processes. The textures are cleared or loaded at the beginning
of each level or game state. For instance, the textures used for the main menu are
the only textures that are loaded at that time and are cleared afterwards because
they are no longer used in the application.
Shader Manager:
The shader manager manages the shader assets that are used in the
application. The only shaders that are loaded are the ones that are being used in
certain areas or levels. When they are no longer needed they are erased to clear

memory for other processes. For instance, a level that takes place inside of a
building and does not require a skybox will not load the skybox specific shader
because it will not be used.
Mesh Manager:
The mesh manager operates the same as the other managers by only loading
the necessary assets for a given area or level. Each entity has a mesh component
and those that share the same mesh share an instance of the single mesh object.

Shadow Mapping
Shadow mapping is a fairly easy way to create dynamic shadowing in a
graphics application. The shadow mapping algorithm works in two passes through
the pipeline. First, the scene is rendered from the point of view of the light source
and the distances are rendered to a texture. Then, the scene is rendered with the
cameras point of view and a test is done to check if the current pixel is further from
the light source than the distance stored in the texture. An orthographic matrix is
used in the case of a directional light because the light source is considered far
enough away that the light rays are parallel to each other.

Skybox
The skybox is used to create a background for a graphics application. It is a
simple cubic skybox that surrounds and follows the camera and is always rendered
behind all of the other objects in the scene. This is how the effect of never getting
closer or further to the sky is created. In advanced skyboxes, the skybox moves
with the camera but at a different speed to give off the illusion that the skybox is
not infinitely far away. This was not included into the project because a simple
skybox would work fine considering there is no night/day cycle and no distant
objects.

Frustum Culling
The three dimensional area on the screen where objects are rendered is
referred to as the viewing frustum. Everything that is inside the viewing frustum is
rendered to the screen by the graphics card and everything outside of the frustum is

examined by the graphics card and then discarded during rendering. Depending on
the graphics card, the process of culling done by the graphics card can be
computationally expensive when there is a large scene with multiple polys. This is
because the graphics card must examine every single poly to remove the polys that
are not in the viewing frustum even if there are only a few polys in view. This is
avoided by using frustum culling to determine if an object is in the viewing
frustum before it is sent to the graphics card so that we can cut down on the
number of polys sent to the graphics card. The way this optimizing feature is
utilized in my DirectX 11 application is by breaking the large terrain up into
different quadrants so that the quadrants can be culled when they are not in the
viewing frustum.

Slope Based Texturing


Slope based texturing is one of many procedural texturing methods that is
used to realistically texture terrains without the need for an artist. In my DirectX 11
application I use slope to determine how each pixel is textured in the terrain. This
is a quick and easy method that is accomplished by simply subtracting one from
the height value of the normal vector and then assigning a value to each type of
texture that determines the range in which that texture should be assigned.

You might also like