The Rendering Process: Introduction
AN INTRODUCTION TO RAYCASTING:
Raycasting is the term given to the technique we'll be using to render a 3D
scene. To give you an idea of the visual appearance of a raycasting engine,
I'll show you this Wolfenstein 3D screenshot in fig1. The Wolfenstein
engine was one of the first real-time 3D engines, and id's lead programmer
John Carmack may well have been the person to start the raycasting craze.

fig1: Screenshot from Wolfenstein 3D
As you can see by the image, the output is rather blocky. The visual effects
aren't as realistic as those produced by games like DOOM, Quake, Unreal etc.,
and the engine's not as fast as theirs. But raycasting is a simple technique
that's simple to code -- that's what makes it a good starting point.
Raycasting is a variation of another rendering technique called
raytracing. Raytracing is unsuitable for
real-time applications
because it's just too slow. It involves tracing a ray from each pixel of the
screen out until it hits part of an object. The part of the object is then
drawn according to the distance the ray travelled and the point of the object
that the ray hit. Afterwards, the next pixel is taken as the new starting
point and the process repeats itself. If you had a screen in a resolution as
low as 320x200, this would mean (320 * 200 = 64000) rays to be traced ! As
tracing a ray involves extensive calculations, it's an extremely
slow process. I wonder how long a 1024x768 screen would take...
However, the effects of raytracing are stunning and virtually any shape can
be rendered. Take a look at fig2, which shows a screenshot from The
7th Guest. Players of this game must stick to a pre-determined path because
the images needed to be pre-rendered to allow for the speed and smoothness.
This is the exact opposite of Wolfenstein, where you may go anywhere (within
reason) and the images are generated dynamically (or 'on the fly').

fig2: Screenshot from The 7th Guest
Raycasting, as I've already said, is a variation of the raytracing method.
It gets its speed from various 'geometrical constraints'. That's just a
fancy way of saying that the world a raycaster is expected to render follows
some basic rules, such as all walls are fully vertical (no slopes are allowed;
the walls are all perpendicular to the floor). Because all walls are
at 90 degrees to the floor, rays can be cast for every screen column
rather than for every pixel as done in raytracing. This means
that, for a 320x200 screen, instead of casting 64000 rays, we'd only cast 320,
which is a significant improvement. It may surprise you (or not) to learn that
raycasting is an entirely 2D process (as will be proven later), which allows
everything to be simplified even further.
Although raycasting is an old, and greatly obsolete, technique, it gives a
good starting point for 3D because it provides an introduction to simple
algorithmic programming. And because raycasting uses simple trigonometry,
the algorithms are fairly straightforward to implement in code.
CONCLUSION:
This section was a rather brief introduction to raycasting, but it was simply
to give you a vague outline of what the technique entails and what can be
accomplished, without delving deeply into the topic (there's plenty of time for
that later :). Let's move on to the first step -- Understanding the Principles
Behind Raycasting. The first few steps are basically introducing you to
raycasting, so no formulae for a little while.
NEXT PAGE
|
|