It’s been quite a while since my last 3D game engine post, but I haven’t forgot about it. In fact, I’ve been so heads-down in research I haven’t really done any development at all. I still feel like there are a few more books I will need to read to be better prepared, but I guess that will always be the case. So I’ve decided to at least start some preliminary work on the engine itself. Honestly, I’ve barely even started but I thought this series would be more interesting if you saw the genesis of the engine. From absolutely nothing to, well, I hope something respectable.

Since I’m considering this the precursor to my first 3D engine, I am code-naming the project “Engine Zero”. Partly because this is sort of the “day zero” and partly because I’m a programmer and zero comes before one. Though it does look like there is a “Zero Engine” already, so I will have to come up with a better name once I am further along. So behold, the first screenshot of the engine below. Yes, it’s just a message box. You have to start somewhere, right?

Engine Zero 01

OK, so that took all of 5 minutes to whip together. But I have done some planning in terms of file management and source control. First off, the way Visual Studio organizes files by default is non-optimal. Having the source files mixed in with project/solution/temp files is not what I want. So I have made a folder just for source code, another for the build binaries, and a project folder for everything else. This feels a lot cleaner and will help keep the project more organized. You can see the structure below.

Engine Zero 02

Next up, I created a source control repository for the project. I ended up going with Subversion, as this will be fine for just coding by myself. I know everyone loves Git, but honestly I find the tools and front-ends for Subversion to be a lot more mature than with Git. If I can use a user-friendly GUI and save myself time, I’d rather do that over command-line hacking. However, I am not using source control as my sole backup method. I have the project folder backing up to an external hard-drive and to the cloud. Plus, it saves each file revision, so I could rollback changes even if I forgot to commit to SVN. It would literately take Armageddon to destroy this code. And, frankly, if it’s the end of the world I’ll probably have more important things to worry about than the integrity of my backups.

Anyway, I am still very excited about this project and think the potential is enormous. While there is not much room for yet another 3D engine, I think I have some innovative ideas to bring to the table that the community would be genuinely excited about. I don’t want to over hype things this early into development, or give away all my ideas, but if you stick around with me through this series, I think it’s going to be a fun ride.

3D Game Engine Programming
The quest to become a master of 3D engines has brought me to another book, 3D Game Engine Programming by Stefan Zerbst (with a forward from the legendary Andre LaMothe). This is one of the first books I’ve read in a while that wasn’t available on the Kindle, and it’s out of print, but I managed to find a used copy of the paperback without a problem. At a somewhat meaty 850 pages, it was a little cumbersome to read, especially laying down in bed. It’s really amazing how spoiled you get with new technology. Anyway, the book was great and I enjoyed the whole thing.

Though I have been reading a bunch of books on graphics programming, this one was a refreshing peek into the design of a 3D engine. It was also obvious that the engine was a living, breathing thing. Not just a sample created for the book. Zerbst covers a lot of ground here: rendering with DirectX9, sound, input, scene management, networking, a math library, even creating a simple level editor/low-poly modeler. And he goes in-depth, even to the point of hand-coding assembly for optimizing a vector class. And, somehow, he made it make sense.

I very much enjoyed the amount of code and the amount of discussion that followed each piece. There are tons of code samples throughout the book, with ample explanation as to what everything is doing. Though there were a few cases of long, multi-page code samples, for the most part the author kept things as concise as possible.

Another thing I liked was how Stefan Zerbst broke out each major component of the engine into it’s own DLL (i.e. one for graphics, one for sound, one for input, etc.). I think this is a great idea, and has the potential to speed up development without having to compile all these parts of the engine every time you need to test your game. This is certainly something I want to explore further with my engine.

Surprisingly, the book was not totally outdated considering it was first published in 2004 (almost 10 years ago, OMG!). Granted, there is some discussion of stencil shadows and the fixed-function pipeline but, for the most part, the basic concepts are still valid today. It’s also somewhat amazing (or amusing) that Microsoft created an API (DirectX9) that still going strong so many years later.

However, the book isn’t totally without fault. One thing that seemed a little strange was the authors liberal use of global variables for key parts of the engine. He would even say: “I am just using a global here to make things simple as an example, you may not want to do this in your engine” or something to that effect. I understand making things easy for illustration, but why not show us the right way to do it?

It’s not like one single book could ever cover all you need to know about writing 3D engines, certainly not in 850 pages. That being said, 3D Game Engine Programming is an awesome resource for the aspiring engine creator. It covers territory not seem in other books and really digs deep into the aspects that matter. All-in-all I found this text to be helpful and am glad to have it in my growing collection.

Practical Rendering

I was thoroughly impressed by Practical Rendering and Computation with Direct3D 11 by Jason Zink. Microsoft’s Direct3D API is certainly not for beginners, and neither is this book. But, at the same time, the author does a great job of explaining the material in a way that is approachable. The book assumes you are already comfortable with C++, and doesn’t hold your hand with the syntax. This is great, since you really should have an understanding of C++ before jumping into 3D graphics programming. It’s also not the kind of book that expects you to type in long pages of example code into your computer. In fact, there are not really any complete examples listed in the book at all. Instead the author chooses to highlight specific API calls and explain how different techniques can be implemented using the GPU.

This is in stark contrast to the last DirectX 11 book I read by Frank Luna. Luna’s text was great, don’t get me wrong. But it was very focused on producing functional demos to showcase certain effects (like shadow mapping or ambient occlusion). Instead Zink chooses to go totally knee-deep into the API itself and, as a reader, I came away much more confident that I understood the material. Just as an example, early on in the book there is a 100 page chapter just on resources. Most other tutorials would briefly show how to create a buffer, and then move on other stuff. Not here. In fact, the next 200 pages of the book is just about how the pipeline works. It’s really great, and rare to find such insight.

Don’t be fooled, there is certainly code in these pages, and there are a few examples. The book covers some topics like deferred rendering, multi-threaded graphics, dynamic tessellation, and physics. What I liked about the examples is that only the bare minimum amount of code was shown. Just enough to understand the key concepts without getting bogged down with boiler-plate code. It also made reading along much nicer, without having to feel like you need to get up every 5 minutes and type something in on a PC. Plus, the source code for the examples, and the author’s engine, are available for free online. So no need to type either way.

One thing I really enjoyed was the discussion on DirectCompute and on compute shaders. There are hardly any books covering DirectCompute, so it’s great to see so much space dedicated to the API. I am very interested in using this in my own engine, though it’s difficult to find information on the topic. Practical Rendering and Computation includes several chapters using compute shaders, for example to do image processing (blur). There was also a good amount of space given for tessellation. So if you are at all interested in these specific topics, it’s pretty much a no-brainer to get this book.

One other thing. Mad props to Jason Zink for being available to the community. You’ll find him on the gamedev.net forums, even helping out newbies with their 3D questions. Much respect.

All-in-all, this was quite an eye-opening read. I mean, after reading the Luna book and doing some online tutorials, I thought I knew about DirectX 11. Well, I knew something. But this book went much further than what I had previously seen on the topic. I would even recommend reading this *before* Frank Luna’s book, as I think that would flow a little better. Get the foundation solid, and then start learning how to code specific effects. Anyway, this book comes highly recommended by me if you are attempting to learn Direct3D.

3D Game Programming

Frank Luna’s DirectX series has been the go to book for DirectX development for many years. Although there are other great resources, Luna’s writing is both informative and approachable. The book also covers a broad range of topics from the basic lighting, texturing, and blending, to terrain rendering, normal and displacement mapping, geometry and compute shaders and more. He even tackles some tough topics like shadow mapping and ambient occlusion in a way that is understandable. Overall a lot of good material in a package that’s a bit under 900 pages.

The book assumes you have some knowledge of graphics and C++ programming, though it does go over some of the basics at the beginning. So you don’t need to be a graphics wizard to read this book, but you should at least have a firm grasp of C++ and some idea about 3D mathematics. Though you don’t need previous knowledge of DirectX. I had some experience with DirectX 9 going in, and I was still surprised about some of the changes with DirectX 11. Although the basic concepts are the same (using vertex and index buffers, for example), the code to accomplish things were very different in places.  That said, Luna’s style made even some of the denser code snippets manageable.

Luckily, the included samples did compile with only minor changes to the project properties. I purchased the Kindle e-book, but was able to download the samples from the website. Although I enjoyed the e-book, I will make note that many of the code snippets didn’t look great on the device. This is a common problem with programming books on the Kindle, where code that should be on one line spans multiple lines and makes a mess of the original print formatting. Unfortunately this book is not much better in that regard. Even so, I was still able to follow the code. I just wish more care would be taken with the formatting.

All in all, a great resource and should not be missed if you plan on writing a game or engine with DirectX 11.

 

For quite some time I have been waiting for a good data-glove to hit the market for use with virtual reality applications. So far the only consumer product that has come remotely close was the P5 glove, which was probably one of the biggest disappointments in my life. Although better data-gloves have existed since the 90’s, they have been so expensive to only be attainable by large corporations or the government. So with nothing really available off-the-shelf, I have decided to build my own.

Virtual Reality cannot really be had using archaic input devices like the keyboard and the mouse. While fine for web-browsing, they just don’t cut it for immersive interactive 3D  experiences. Tracking hand and finger movements just seem like a very intuitive way to interact with a virtual world. Although there are devices, like the Razer Hydra, that capture some of these elements, it’s just not the VR I dreamed of as a kid if you don’t don the gloves.

Currently I am evaluating good orientation trackers (rather, an inertial measurement unit or IMU). I found the Pololu MinIMU-9 v2 and it seems to fit the bill. The price, at $40, is not too shabby either. It does not come with a USB interface or anything fancy like that, so I had to solder some connections myself and use an Arduino to interface with the PC. Even so, the package is not bad at all. As you can see in the video, the tracking is decent. Maybe not the best I have ever seen, but certainly workable. I’m pretty sure it’s giving better performance than the Hillcrest Labs unit I was previously using, but it’s hard to say just by looking at a quick demo. Anyway, I’m happy with my $40 dollars.

Next up I will be looking at flex sensors to track finger movement. These ones from Spectra Symbol look nice and were supposedly used in the Nintendo PowerGlove (which could be bad or good depending on how you look at it). Hopefully those sensors won’t be too hard to get running, as it would be very convenient to grab parts like these off the shelf. Especially if I want to post the instructions online so other people can build their own.

Finally I will need to construct a proper positional tracking system so physical movement will be mirrored in the simulation. I have a couple of ideas for this, though I still have a lot to experiment with. Stay tuned.

Direct Compute Lecture

Well I know this is kind of old, but I am just discovering it and it seems like a good resource. It’s basically a series of videos put together by Microsoft to explain their DirectCompute API. If you’re not familiar with DirectCompute, it’s an API that allows you to write general purpose algorithms and run them on the GPU. Since the GPU is massively parallel, certain algorithms can run orders of magnitude faster than on the CPU.

Currently I am trying to evaluate if DirectCompute is a good option for building a GPU accelerated physics engine. So far I have watched the first 3 lectures, and it appears to be helpful. If you are interested in leveraging DirectCompute in your applications, you should definitely check out this series.