Google Ads

Questions for the Author?

Navigation

 ·   Wiki Home
 ·   Wiki Help
 ·   Categories
 ·   Title List
 ·   Uncategorized Pages
 ·   Random Page
 ·   File Upload
 ·   Uploaded Files
 ·   Recent Changes
 ·   RSS
 ·   Atom
 ·   What Links Here

Active Members:

Search:

 

Create or Find Page:

 

View Direct3D Concepts

Direct3D Concepts

I haven't found a really concise description of how to understand Direct3D.

Basic Direct3D

Conceptually, you create a Direct3D Device that knows how to do just two things:

  • Control the video hardware directly for maximum performance
  • Control of a camera
  • Drawing triangles to the video in 3D perspective from the camera's perspective

The drawing of triangles is called rendering in Direct3D, and if you draw enough triangles you end up with something that actually looks like a scene. The triangles can be rendered with the following kinds of effects:

  • lighting of the triangle surface (this doesn't include cast shadows) based on light sources placed in the scene
  • the way the lighting is blended between joints of adjacent triangles
  • the color of the triangles (using Textures, which are just bitmaps)
  • the way light is reflected (using Material properties)
  • fog effects

In addition to these basic effects, programmers can further modify the way that triangles are rendered using Effects. Effects are written in a different language called High Level Shader Language (HLSL), and can process both triangle vertex and pixel data, modifying them on the fly.

Direct3D Drawing Sequence

After you've set up a Direct3D device, you need to prime it. You can think of the device as producing finished graphics from raw resources. These resources come in several flavors:

  • Vertex Buffers -- these are the lists of triangles
  • Texture Buffers -- these are the image bitmaps that are drawn on the triangles

At the time of rendering, there are several settings that can be set.

  • Current Vertex Stream -- the source of triangle data to draw
  • Active Lights -- which lights are active, that affect the shading of triangles
  • Current Material -- describes how the triangles should reflect light so it looks shiny, rough, etc.
  • Current Texture -- what bitmap to use
  • Current Effect -- For custom vertex and pixel processing using Shaders...this is how you get interesting looks from your 3D models.
  • Camera Properties -- the location of the camera, and its lens settings

Rendering can take place in several passes and subpasses, drawing from multiple vertex buffers, materials, textures to draw a complete scene. The Direct3D Device settings active at the time of drawing a particular set of vertices changes the way they are drawn.

Video Buffering

All this drawing is done on a Surface, which is a block of video memory. Since this is a shared memory resource, you need to request exclusive access to it (called locking) before you can modify them directly.

There are usually at least two surfaces, a front buffer buffer and a back buffer. You can think of the front buffer as the "stage" where everything happens, and back buffer is "back stage". All the scene construction via Direct3D rendering happens on the back stage while the front stage is being viewed by the audience. When rendering is done, the front stage is magically switched with the back stage, so the screen updates all at once. In Direct3D lingo, this is called "Presenting".

Building up a Scene

Direct3D by itself just know how to handle the drawing of triangles. There are also several utility classes that manage the loading of vertex data and materials, do 3D mathematical calculations, and so on. These are found in the DirectX.Direct3D.Direct3DX utility namespace.

Moving beyond basic Direct3D, game engines such as Irrlicht contain many routines so you don't have to write all this glue code from scratch.

Tools

For shader programming and design, nVidia has FX Composer .

For creating Mesh (.X) files, various 3D programs have ways of exporting them.