3D Graphics Rendering Pipeline Algorithms
This algorithm comes from a Simple Cube Demo by Chaz. Clipping and Backface Culling is not implemented.
Definition of Variables
- Set the Vanishing point - ZSCALE = 500.00
- Define a large Number for vertex snapping
- Define Matrix4x4
- Load Identity Matrix
- Define Rotation Matrices
- Define rotation angle variables - rotx,roty,rotz
- Define List of Vertices - original
- Define List of Vertices - transformed
- Add Points
- Set coords to 3d Objects
- Set shading to Flat or Gouraud or whatever
Set oow loop
for ( 0 to numFaces/objects){
object[i].oow = 1/Object[i].z + ZSCALE;
}
Flash Tutorials in Video Format -
Watch them now at LearnFlash.com
Infinite animation Loop
- Set Rotation Matrices
- Loop - for(0 to numFaces){
- Rotation Transform
- Convert Points to 2D
- points2DList[i].oow = 1/point2DList[i].z + ZSCALE ;
- Snap the vertices - point2DList[i].x += vsnap;
- } // End for Loop
- Loop - for(0 to numFaces){
- set color
- DrawPolygon i
- End for Loop
- Increment x,y,z rotation angles for next frame
- End Main Loop
ExtremeTech Algorithm
This Algorithm comes from a series of articles at extremetech.com about setting up a pipeline.
Declare and Initialise variables
- Declare pointsList, faceList, ObjectsList, etc
- Declare brightness, lights etc.
Load Model Data
- Add Points to pointsList
- Set up FaceList
- Do any precalculations - sin, cos, normals , whatever you can
Main Animation Loop
- Get Key input
- Set/update translation, rotation variables
- . Loop thru poinstList
- Transform points to World Space
- Transform to Camera Space
- Occlusion Culling
- Frustum Culling
- Backface Culling
- Perspective calculations
- SwapDepths or Z-sorting
- Draw Polygons
- End PointsList Loop
- End Main animation loop
Grigory's 3d Flash Engine Algorithm
Setup and Initialisation
- Set World Center
- Initialise Camera
- Initialise Lights
- Add Points
- Initialise Faces
- Initialise x,y,z axes
Main Animation Loop
- Transforms
- Camera Calculations - get Normals
- sort Depths
- Draw Polygons
Smalltalk 3d Pipeline
Precalculations
- Visibility Regions
- Static lightmaps
- Collision Detection Data Structures
Game
- Initialise Graphics
- Read Game world
Loop
- Read input from users - keys, mouse
- Tick all objects
- transform all objects
- Collision Detection
Draw
- Cull objects
- Frustrum Culling
- Occlusion Culling
- Backface Culling
- Z-sorting
- Render From Camera's Perspective
3d Pipeline
Initialisation
- Precalculate Normals
- Normalize normals
Loop
- Rotate + translate points and normals
- backface Cull
- Sort depths
- Frustum cull
- Draw To Scene
- Increment angles and translation variables.
9 Engine Pipeline
- Rotate and translate
- Calculate Normals
- Calculate average z-Value for each face
- Lighting
- Backface Culling
- Set Fill colours
- Draw
- SwapDepths(Math.floor(meanZ+10000))
Andre's milk bottle pipeline
- Initialise PointsArray
- Initialise FaceList/s
Loop
- Rotate/translate Points
- Perspective calculations - 3d to 2D
- Z-sort
- Calculate normals
- Calculate colours
- draw
ef3d engine Pipeline
Initialisation
- Init points variables
- Init Arrays
- Init camera
Loop
- Transform to World Space
- Transform to Camera space
- draw
- translate object
- rotate object
3d Pipeline basic
Loop
- Rotate/translate
- Calculate normals
- Calculate light vectors
- z-sorting
- Perspective , 3d to 2D
- Draw
Go here for a summary of Alan Watt's perspective on the 3D Rendering Pipeline
If you want your algorithm to go up here, or have any comments, suggestions,
criticisms , please
post to the board.
|