• entries
    64
  • comments
    46
  • views
    80441

Entries in this blog

ericrrichards22
Last time[font=Arial]

, we covered some of the theory that underlies blending and distance fog. This time, we'll go over the implementation of our demo that uses these effects, the BlendDemo. This will be based off of our previous demo, the

[/font]Textured Hills Demo[font=Arial]

, with an added box mesh and a wire fence texture applied to demonstrate pixel clipping using an alpha map. We'll need to update our Basic.fx shader code to add support for blending and clipping, as well as the fog effect, and we'll need to define some new render states to define our blending operations. You can find the full code for this example at

[/font]https://github.com/ericrrichards/dx11.git[font=Arial]

under the BlendDemo project.

[/font]
[font=Arial]

blendDemo2_thumb%25255B2%25255D.png?imgmax=800

[/font]

[font=Arial]

Read More...

[/font]
ericrrichards22
[font=Arial]

This time around, we are going to dig into Chapter 9 of

[/font]Frank Luna's Introduction to 3D Game Programming with Direct3D 11.0[font=Arial]

. We will be implementing the BlendDemo in the next couple of posts. We will base this demo off our previous example, the

[/font]Textured Hills Demo[font=Arial]

. We will be adding transparency to our water mesh, a fog effect, and a box with a wire texture, with transparency implemented using pixel shader clipping. We'll need to update our shader effect, Basic.fx, to support these additional effects, along with its C# wrapper class. We'll also look at additional DirectX blend and rasterizer states, and build up a static class to manage our these for us, in the same fashion we used for our InputLayouts and Effects. The full code for this example can be found on GitHub at

[/font]https://github.com/ericrrichards/dx11.git[font=Arial]

, under the BlendDemo project. Before we can get to the demo code, we need to cover some of the basics first, however.

[/font]
[font=Arial]

blendDemo_thumb%25255B1%25255D.png?imgmax=800

[/font]

[font=Arial]

Read More...

[/font]
ericrrichards22
[font=Arial]

We're going to wrap up our exploration of Chapter 8 of

[/font]Frank Luna's Introduction to 3D Game Programming with Direct3D 11.0[font=Arial]

by implementing one of the exercises from the end of the chapter. This exercise asks us to render a cube, similar to our

[/font]Crate Demo[font=Arial]

, but this time to show a succession of different textures, in order to create an animation, similar to a child's flip book. Mr. Luna suggests that we simply load an array of separate textures and swap them based on our simulation time, but we are going to go one step beyond, and implement a texture atlas, so that we will have all of the frames of animation composited into a single texture, and we can select the individual frames by changing our texture coordinate transform matrix. We'll wrap this functionality up into a little utility class that we can then reuse.

[/font]

[font=Arial]

firebox_thumb%25255B1%25255D.png?imgmax=800

[/font]
[font=Arial]

https://www.youtube.com/watch?feature=player_embedded&v=6Q8o06YRxc0

[/font]


[font=Arial]

Read More...

[/font]
ericrrichards22
[font=Arial]

This time around, we are going to revisit our old friend, the Waves Demo, and add textures to the land and water meshes. We will also be taking advantage of the gTexTransform matrix of our Basic.fx shader to tile our land texture multiple times across our mesh, to achieve more detail, and use tiling and translations on on our water mesh texture to create a simple but very visually appealing animation for our waves. This demo corresponds to the TexturedHillsAndWaves demo from Chapter 8 of Frank Luna's Introduction to 3D Game Programming with Direct3D 11.0. You can download the full source for this example from my GitHub repository at https://github.com/ericrrichards/dx11.git.

[/font]
[font=Arial]

Here is a still of our finished project this time:

[/font]
[font=Arial]

texHills_thumb%25255B1%25255D.png?imgmax=800

[/font]
[font=Arial]

I'm also going to try to upload a video of this demo in action, as the static screenshot doesn't quite do justice:

[/font]
[font=Arial]

https://www.youtube.com/watch?feature=player_embedded&v=Xb5k3NxiPeo

[/font]

[font=Arial]

Read More...

[/font]
ericrrichards22

Texturing 101

[font=Arial]

This time around, we are going to begin with a simple texturing example. We'll draw a simple cube, and apply a crate-style texture to it. We'll need to make some changes to our Basic.fx shader code, as well as the C# wrapper class, BasicEffect. Lastly, we'll need to create a new vertex structure, which will contain, in addition to the position and normal information we have been using, a uv texture coordinate. If you are following along in

[/font]Mr. Luna's book[font=Arial]

, this would be Chapter 8, the Crate Demo. You can see my full code for the demo at

[/font]https://github.com/ericrrichards/dx11.git[font=Arial]

, under DX11/CrateDemo.

[/font]

[font=Arial]

crate_thumb%25255B1%25255D.png?imgmax=800

[/font]

[font=Arial]

Read More...

[/font]
ericrrichards22
[font=Arial]

This time, we are going to take the scene that we used for the

[/font]Shapes Demo[font=Arial]

, and apply a three-point lighting shader. We'll replace the central sphere from the scene with the skull model that we loaded from a file in the

[/font]Skull Demo[font=Arial]

, to make the scene a little more interesting. We will also do some work encapsulating our shader in a C# class, as we will be using this shader effect as a basis that we will extend when we look at texturing, blending and other effects. As always, the full code for this example can be found at my Github repository

[/font]https://github.com/ericrrichards/dx11.git[font=Arial]

; the project for this example can be found in the DX11 solution under Examples/LitSkull.

[/font]
[font=Arial]

litskull1_thumb.png?imgmax=800litskull2_thumb.png?imgmax=800litskull3_thumb.png?imgmax=800

[/font]
Left to Right: Rendering the scene with 1 key light, rendering the scene with key and fill lights, rendering the scene with key, fill and back lights

Read More...
ericrrichards22
Last time, we finished up our exploration of the examples from Chapter 6 of Frank Luna's Introduction to 3D Game Programming with Direct3D 11.0. This time, and for the next week or so, we're going to be adding lighting to our repertoire. There are only two demo applications on tap in this chapter, but they are comparatively meatier, so I may take a couple posts to describe each one.

First off, we are going to modify our previous Waves Demo to render using per-pixel lighting, as opposed to the flat color we used previously. Even without any more advanced techniques, this gives us a much prettier visual.
waves_thumb.png?imgmax=800lighting_thumb.png?imgmax=800

[font=Arial]

To get there, we are going to have to do a lot of legwork to implement this more realistic lighting model. We will need to implement three different varieties of lights, a material class, and a much more advanced shader effect. Along the way, we will run into a couple interesting and slightly aggravating differences between the way one would do things in C++ and native DirectX and how we need to implement the same ideas in C# with SlimDX. I would suggest that you follow along with my code from

[/font]https://github.com/ericrrichards/dx11.git[font=Arial]

. You will want to examine the Examples/LightingDemo and Core projects from the solution.

[/font]

[font=Arial]

Read More...

[/font]
ericrrichards22
We'll wrap up the slate of examples from Chapter 6 of Frank Luna's Introduction to 3D Game Programming with Direct3D 11.0 by taking a look at updating a vertex buffer each frame, as opposed to the immutable vertex buffers we have been working with previously. We will be using the Hills Demo that we created previously as a starting point, and add a second grid mesh that will represent water. We will update this mesh each frame, to get the ripple effect shown below.

waves_thumb%25255B1%25255D.png?imgmax=800

Read More...
ericrrichards22
This time around, we are going to be loading a pre-defined mesh from a simple text-file format. This will be a rather quick post, as the only thing different that we will be doing here is altering our CreateGeometryBuffer function to load the vertex and index data from a file, rather than creating it on-the-fly. If you are following along with me in Frank Luna's Introduction to 3D Game Programming with Direct3D 11.0, this example corresponds to section 6.12, and is a port of the Skull Demo from the example code.
skull_thumb1.png?imgmax=800

Read More...
ericrrichards22
This time up, we are going to add some additional shape types to our GeometryGenerator class, and look at how to redraw the same geometry at different locations and scales in our scene. This example corresponds to the ShapesDemo from Frank Luna's Introduction to 3D Game Programming with Direct3D 11.0.

shapes_thumb%25255B1%25255D.png?imgmax=800
NOTE: The framerate is atrocious because I am running on an old Intel G45/43 integrated chipset... On a real 3D chipset, like my GTX 560 Ti, you would have several thousand frames per second.

As you can see, in addition to the Grid mesh that we implemented previously for the Hills Demo, we have added a box, spheres, and cylinders. We are also only keeping a single instance of each type of geometry in our vertex and index buffers, and drawing them with different world matrices to render multiple objects in our scene. Lastly, we are drawing in wireframe mode, which involves setting up some different render states from our previous examples.

Read More...
ericrrichards22
This time around, we are going to be porting the Hills Demo of Frank Luna's Introduction to 3D Game Programming with Direct3D 11.0 from C++ to C# and SlimDX.

This will be very similar to the previous entry, where we drew a colored box, with a few changes:

  • We'll start developing a class to generate mesh geometry (to replace the functionality that used to be present in previous versions of DirectX in the D3DX libraries).
  • We'll be using pre-compiled effect files, rather than compiling them at runtime.
    hillDemo_thumb%5B1%5D.png?imgmax=800
    Read More...
ericrrichards22
I'm going to skip over the first few chapters of Introduction to 3D Game Programming with Direct3D 11.0. I've got a basic understanding of basic linear algebra for 3D graphics, and I'm not eager to get into the weeds there, instead opting to go straight into the meat of DirectX coding. Besides the math pre-requisites, these chapters also give an overview of the XNA Math C++ library, which I am going to forgo for the SlimDX types instead.

With that out of the way, we will begin with Chapter 4, Direct3D Initialization. This chapter covers basic initialization of the Direct3D device, and lays out the application framework used for the rest of the book. If you've read any of Mr. Luna's other DirectX books, this framework will look very familiar, and even if you have not, it is basically a canonical example of a Windows game loop implementation. The framework provides a base class that handles creating a window, initializing DirectX, and provides some virtual methods that can be overridden in derived classes for application-specific logic. Additionally, this chapter introduces a timer class, which allows for updating the game world based on the elapsed time per frame, and for determining the frame rate, using the high-performance system timer.
Capture_thumb%255B8%255D.png?imgmax=800
Read More...
ericrrichards22
A while back I picked up Frank Luna's Introduction to 3D Game Programming with DirectX 11. I've been meaning to start going through it for some time, but some personal things have cut into my programming time significantly. I recently acquired a two year old Australian Cattle dog, and Dixie has kept me on the dead run for the weeks... It's very difficult to muster up the courage to dive into a programming project when you feel half zombified from getting up at 4:30 to let the dog out so she will stop her adorable yet frenzied licking attacks on your fiance.
8642_10152898576275296_798694434_n.jpg

But today, I'm going to start. I have not dealt with DirectX 11, nor 10 before; it's only in the last year or so that I built myself a modern desktop to replace my badly aging laptop from 2006. I do have some experience playing around with DirectX 9, so it will be interesting to see what has changed.

As I mentioned, I'll be going through Introduction to 3D Game Programming with DirectX 11 by Frank D. Luna. At first glance, it seems very similar to his previous book, Introduction to 3D Game Programming with Direct X 9.0c: A Shader Approach, which I found to be very well-written, with easy to follow code examples. One wrinkle is that I'm going to be doing this in C#, with SlimDX, rather than in C++ and straight DirectX 11. At my job, I mostly write C#, and have developed a serious fondness for it. Additionally, I've found that attempting to port C++ code over to C# is a somewhat interesting exercise, and not a bad way to learn some of the darker and less-common corners of the C# standard libraries.

I plan on doing a post on each major example. So there may be a couple per chapter, and I don't know what kind of pace my schedule will allow me. If you're interested at looking at my code as I'm going along, you can clone my Git repository at https://github.com/ericrrichards/dx11.git. I'm not going to include the original book code (I couldn't find a license specifically for the code, and I'm struggling to parse the legalese on the inside cover of the book), but you can download it from the book's website at http://www.d3dcoder.net/d3d11.htm.

(This was originally posted at http://richardssoftware.blogspot.com/2013/07/learning-directx-11-via-slimdx.html)