|

Now that most of the basic terminology is under your belt, we can knock it up a notch and start to talk about shaders
in a little more detail now.
The GPU on a graphics card is designed to run specialised 'mini programs' that are involved with two important phases
of the frame creation process, namely geometry construction in the simulated world, and camera projection.
There are two primary types of shaders used in the construction process, vertex shaders, which are applied to each
vertex in the 3D scene, and pixel shaders, which are used to manipulate individual pixels during the process of creating
the 2D representation of the 3D scene.
Vertex shaders are sometimes used to optimise the geometry in a scene to reduce the workload for later stages.
Each vertex in the scene is processed by a vertex shader program running on the GPU, this program determines
whether the vertex is needed to create the final view from the virtual camera. This type of operation is known
as 'hidden surface determination', and involves four main stages:
Backface culling: The removal of the faces on the back of objects that don't face the camera (e.g. on a cube you
will at most see three faces at any one time, so there's no reason to draw the faces you can't see).
Occlusion culling: The removal of the portions of objects that are hidden by other objects from the camera viewpoint.
This is one of the most difficult algorithms in computer graphics, and a number of different occlusion culling
algorithms have been developed over the years. The simplest is painter's algorithm, in which the polygons are sorted,
and then drawn back to front. Another method is known as Z-buffering, in which the depth value at each pixel is
stored as each polygon is rendered. The pixel is then only overwritten if the value of the current point is less
than the depth value stored in the z-buffer. This last method is the most common in real-time graphics (and
*really* isn't easy to describe if you're tired!).
Contribution culling: If an object is so far away that it doesn't contribute significantly to the final frame
(if it's too small), then the object can be discarded.
Viewing frustum culling: Remember the viewing frustum, the area visible to the virtual camera? Well this type of
culling simply removes any objects that are not visible within this area. Often, objects will lie on the
boundary of the viewing frustum, these polygon faces are cut into smaller triangles along this boundary in a process
called 'clipping', and any pieces that lie outside the frustum edge are discarded.

Frustum Culling in action: a triangle gets the chop
So after all this 'culling', this simple set of vertex shaders can reduce the scene geometry data to a much more manageable
level, which in turn will increase the overall frame rate substantially.
In the later stages of the frame generation process, the GPU executes the pixel shaders, which not only calculate the final
colour of every pixel in the frame, but also help with the generation of more realistic surfaces. For example, the flat
faces of an object made up from a mesh of triangles can appear faceted, with each individual triangle that makes up the surface discernable.
However, a simple pixel shader can smooth out the appearance by calculating surface normals that vary more smoothly
from pixel to pixel across the surface.
Pixel shaders also can combine the positions of light sources and the current geometry in a scene with the surface colours
of the image maps, this results in even more detailed images. Modern games make heavy use of pixel shaders to give the
most realistic textures possible.
Obviously, the processing required to do all of these calculations for every vertex and pixel in the scene, (and in a
fraction of a second) is staggeringly massive. Dealing with this workload in a sequential way, (one after another) like
a desktop CPU would handle it, would slow the framerate down considerably, so structures called vertex and pixel
pipelines are built into the GPU to speed things up.
<<< Previous
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13
Next >>>
Article Navigation:
|
| Latest Question |
|
Stop Automatic Restarts after Automatic Windows Updates - After leaving my computer to encode a large video the other day, I was surprised to come back and find it sitting at the login screen. ...
View Full Question & Answer
|
| Search |
To search the site, enter your search string in the box below:
|
|