Title: Software Games Development What are 3D games
1Software Games Development What are 3D games?
2Part I What are 3D Games?
- Key Topics
- The games of third dimension
- The Components of DirectX
- Direct3D and todays games,
- The features of 3D games
- Hardware acceleration
- Watt A Policarpo F, (2001) 3D Games
Real-time rendering Software technology,
volume 1. Addison Wesley. ISBN 0201-61921-0 - Andrew Rollings, (1999) Game Architecture and
Design, CoriolisI, SBN1576104257 - Mark DeLoura, (2000) Game Programming Gems",
(Ed.) Charles River Media, ISBN 1584500492.
3Introduction
- The computer game world is now officially 3D.
- Action games have long existed outside the
confines of two dimensions, but until recently, a
vast number of games were two-dimensional, most
notably adventure and strategy games. With the
advent of the low-cost 3D accelerator, however,
this has changed. - In this lecture, we will discuss the
three-dimensional games by covering their most
distinguishing features.
7th Guest
Capture the Flag
Black and White
Half-life
4The State Of The Art
- The games industry has always prided itself on
being on the cutting edge of technology.
Whenever a new processor, graphics card, or any
other cool peripheral appears on the market and
needs support, the game developers are there in
force to provide that support. - Although game developers may perceive themselves
as being on the cutting edge of technology, this
position is debatable. Who is to say whether the
latest 3D came or the latest multi-terrabyte
database software is the most advanced? - Undoubtedly, in terms of technical complexity, a
database such as SQL Server 7 (for e.g.) is more
advanced than any game currently on the market.
But it's just not as enticing, and the coolness
factor associated with games and game development
only helps to feed the hype.
5The State Of The Art
- However, we can say that, although game
developers are not on the cutting edge of
technology, they are most definitely world
leaders in the art of fast approximation of
simulated real-world systems. - Why fast approximations? Well, until home
computers get much more powerful than they are
today, there is no way we would be able to model
an immersive world full of complex dynamics and
interactions in realtime, without taking a few
shortcuts to save time. - Even if Moore's Law holds true, and raw computer
processing power doubles every 18 months or so,
it is doubtful that anybody will be able to make
a truly accurate to-the-molecule simulation of a
world for a very long time. - As computers get faster and faster, these
approximations will become increasingly accurate.
Nowhere is this more evident than in the
graphics engines for today's games. The lineage
of the 3D graphics engine can be traced back to
the early days.
6The Rise and Fall of the 3D Engine
- The first famous 3D game was Battlezone, as shown
Figure 1, in the arcades. This simple tank
simulation used low-polygon-count wireframe
graphics to portray a simple landscape
interspersed with cubes, pyramids, and tanks. - No hidden-line removal was attempted (that is,
objects appeared as if they were made of glass
and you could see the hidden edges on the far
side of the object).
Fig. 1 - Battlezone
7The Rise and Fall of the 3D Engine
- The next famous one was the BBC version of Elite,
as shown in Figure 2, by David Braben and Ian
Bell. - The 3D engine represented each star system as a
single sun (as a filled circle with perturbed
edges) and a single planet (as an outlined
circle). Ships were drawn in wireframe and
benefited from intraobject hidden-line removal
(that is, you couldn't see the far side of a ship
through its infrastructure, but you would be able
to see if another ship was behind it).
Fig. 2 BBC Elite
8The Rise and Fall of the 3D Engine
- As processing power increased, so did the number
of polygons used, as well as the complexity of
the drawing techniques. - First came filled polygons, such as those seen in
the Archimedes version of Elite, as shown in
Figure 3. These polygons were simply colored flat
shade of a single color.
Fig. 3 Archimedes Elite
9The Rise and Fall of the 3D Engine
- Soon after, simple flat shading was added to the
polygons, and these would change in illumination
according to a light source, as demonstrated in
Zarch, and shown in Figure 4. - This was usually a simple directional light
source anything else would have been too
computationally expensive.
Fig. 4 Zarch
10The Rise and Fall of the 3D Engine
- This was closely followed by Gouraud shading, a
technique whereby the illumination was calculated
at the vertices of the polygon and simply
linearly interpolated over the interior of the
polygon, as in Little Big Adventure (known as
Relentless in the U.S.) shown in Figure 5.
Fig. 5 Little big adventure
11The Rise and Fall of the 3D Engine
The Rise and Fall of the 3D Engine
- The next development in the saga of the polygon
was texture mapping projecting a picture onto
the surface of the polygon so that it appeared
that the polygon was textured. - Ultima Underworld II, as shown in Figure 6, was
one of the first examples of this.
Fig. 6 Ultima Underworld II
12The Rise and Fall of the 3D Engine
The Rise and Fall of the 3D Engine
- Later developments - such as Wolfenstein 3D
(which introduced ray casting) shown in Figure 7,
Doom (which introduced binary space partitioning
(BSP) trees) shown in Figure 8 - brought more
advances to light sources, with explosions
providing directional point sources, and laser
fire dynamically lighting walls as it streaked
past.
Fig. 8 - Doom
Fig. 7 Wolfenstein 3D
13The Rise and Fall of the 3D Engine
- At this stage, 3D was still the exception rather
than the rule. Most games were still being
developed in 2D, and 3D was only just beginning
to become the mainstream. - Quake (as shown in Figure 9) heralded in this new
era of game development.
Fig. 9 - Quake
14The Rise and Fall of the 3D Engine
- What caused the great turnaround was the
introduction of the first 3D accelerators into
the market. - 3D products with huge polygon counts, advanced
lighting, texture mapping (such as Quake III
Arena shown in Figure 10), and all the latest
whizzy features now jostle for position on the
shelf, but try to find one of these products that
uses the 3D technology in an original and
innovative fashion.
Fig. 10 Quake III Arena
15DirectX
- Microsoft developed a software development kit
(SDK) specifically to promote hardware-assisted,
high-performance games for Windows. - This SDK, known as DirectX, consists of many
components, each of which deals with a particular
aspect of game development. - Because DirectX is well supported and widely
known, virtually all 3D games rely on it for the
features they need. - The components of DirectX are divided into two
groups - DirectX Foundation contains low-level components
that supply basic functionality - DirectX Media contains high-level components that
perform many complex operations.
16DirectX Foundation (1)
- DirectX Foundation consists of the following
components - DirectDraw,
- DirectSound,
- DirectMusic,
- Direct3D Immediate Mode (IM),
- Directlnput,
- DirectSetup, and
- AutoPlay.
17DirectX Foundation (2)
- DirectDraw
- DirectDraw provides a way for software developers
to access the display's attributes - including
the size of the desktop and how many colors can
be displayed at once-and the display's features,
such as playing back video, displaying images and
bitmaps, and so on. - DirectDraw is NOT a graphics library, in that it
cannot draw lines, polygons, or text, but it is
still nonetheless invaluable for all of today's
3D games. - DirectSound
- DirectSound can play, mix, and apply effects to
sounds on a variety of hardware devices. Many
programmers rely on DirectSound for all of their
sound output. - DirectMusic
- DirectMusic, a recent addition to DirectX,
supports the playback of MIDI files and other
kinds of music.
18DirectX Foundation (3)
- Direct3D IM
- Direct3D IM gives programmers direct access to a
graphics card's 3D features. It is written with
a minimal amount of code, thus requiring the
programmer to do most of the work in displaying
3D environments. - DirectInput
- DirectInput allows programmers to use existing
and future input devices. It directly supports
force-feedback joysticks, normal joysticks, mice,
flight yokes, and any other input device
developed with Directlnput support. - AutoPlay
- AutoPlay allows a CD to start itself after being
inserted into a CD-ROM drive, thus enabling
software developers to create self-installing
games and those that run themselves after being
inserted.
19DirectX Media (1)
- DirectXMedia consists of only four components
- Direct3D Retained Mode (RM),
- DirectPlay,
- DirectShow, and
- DirectAnimation
- but each one contains a large amount of
functionality.
20DirectX Media (2)
- Direct3D RM
- Direct3D RM is a high-level component of DirectX.
Rather than handling only the basics, as IM
does, RM performs most of the tasks involved in
displaying 3D scenes. Because it is high level,
the changes from one version of RM to the next
tend to be slight, allowing programmers to become
more familiar with it. - DirectPlay
- DirectPlay allows programmers to write
multiplayer software that runs over LANS, modems,
the Internet, and other networks. - DirectShow
- DirectShow plays video files of all types -
QuickTime, AVI, MPEG-according to the filters
(video decoders) installed on the computer it is
running on. This provides game developers with
an easy way to introduce cinematic scenes into
their games. - DirectAnimation
- DirectAnimation is a component designed for Web
and desktop animation.
21The Features Of DirectX
- Today's games use DirectX and so support many if
not all of the graphical features provided by
this SDK. - Polygons
- Lights
- Environmental Effects
- Hardware
22Polygons (1)
- The main primitives simple geometric shape from
which more complex shapes are formed in 3D games
is a convex polygon. - A polygon is a bounded portion of a plane, which
is, in turn, a shape infinitely wide in two
dimensions and infinitely flat in the third. - A convex polygon has no two points through which
a line can be drawn that passes outside the
polygon (Fig. 2a). This is contrasted with a
concave polygon, which has at least two points
through which a line can be drawn that passes
outside the polygon (Fig. 2b).
Fig.2 A convex polygon (a) and a concave
polygon (b)
23Polygons (2)
- Nearly all objects in Direct3D games are composed
of convex polygons. - Objects with sharp edges, therefore, can be
replicated exactly, while those with smooth edges
can be simulated. - Most games do not display plain, single-color
polygons. Rather, they display polygons with a
number of special effects to improve their
realism.
24Polygons (3)
25Polygons (4)
- Shading
- Direct3D is capable of shading polygons
realistically to enhance their appearance. - It can shade polygons based on their positions
and their orientations relative to one or more
light sources. - Gouraud Shading
- Gouraud shading is a fast method of simulating
curved surfaces. - The vertices of the polygon are shaded as if the
polygon were curved, and these resulting shades
are spread across the face of the polygon. - This approach does not produce accurate results
if a highlight from a light falls in the center
of the polygon (because only the shades at the
vertices are calculated) but otherwise, it is
fairly realistic.
26Polygons (5)
- Phong Shading
- Although Phong shading is NOT currently
implemented in Direct3D, it will be in future
versions. - Phong shading is more realistic than Gouraud and
never misses highlights. - It shades each pixel of the polygon as if it were
curved for this reason, it is slower than
Gouraud shading. - Texture Mapping
- Virtually all polygons have a texture-an image or
bitmap-applied to them. - This image is mapped, or painted, on the polygon.
- Usually, each vertex of the polygon is assigned a
texture coordinates two-dimensional point
indicating the pixel in the texture corresponding
to the given polygon vertex.
27Polygons (6)
- Transparency
- Transparency results from giving the texture map
associated with the polygon a stencil (also
called a mask) or an alpha channel. - A stencil allows cutouts portions of the polygon
can be either fully transparent or fully opaque.
- An alpha channel is another component (added to
the red, green, and blue components of each
pixel) that specifies to what extent each pixel
is transparent. - Alpha channel transparency takes longer to
compute than stenciling, but is
hardware-accelerated in all of today's graphics
cards, and so it is the preferred method of
transparency.
28Polygons (7)
- Bump Mapping
- Bump mapping refers to the process of modifying
the appearance of a polygon so it seems bumpy. - The bumps are specified by an image (sometimes
called a height or displacement map), and the
technique is usually used in combination with
texture mapping. - Reflection Mapping
- Reflection mapping is a method of simulating
reflections. - When a reflection map is applied to a polygon,
the texture coordinates chosen depend on the
viewer's location, and the texture map itself is
an image that resembles the environment. - This produces the illusion of a reflective
surface.
29Lights
- Lights play an important role in games, casting
shadows and illuminating important parts of
scenes. - Many games use a combination of real-time
lighting and pre-rendered lighting. - Real-time lighting is calculated while the game
is playing - all the mathematics for generating
shadows and other lighting effects is done by the
game every time the 3D world is displayed. - Pre-rendered lighting is calculated in advance by
a 3D modeling program and applied to objects in
the game world (this lighting type is faster, but
cannot be used for moving lights).
30Environmental Effects (1)
- In addition to the many effects applied to
polygons, Direct3D supports environmental effects
- those that are global and affect all objects in
the game world. - Fog
- Fog is a generic name for any type of color that
distant objects converge to. - It can be white to simulate real fog, black to
simulate nighttime, or another color.
31Environmental Effects (2)
- Shadows
- Today's games increasingly make use of shadows,
which Direct3D supports. - Game designers usually decide that not all
objects should have shadows - only select objects
(like characters and moving vehicles, for
example), because using shadows for all objects
within a 3D world is computationally expensive. - Many objects, because they do not move, can be
given textures with pre-drawn shadows,
eliminating the computational cost at the expense
of memory. - Another technique involves modifying the
intensities of the polygon's vertices (similar to
Gouraud shading), making those that lie within
shadow regions darker and those that do not,
lighter. This technique crudely approximates
real shadows, but is fast and universally
supported by hardware.
32Summary
- The first step in becoming a three-dimensional
game programmer is to understand what elements
contribute to the graphics of three-dimensional
games. - For Windows programmers, those elements are
usually the features supplied by Microsofts
DirectX, a high-performance COM SDK aimed
specifically at the game-developer community. - DirectX gives developers direct control over
graphics accelerators, input devices, sound
cards, and more. - Credit goes to the manufacturers of graphics
accelerators for the radical new advances in the
quality and performance of three-dimensional
games. - These graphics accelerators natively support a
growing list of 3D features, enabling developers
to produce games that are richly detailed and run
at high speeds.