Game Development Reference
In-Depth Information
Chapter 4. 3D Graphics
Although the first 3D games were released in the arcade era, it wasn't
really until the mid-to-late 1990s that 3D took off. Today, nearly all
AAA titles on consoles and PCs are 3D games. And as the power of
smartphones increases, more and more mobile games are as well.
The primary technical challenge of a 3D game is displaying the game
world's 3D environment on a flat 2D screen. This chapter discusses the
building blocks necessary to accomplish this.
Basics
The first 3D games needed to implement all their rendering in software. This
meant that even something as basic as drawing a line had to be implemented by
a graphics programmer. The set of algorithms necessary to draw 3D objects into
a 2D color buffer are collectively known as software rasterization , and most
courses in computer graphics spend some amount of time discussing this aspect
of 3D graphics. But modern computers have dedicated graphics hardware, known
as the graphics processing unit (GPU), that knows how to draw basic building
blocks such as points, lines, and triangles.
Because of this, modern games do not need to implement software rasterization
algorithms. The focus is instead on giving the graphics card the data it needs
to render the 3D scene in the desired manner, using libraries such as OpenGL
and DirectX. And if further customization is necessary, custom micro-programs,
known as shaders , can be applied to this data as well. But once this data is put
together, the graphics card will take it and draw it on the screen for you. The days
of coding out Bresenham's line-drawing algorithm are thankfully gone.
Onethingtonoteisthatin3Dgraphics,it'softennecessarytouseapproximations.
This is because there simply isn't enough time to compute photorealistic light.
Games are not like CG films, where hours can be spent to compute one single
frame. A game needs to be drawn 30 or 60 times per second, so accuracy must
be compromised in favor of performance. A graphical error that is the result of an
approximation is known as a graphical artifact , and no game can avoid artifacts
entirely.
Search WWH ::




Custom Search