Game Development Reference
In-Depth Information
function
GetWorldTransform()
// Order matters! Scale, rotate, translate.
Matrix
temp
= CreateScale(
scale
) *
CreateFromQuaternion(
rotation
)
*
CreateTranslation(
position
)
return
temp
end
end
Summary
This chapter looked at many of the core aspects of 3D graphics. Coordinate spaces
are an important concept that expresses models relative to the world and the cam-
era, and also determines how we flatten a 3D scene into a 2D image. There are
several different types of lights we might have in a scene, and we use BRDFs such
as the Phong reflection model to determine how they affect objects in the scene.
3D engines also shy away from using the painter's algorithm and instead use z-
buffering to determine which pixels are visible. Finally, using quaternions is pre-
ferred as a rotation method over Euler angles.
There is much, much more to rendering than was covered in this chapter. Most
games today use advanced rendering techniques such as normal mapping, shad-
ows, global illumination, deferred rendering, and so on. If you are interested in
studying more about rendering, there's much to learn out there.
Review Questions
1
.
Why are triangles used to represent models in games?
2
.
Describe the four primary coordinate spaces in the rendering pipeline.
3
.
Create a world transform matrix that translates by 2, 4, 6 and rotates 90°
about the z-axis.
4
.
What is the difference between an orthographic and perspective projec-
tion?
5
.
What is the difference between ambient and directional light? Give an ex-
ample of both.