|
|
|
I've had a hard time finding good DirectX tutorials on the net. I figured if i was having a tough time, i'm sure others are too. So heres Some good tutorials and lessons that have helped me learn a lot.
|
|
ID
|
Title
|
Title/Description
|
|
|
|
|
|
"We will go through the elements necessary to create a minimal Direct3D 10 application. Every Direct3D 10 application must have these elements to function properly. The elements include setting up a window and a device object then displaying a color on the window."
|
|
|
|
|
|
|
"Once we have a Windows application we can start using Direct3D. We must initialise DirectX and create the necessary Direct3D objects used in all our future rendering."
|
|
|
|
|
|
|
"This article attempts to provide a basic base class which applications can derive from to extend Direct3D functionality. This article assumes you have at least a basic understanding of the Win32 API."
|
|
|
|
|
|
|
"Initializing Direct3D and creating a Direct3D Device. C++"
|
|
|
|
|
|
|
"In this first DirectX lesson we will go over how to build a basic Direct3D application. We will also cover a couple of theoretical concepts underlying DirectX which are useful to know. Don't worry, nothing too theoretical."
|
|
|
|
|
|
|
"This Application Creates an Direct3D WIN32 Window. I created this D3D window as similar as possible to the OpenGL window. I did it like this to make it easier to compare the two 3D liberaries."
|
|
|
|
|
|
|
"Till now we created a window, which handles the messages from Windows and started programming the application class. In this tutorial we finish the application class. We will init Direct3D with the appropriate parameters. There are two ways of doing this. The easy and the hard way. In this tutorial we are concentrating on the easy one. Usually we have to enumerate all adapters, devices and modes, which are available on the system, but here we start from knowing the capabilities of the system. We use the default adapter, so when you have two or more graphic cards in your system the standard will be used. We will set the screen resolution, the color bits, the depth buffer bits and the stencil buffer bits."
|
|
|
2
|
Start drawing!
|
Here are a couple basic Direct3D tutorials to get ya started displaying stuff like triangles or squares.
|
|
|
|
|
|
"In this tutorial, we will extend the application to render a single triangle on the screen. We will go through the process to setup the data structures associated with a triangle."
|
|
|
|
|
|
|
"How to cover your display with lots and lots of dots"
|
|
|
|
|
|
|
"The shortest path between 2 points is a straight line. Here's how to draw some."
|
|
|
|
|
|
|
" Fans, Strips and Lists"
|
|
|
|
|
|
|
"Triangles do not make the world go round. They are the world. Because triangles can be combined to form pretty much any shape known to man, games tend to be made out of triangles. In this lesson we will learn how to draw a simple triangle and color it."
|
|
|
|
|
|
|
"This article builds on the previous article; Setting up Direct3D 9 for it's base code, and covers creating a vertex buffer, filling it, drawing a coloured triangle to the screen, and rotating it about the Y axis."
|
|
|
|
|
|
|
"In this tutorial we will draw the first polygons. There will be two objects, a triangle with three different and a quad with one color. Before we can do this we set the needed render states and create some more requirements for drawing. We must create our own specific vertex format and structure with the needed variables included. Then we will draw the polygons with the help of vertex buffers."
|
|
|
3
|
Depth
|
Here you will learn how to render depth and set up a camera or perspective.
|
|
|
|
|
|
"Now our triangle can rotate, can be resized and can move. Our camera can zoom, pan, and change direction. We've got everything set to go. However, there is one problem that must be solved before we go too far..."
|
|
|
|
|
|
|
"Rendering an object defined in Model Space"
|
|
|
|
|
|
|
"The outcome of this tutorial will be a 3D object rendered to screen. Whereas previous tutorials focused on rendering a 2D object onto a 3D world, here we show a 3D object."
|
|
|
|
|
|
|
"How to set up and use a Z buffer."
|
|
|
4
|
Buffers
|
Rendering large complex models can be quite slow. Here are a couple tutorials on vertex and index buffers.
|
|
|
|
|
|
"Now that you can render the basic primitives, here's how to do it faster."
|
|
|
|
|
|
|
"This tutorial covers an easy way to optimize a program or make it faster. Index buffers are used to reduce the number of vertices needed to draw an object. You only need each vertex one time. In the index buffer is stored, which vertices of a vertex buffer are used to draw a triangle. So there are always three indices that describe one triangle. The result is, that there must be stored only a small part of the vertices, which were needed without this buffer. Now you have to store three times the indices of the vertices you want to use, but that is not so much memory, because the indices are only short values."
|
|
|
|
|
|
|
"Translation, Rotation and Scaling"
|
|
|
|
|
|
|
"So far, our triangle does nothing. It sits still, and even if you got it to move, it wasn't in 3D. You made a boring, flat triangle. Now let's bring this triangle to life by transforming it into a 3D triangle, rotating it, moving it around, and even scaling it to a different size."
|
|
|
|
|
|
|
"The contents of this tutorial are solid objects and the rotation and translation of them. We do these operations using the Direct3DX utility library. Solid objects are nothing more than many single polygons, which lie next to each other in 3D space. We will build a pyramide out of four triangles and one quad for the basis. Then we rotate it and translate it into the screen so that we can see it. Using the Direct3DX utility library for that makes it easy. For each rotation and translation we need one matrix. We create these matrices with the Direct3DX functions. Then we have to multiply all matrices together and send it to the device. That's all what we do in this tutorial. We need no more files or functions."
|
|
|
|
|
|
|
"The outcome of this tutorial will be an object that orbits around another. It would be useful to demonstrate the transformations and how they can be combined to achieve the desired effect. Future tutorials will be building on this foundation as we introduce new concepts."
|
|
|
|
|
|
|
"Textures can be thought of as wallpaper that is shrink-wrapped onto a surface. You could place a wood texture on a cube to make the cube look like it is actually made of wood."
|
|
|
|
|
|
|
"An example of applying a texture to a simple quad"
|
|
|
|
|
|
|
"Now that you know how to build basic models, its time to make them look good. Adding textures is a way to add images onto your 3D models, and this lesson will cover the basics of how to do this."
|
|
|
|
|
|
|
"Now where we have done all the basic stuff, like the initializationof Direct3D and creation simple objects, we can make something new. In this tutorial we will start using texture mapping. Textures are a simple 3D effect, but have an enormous result and are very easy to use. The first thing we have to do is to change the custom vertex format. Then we only need to load the texture with help of the Direct3DX utility library. Two important things are the texture coordinates, which we need to establish how the texture is displayed on the triangle, and the filters, which smooth the texture. The filters are already set in the application class. You can choose the filter type in the settings dialog."
|
|
|
7
|
Lighting
|
Lighting makes things look much much better and realistic. I
|
|
|
|
|
|
"Direct3D lights add more realism to 3D objects. When used, each geometric object in the scene will be lit based on the location and type of lights that are used. The sample code in this tutorial introduces the topics of lights and materials."
|
|
|
|
|
|
|
"In the previous lessons we have turned lighting off for simplicity. However, no lights in a 3D world makes everything look fake. Lights add good effects to your game, even if they are as simple as day and night. This lesson will cover the basics of lighting and show how to make a simple light."
|
|
|
|
|
|
|
"There is more to lighting than a simple Directional Light. This lesson covers more types of lights you can use."
|
|
|
|
|
|
|
"In this tutorial we will handle one of the most important topics in 3D graphics programming. Lighting helps us creating realistic scenes or different atmospheres in a game. To use lighting we have to create a light source, of course. In the fixed-function pipeline DirectX supports simultaneous light sources, but they are rarely needed. The number of supported active lights is specified in the D3DCAPS9 structure. The light source for this tutorial is a directional light, which means that the direction of the light is equal for the whole scene. To use lighting we need to know in which direction the triangles of our scene face. This information is stored in the normal, which is perpendicular to the triangle. The light intensity for each vertex is the dot product between the light vector and the normal vector. The material for the object is either given by the diffuse color value or a material structure, which we will use here."
|
|
|
|
|
|
|
"Direct3D provides four different types of light, ambient, directional, point and spot. I describe these lights below but you are also advised to look in the DirectX help for the more advanced details. Lights are added to your scene using the Direct3D device interfaces. Whenever geometry is rendered it may be lit by these lights."
|
|
|
8
|
Blending/Transparency
|
In These lessons you will learn how to use blending for cool effects and transparency.
|
|
|
|
|
|
"This tutorial covers a nice effect. We want to make the polygons of the pyramide transparent with alpha blending. We will use the alpha value of the vertex color. To do this we have to add a diffuse color value to the vertex structure again. Then we set the alpha value to 50%, so that the texture will be half transparent. Before we can use alpha blending we have to change the render states. We enable alpha blending and deactivate the depth buffer, because the hidden surfaces are now also visible and they wont be drawn with an activated depth buffer."
|
|
|
|
|
|
|
"In the seventh tutorial we already had the topic of alpha blending with the alpha value of the vertex color. This time we will cover a new way of using transparency. We will load a texture, which shows a leaf. As you can see there is a black border around the leaf, but we don't want the black area to be displayed. Here we come to the color key. The color key defines one specific color, in this case black, which shouldn't be drawn to the render surface. The Direct3DX utility library includes a function, which can be used for that. On the image below you can see the leaf."
|
|
|
|
|
|
|
"This is another nice tutorial about alpha blending. It covers alpha blending with the alpha channel of a texture loaded from a bitmap. We just load a texture, which includes an alpha channel, after we have enabled alpha blending. We use the same texture as in the last tutorial, but this time we have the alpha channel included. On the image below you can see the alpha channel of this texture."
|
|
|
|
|
|
|
"With DirectX 6.1 Microsoft introduced multitexturing, also known as texture blending, to his API. Direct3D supports the blending of up to eight textures on a primitive in a single pass through the use of texture stages. You can apply one texture to all of these stages. Each texture stage takes two arguments and performs a blending operation between them, both defined by the application. There are several texture arguments and texture operation flags usable. For a complete list please take a look in the SDK documentation. With the help of these arguments you can access results of a previous texture stage, which is used to perform multitexturing. All texture operations are possible for color and alpha values."
|
|
|
|
|
|
|
"There are often people, who have graphic cards that don't support single pass multitexturing or want to use more than the supported textures. These people can use a technic called multi pass multitexturing. In this tutorial we try to replicate the result of the last tutorial with multi pass multitexturing. Multi pass multitexturing is done as follows. We set a texture in the first texture stage and define all arguments needed for rendering. Then we simply render the primitive. Now we set the second texture in the first texture stage and define color or alpha blending render states to adjust the blending factors as needed. Now we render the same primitive again with the new texture and blending factors. The system now blends the already rendered colors and the new colors of the second texture according to the blending factors."
|
|
|
|
|
|
|
"Alpha blending with a per-vertex transparency."
|
|
|
|
|
|
|
"Sometimes you wish to have objects be see-through. This includes windows, glass objects, clouds, and much more. These effects are achieved by blending colors together, the color of what you are drawing and what is in the background. This lesson will cover how to do simple color blending."
|
|
|
|
|
|
|
"The alpha channel is not the only way to achieve transparency. Another type of transparency is having an image, and everything around that image be invisible. You will learn how to do this in this lesson."
|
|
|
9
|
Rendering States
|
States are used to change the way Direct3D renders primitives.
|
|
|
|
|
|
"In this tutorial we will explore 3 main types of state objects, BlendStates, DepthStencilStates, and RasterizerStates. At the end of the tutorial, you should have a much better understanding of the way in which states interact to produce different representations of the same scene."
|
|
|
|
|
|
|
"There are many states that can be set that effect the rendering of 3D primitives."
|
|
|
10
|
Text
|
Learn how to display text using Direct3D I
|
|
|
|
|
|
"A look at the new D3DXFont interface that was introduced in the DX9 2003 Summer Update"
|
|
|
|
|
|
|
"Using D3DX to create a mesh from text"
|
|
|
|
|
|
|
"The topic of this tutorial is something that is needed in nearly every program. Fonts are used for menus, stats, briefings, etc. The Direct3DX library includes a class, which makes it possible for us to use the Windows true type fonts, but also others. The class is called D3DXFont and is very easy to use. The only thing we have to do is to create the font object and then draw the text. For that we fill a so called LOGFONT structure with the information about name, color, size, etc. of the font. The alignment of the text is stored in a RECT structure. I don't create a new class for this, because it is not much and you better add it to classes where you need it. We only add some code to the main.cpp."
|
|
|
|
|
|
|
"Direct3D comes with a set of interfaces to help you easily draw text to the screen."
|
|
|
11
|
Models/Meshes
|
These tutorials will teach you how to load and display 3D Models.
|
|
|
|
|
|
"Loading and displaying a 3D model is very easy using the D3DX library. This section also describes the more complex methods of animating the models."
|
|
|
|
|
|
|
"We're getting pretty good with triangles, but triangles by themselves are no fun. Let's learn how to make simple shapes out of triangles, and transform each shape as a whole."
|
|
|
|
|
|
|
"Fortunately, there is an easier way to create 3D graphics than coding each vertex into a buffer. That would just be insanity and would take game developers years to make modern graphics, let alone the game engine. Meshes get rid of all that hassle, and allow you to build 3D artwork in a separate program, load it into your game and render it as a single entity."
|
|
|
|
|
|
|
"The Utah Teapot is cool and all, but it really doesn't suit the purposes of a game. I mean, sure you can decorate the rooms with teapots (if you really want), but driving around in a half-converted, unpainted teapot tends to bore the general populace. In this lesson we will go over how to load your own 3D models drawn up in 3D modeling programs."
|
|
|
|
|
|
|
"In the last lesson you made a spaceship. Untextured, but it was a spaceship! *Gasp*! Now we get to learn about textures. OK, so we've learned this already, but textures can be stored inside X files, and getting the texture from the mesh and then setting them is what this lesson will cover."
|
|
|
|
|
|
|
"Notes on writing Vertex and Pixel Shaders"
|
|
|
|
|
|
|
"Vertex shaders allow us to manipulate the data that describes a vertex."
|
|
|
|
|
|
|
"You need to have read the introductory page on Shaders and the page on Vertex Shaders before reading this page. A lot of the concepts in shader coding are shared between vertex and pixel shaders so on this page I just discuss the differences along with examples."
|
|
|
|
|
|
|
"we will actually step through the graphics pipeline and look at how each stage works. The concept of shaders and the effect system will be explained."
|
|
|
|
|
|
|
"The outcome of this tutorial will be a wave effect imposed on the character model from the previous tutorial. This effect is done entirely by the GPU with no CPU interaction with the data."
|
|
|
|
|
|
|
"The outcome of the tutorial is that the model will become shiny, and it will reflect its surrounding environment."
|
|
|
|
|
|
|
"The outcome of this tutorial is that the model will have a second layer extruded from the model. Note that the original model is still preserved at the center."
|
|
|
|
|
|
|
"In the last tutorials with lighting we always used it per-vertex with the help of the normal stored in each vertex. This leads us to a problemnwhen the light comes close to the triangle, which is lit. Though the triangle should appear bright it is not, because the angle between the normal and the light vector is high. That is where dot3 bump mapping, also known as per-pixel lighting, is used to solve this problem. But that is not the only reason to use dot3 bump mapping. It also allows you to add high detail to surfaces or objects without increasing the number of polygons."
|
|
|
|
|
|
|
"This tutorial covers an easy way of creating fog in Direct3D. Sometimes it is also used to hide distant objects needed to achieve high framerates in realtime applications. Direct3D consists of two types of fog called vertex and pixel fog. Vertex fog is faster, as it is only computed per vertex and then interpolated over the triangle. We simply can activate vertex fog through the device's render states. There are several parameters that can be set such as color, start and end distance and the fog formula."
|
|
|
|
|
|
|
"Rendering to a texture is one of the advanced techniques in Direct3D. On the one hand it is simple, on the other hand it is powerful and enables numerous special effects. Examples are the glow effect, first introduced in Tron 2.0, environment mapping, shadow mapping, and many more. Rendering to a texture is simply an extension to rendering to a surface. There are just some additions needed. First the texture itself has to be created. Furthermore some other precautions have to be made. The second step is to render the appropriate scene to the texture. Finally the texture is used to render the final scene."
|
|
|
|
|
|
|
"With point sprites Direct3D offers an often underestimated feature. Though most people share the opinion that point sprites are too unflexible, especially when used for particle systems, they have advantages in memory usage and thus performance compared to usual approaches. This tutorial will just cover the basics of point sprites, but it's still a good base to work with. The name by itself already suggests some of the characteristics. All in all a point sprite is simply a screen-aligned element of variable size that is defined by a single point. This already leads to the advantages of point sprites since all you need is a single vertex for each point sprite instead of four for a textured quad. Using only one vertex, whose overall size is less than the size of usual textured verices, means the among of memory that needs to be transfered over the AGP bus decreases tremendously."
|
|
|
|
|
|
|
"Working with Microsoft Effect Files (.fx)"
|
|
|