3D Primer

Author information

Author: Jeroen Ruigrok van der Werven <asmodai@in-nomine.org>
Revision: $Revision: 231 $
Date Revision: $Date: 2012-07-27 13:05:44 +0200 (vr, 27 jul 2012) $

Table of Contents


I started this document because I like the subject of computer graphics and see a lot of ties with previous work I did on toolchains.

A lot of this right now is really unstructured. Basically a sort of brain dump, it will get fixed in the end.

This document uses MathML for rendering formulae as they were intended to be shown. In order to render these formulae on non-MathML compliant browsers this page uses MathJax.

The default font support on Windows 7 and MacOS X is good enough to display many formulae. You might want to install Stix Fonts to get even better coverage.

3D Basics

Basic Terminology & Glossary

For non-native English speakers some geometric and mathematical terms might be radically different than those in their own language. My own native language, Dutch, is a good example of this knowing ‘loodrecht’ as the word that is known as ‘perpendicular’ in English.

The world of 3D graphics relies heavily upon mathematical concepts, so any affinity or rudimentary experience with geometry and set theory makes things a lot easier to understand.

  • blitter - in the earlier years of personal computing a co-processor dedicated to memory data transfers
  • pixel - contraction of picture element, the smallest unit of digital images
  • PSU - pixel shader unit
  • ROP - render output
  • texel - contraction of texture element, the smallest unit of a texture, the texture map equivalent to a pixel
  • texture - the feel of a surface or fabric, in the 3D world
  • TMU - texture mapping unit, also known as the graphical pipeline

Background on 3D

Phong reflection model.

Formula: shading function
S p = C p cos i 1 - d + d + W i cos s n
Formula: the Phong reflection model
I p = k a i a + lights k d L · N i d + k s R · V α i s


Formula: Kijiya's rendering equation
I x x = g x x ε x x + S ρ x x x I x x d x
Formula: the rendering equation
L o x w = L e x w + Ω f r x w L i x w ( w · n ) d w
Formula: the bidirectional reflectance distribution function
f r x w w = d L r x w L i x w ( w · n ) d w

Typical 3D Features

URL dump:


Alpha blending

Alpha blending is a very simple technique to create the effect of transparency. It accomplishes this by using a variable factor to determine the amount of blending between the foreground colour and the background colour.

In mathematics this is written as such:

Formula: alpha blending
r g b blended = α r g b foreground + 1 - α × r g b background 0 α 1

So an α value of 0 results in an RGB value that is totally transparent, in other words it allows the background to show through. If the α value is 1, however, the foreground is totally opaque and obscures the entire background. Any α value in-between 0 and 1 will balance the foreground and background colour appropriately. Of course, the caveat here is that the α value applies equally to the individual RGB values. For appropriately filtered alpha blending see


DirectX functions: OpenGL functions:


Anisotropic Filtering

When one take a certain image of a specific size and scale it in a different X and Y




Anti-aliasing is a technique goes against a phenomenon called edge-aliasing. But that still does not mean anything. In short: edge-aliasing is the effect that causes the so-called staircase (jaggies) effect in an image. In a drawing program when you have a white background and a black foreground colour and you draw a diagonal line you will see the pixels on-screen display a staircase effect. A pixel tends to be a cube form and thus a resulting image will have noticeable edges. Just like when you would recreate that line as a mosaic. Anti-aliasing is the process of applying a filter over the image to counter the effect of edge-aliasing.

Types of Antialiasing Methods:


FSAA - Full Screen Anti-Aliasing

Texture aliasing



Bilinear filtering



Bump mapping



MIP mapping

Multum In Parvo (MIP; Latin for 'much in little') mapping is a texturing technique to improve the visual quality of computer graphics. In drawing 3D scenery objects that approach the horizon are drawn proportionally smaller in size. On the computer drawing like this will result in the objects in the distance losing their details due to their size. This leads to edge-aliasing, which leads to interference patterns forming commonly known as moiré.

To counter this MIP mapping, as stated above, uses a variety of scaled down objects. The normal texture might be drawn/rendered at 512x512 pixels and is what you see when you are very close up to a surface with that texture. For displaying surfaces with the texture in the distance it has pre-rendered and filtered textures in, typically, powers of two resolutions. So the GPU might have already pre-rendered 256x256, 128x128, 64x64, perhaps all the way down to 8x8, or even 2x2 resolutions.

MIP mapping scales and filters a texture map into multiple versions before applying it to the wire frame model. These versions are of varying resolution and details. At close distances to the camera viewpoint, the texture map appears in its original full detail. For medium distances, a smaller texture that is half the resolution of the original is used. Even further distances display texture maps that are a quarter the resolution and so on. Each of these stages is known as a MIP map level.

By choosing the appropriate texture map resolution and detail, MIP mapping ensures that pixels do not get lost at further distances. Instead, properly averaged smaller versions of the original texture map are used. Since low resolution textures are used for further distances, other benefits of MIP mapping include reduced memory bandwidth requirements.




Polygon offset

Adds an appropriate offset to force coincident z-values apart to cleanly separate a polygon edge from its highlighting line


Programmable shading

Fill in.





Texture mapping






3D Software Development Kits

Right now the two major Software Development Kits (SDKs) are:

As of this writing DirectX has version 11 out and OpenGL has specification 4.2 out.

Both specifications are quite powerful in their own right. The choice for selecting one of the other is a choice you make based on your requirements (which you do have, right?).




Since DirectX is build up from multiple sub-parts this document will only highlight the graphics parts in order to cut back on the size of the total document.

DirectX Programming Documentation

DirectX has had the following releases:

DirectX was introduced by Microsoft in 1995. It is based on their Component Object Model (COM) technology. Thus DirectX has been object oriented from the start. Prior to version 8.0 DirectX was rather cumbersome to program, since it required a lot of complex operations. Version 4 was never released and was solely known/used in-house

DirectX specifics:

D3DX New features:

DirectX 9 introduces a new high level shading language for shader programming. This language provides the ability to more easily write shaders with functions, arbitrary variable names, conditionals, and loops.

The shader compiler now supports the following profiles: vs_1_1, vs_2_0, ps_1_1, ps_1_2, ps_1_3, ps_1_4, ps_2_0, ps_2_sw.

A shader fragment linker has been added to facilitate the management and generation of shaders, The fragment linker links assembly or high level shading language shader fragments together. i.e. to allow mixing and matching of lighting types, skinning types, etc.

The Effect framework has undergone some exciting changes for DirectX9, specifically the addition of the ID3DXEffectCompiler interface. The Effect compiler interface can be used for shader specialization. i.e. marking a global variable as literal for a specific compile of the shader.

Added variable sharing between effects. Variables in effects files declared with the keyword "share" will be shared across all effects created with a given effect pool.

A new animation subsystem and mesh hierarchy loader are now included.

The mesh library now supports arbitrary vertex declarations (single stream only).

CloneMesh handles all data type conversions. i.e. FLOAT2 to FLOAT16_2, D3DDECLTYPE_DEC3N...

Patch support is included in the mesh library, including Adaptive tessellation.

  • DirectDraw: DirectDraw provides for drawing raster graphics.
  • DirectInput: DirectInput provides the developer with an interface to myriad input devices, including support for force feedback.
  • DirectMusic: DirectMusic provides for playback of soundtracks. It also allows the composer to dictate what events will trigger transitions in the music to blend from one piece to another or to simply add more tempo, decrease tempo, increase volume or the intensity, all in order to supplement the gameplay. In other words it provides movie-like music control. It is based on MIDI with the Downloadable Sounds (DLS) feature to use custom sounds in combination with the MIDI power.
  • DirectPlay: DirectPlay is a set of tools that simplify communications across networks, the Internet, or modems. The tools allow game players to find game sessions easily to help manage the flow between hosts and players.
  • DirectSetup: DirectSetup provides a simple API for installing DirectX from your customized application. With DirectX being a complex product, this component greatly simplifies the process of installation.
  • DirectShow: DirectShow provides multimedia support for video files such as AVIs and MPGs. This component of DirectX that was once an outside API is integrated with the release DirectX 8.
  • DirectSound: DirectSound provides for playback and recording of waveform sound.


OpenGL background

OpenGL specifics:

OpenGL was begun by Silicon Graphics, Incorporated (SGI). The name is a short form for 'Open Graphics Library'.

OpenGL, through its extension feature, allows vendors to more easily export their own API to provide functionality. Until the ARB standardises on a specific API it means you may encounter vendors offering the same functionality through widely different APIs. This, of course, has both its advantages as disadvantages.

OpenGL is based on a state machine accessed through a C API.

OpenGL features

OpenGL has the following versions defined:

  • 1.0 - January, 1992
  • 1.1 - January, 1997
    • Introduction of vertex arrays,
    • Introduction of polygon offset, a way to remedy stitching and z-fighting,
    • Logic ops
    • Textures
  • 1.2 - March, 1998
  • 1.2.1 - October, 1998
  • 1.3 - August, 2001
  • 1.4 - July, 2002
  • 1.5 - July, 2003
  • 2.0 - September, 2004
  • 2.1 - July, 2006
  • 3.0 - July, 2008
  • 3.1 - May, 2009
  • 3.2 - August, 2009
  • 3.3 - March, 2010
  • 4.0 - March, 2010
  • 4.1 - July, 2010
  • 4.2 - August, 2011

OpenGL 2.0 provides the following:

  • Programmable shading: - Shader Objects - Shared Programs - OpenGL Shading Language is a core feature now,
  • Multiple Render Targets
  • Non-Power-Of-Two Textures
  • Point Sprites
  • Separate Stencil


Documenting how 3d hardware generally is built up and how it progressed through history.








NVIDIA generally uses the identifier NVnn to label their computer chip products. In the past a Cnn identifier has been used for a few products, all of them based on HyperTransport. More recently they seem to have started using the identifier Gnn.









Game Engines




id Tech

Source Engine


Unreal Engine


Direct3D, DirectDraw, DirectInput, DirectMusic, DirectPlay, DirectShow, DirectX are registered trademarks of Microsoft Corporation in the United States and/or other countries.

NVIDIA, the NVIDIA logo, 3DFX, the 3dfx logo, STB, STB Systems and Design, the STB logo, GeForce, NVIDIA Quadro, Vanta, TNT2, TNT, RIVA, RIVA TNT, VOODOO, VOODOO GRAPHICS and Glide are registered trademarks or trademarks of the NVIDIA Corporation in the United States and/or other countries.

OpenGLĀ® is a registered trademark of Silicon Graphics, Inc. in the United States and/or other countries worldwide.