C++, Graphics, Programming, Review, Vulkan

Review: Vulkan Graphics API: in 20 Minutes by Kenwright

Vulkan Graphics API: in 20 Minutes is short, no-nonsense, introduction to the Vulkan graphics API. Though the title of the book says “20 minutes,” I believe I spent somewhere between 1 and 2 hours to finish it (though I admittedly read pretty slow). This is the type of book I wish there were more of: something short and sweet as a brief  intro to get your feet wet. I feel many programming books can be daunting at 600+ pages, so it’s nice to find something you can complete in one or two sittings.

So what is actually covered in this little book? Basically it shows the basics of how to initialize the Vulkan renderer and draw a triangle on the screen. The author does not use any additional libraries, so it’s only showing the Vulkan API itself and some boilerplate Win32 code for opening a window. Though I had already been reading about Vulkan previously, and didn’t find any new material here, I could see this as a decent first step in learning the API.

To be honest,  Kenwright does not really provide any deep explanation of the concepts presented. It’s basically just showing some of the common function calls and the structure to set things up. You could easily find similar code online (at various sources) for displaying a triangle in Vulkan.  Even so, I still think the text holds value and may be more accessible than some of the larger (and more costly) Vulkan books that do provide more detail. This is sort of something that would be useful if you’ve really never worked with the API before and just want to see how the code looks and if it’s something you’re interested in prior to researching further.

All in all, I can’t really fault  Vulkan Graphics API: in 20 Minutes too much. While there were a couple typos and odd use of the English language, overall the book was concise and coherent. It provided a cursory look at a new, exciting, graphics API and it did with with a meager time and money investment on behalf of the reader. While you can find basically the same material online for free, I still personally enjoy learning from books and think the format may click for some people better. It only really scratches the surface, but as a short “first intro” book it’s not bad.

C++, Graphics, Math, Physics, Programming, Review

Review: Essential Mathematics for Games and Interactive Applications by James M. Van Verth and Lars M. Bishop

Essential Mathematics for Games and Interactive Applications by James M. Van Verth and Lars M. Bishop is a quality math book if I ever saw one.  Strangely, the first edition came out in 2004 but the book was kind of off my radar until recently.  This third edition was published in 2015 and seems very current. The authors here do a great job of explaining the material properly. I felt like they created a great foundation for learning these complex ideas and I appreciated the  quality and readability of the code  samples.

The book starts with an overview of computer number representations, and goes into detail with the IEEE 754 floating-point standard. At first I assumed this was unnecessary detail, but actually it’s pretty useful to understand and a good base to build on. They continue with vectors and points, linear transformations and matrices, affine transformations,  orientation (including matrices, Euler angles, axis-angle, and quaternions),  and interpolation (linear and curved). In the next section they transition to more graphic oriented topics such as: viewing and projection, geometry and programmable shading, lighting, rasterization, then a random chapter on… random numbers, and finish off with intersection testing  and rigid-body dynamics.

Just looking at the table of contents is sometimes not enough to get a feel for the quality of the text, so I will reveal  more. The beginning parts are really exactly what you’d expect for a game math book. The basics of vectors, matrices, quaternions, etc. are the bread and butter for a 3D programmer. The coverage here is solid and great for a beginner. Advanced readers  may not find any surprises, but it’s still a good refresher.  The interpolation chapter I found interesting, especially the detail into different types of curves and splines .  This could be immediately useful for coding  a skinned character or animating a camera in a game.  Viewing and projection were given adequate coverage and are essential to anyone wishing to code a graphics engine themselves.  The next chapter was particularly long and explained the programmable shader pipeline to great effect.  The authors explained everything from color representation, vertex attributes, drawing geometry, fixed-function versus programmable, vertex and fragment shaders (aka pixel shaders), and texture mapping. Really a great introduction for anyone wanting to learn to code shaders themselves.  Then they  move onto lighting and go into the basic types (point, spot, directional, and ambient), surface materials, per-vertex and per-fragment lighting, combining with textures, and a few small sections of more advanced topics like normal mapping, physically based lighting, HDR, and deferred shading.

Next up is rasterization, which was an awesome chapter that explained (in epic detail) how rasterizers work which I feel does help when you know what’s going on behind the scenes. I don’t know of many other books that explain this part of the pipeline so well, so this was much appreciated. The random number chapter was also quite informative. It’s easy to just call a function that spits out a number and not actually understand what’s happening.  I found this  portion of the book to be a nice surprise. Intersection testing was covered near the end, and  it was one of the longer chapters. Almost anything you could think of was here: finding distances from lines and points, sphere/ray/plane intersections, axis-aligned bounding boxes (AABBs), swept spheres, object-oriented boxes, triangle intersection, and a simple collision system. Finally the book closes with a chapter on rigid-body dynamics. I actually purchased my copy mostly for the rigid-body material and I felt I learned a few useful things. Of course, it was only one chapter but some of the explanation was better than whole books I’ve read on physics. Certainly it gave me a few things to research further, and I appreciate that.

Overall I would say that  Essential Mathematics for Games and Interactive Applications is an almost flawless textbook. I may be a great place to start for a beginner, and even intermediate to advanced readers may learn a thing or two. Some of the other game math books I recommend I read so long ago it’s hard to make a direct comparison. But this title is certainly up there with the best. I would wholeheartedly recommend.

Math, Physics, Programming, Unity

Custom 2D Physics in Unity Using Verlet Integration


So 2017 will be my year of “doing the work,” a line I learned from Steven Pressfield in his excellent book named, unsurprisingly, “Do the Work.”  I’ve spent literally years reading about 3D math and physics and, outside of a few small demos I’ve experimented with and never released, I haven’t actually produced anything. I’ve also been inspired and motivated by a variety of books, most recently “Little Bets” which talks about innovators from Steve Jobs to Pixar and how they developed their craft. So, hopefully this year I can work on various smaller projects to hone my skills and really apply the knowledge I’ve gained.

To begin with, I’ve implemented a Verlet Integration based 2D physics engine in Unity, shown in the video above. I created this in basically 1 day over a weekend, and am pretty impressed with the initial results. To be fair, all the logic was taken from a C++ tutorial I found online,  A Verlet based approach for 2D game physics by Benedikt Bitterli, and basically what I did was re-implement it in C# and Unity. I’m no stranger to Verlet Integration, and did similar work many years ago in Flash after reading  Thomas Jakobsen’s breakthrough 2003 article, Advanced Character Physics.  So I very much understood the concepts already and could hit the ground running.

The idea was to begin with something small and achievable, and then build upon it. I started with 2D first, but it shouldn’t be that hard to expand the demo to support 3D as well. Eventually I’d like to explore GPU accelerated physics using Compute Shaders, but I do understand that’s a very complex proposition. Some of my earlier experiments with GPGPU programming were initially positive, but I quickly hit walls with the fundamentals of data structure and the huge can of worms of massively parallel computation. Still, I believe the potential is there, but I have a lot more to learn to harness that kind of power.

After my failed excursion in 3D engine programming, I’m a bit hesitant to make another series out of this. I do hope to continue exploring physics more, and will try to share what I can of the process as I move forward. Honestly, looking back at a lot of the games I’ve programmed in the past, I realized it was mostly the physics that made the games fun. Back then it was when Flash and 2D web games were big, so it was feasible to write the physics code by hand for each game. Today, with 3D being the norm, that kind of customized physics per-game is not tenable but, at the same time, I feel that many developers just use their engine of choice’s built-in physics and things haven’t really evolved.  I have some ideas I’d like to explore that just aren’t possible with what is on the market. Maybe the state of the art is just not there yet, or current hardware is not capable, but I feel compelled to at least try. If everything goes well maybe you will see more of these physics posts from me, and maybe something will come of it. Or, maybe not. I guess we will see.

C++, Math, Physics, Programming, Review

Review: Beginning Math and Physics for Game Programmers by Wendy Stahler

beginning_math_and_physics

Beginning Math and Physics for Game Programmers by Wendy Stahler is the kind of book I like. The title is straight-forward, and the content actually delivers what it claims. I’ve read a number of game development math books but I find that many of them expect a college level mathematics background, or at least some intermediate knowledge already. Not here. This is a book that is accessible to stark beginners, and I’d even recommend it to high school students.

Stahler’s text covers all the basics for both 3D math and physics. Topics include: points and lines, geometry, trigonometry, vector and matrix math, transformations, unit conversions, motion, Newton’s laws, energy and momentum, collisions, and, finally, rotational motion. Clocking in at around 500 pages, there is enough space to delve into each area with adequate coverage. I found the explanations to be very clear and geared to novices.  The author uses lines like: “The fancy name for moving objects in these directions is translation.” While advanced readers may feel somewhat patronized by the language, I actually think this is a great approach for beginners. 3D programming is not easy, but sometimes the arcane conventions used in more advanced books can be off-putting to people just getting started.

One thing I should note, I don’t typically test code samples or verify the accuracy of formulas while I’m progressing through the text. What I expect from the book is to gain a high-level conceptual understanding of the material in order to better grasp the subject matter. When it comes to the actual programming implementation, I will just use the book as a reference but usually find the formula online on Wikipedia or similar sites. I realize some people expect every code sample to work, but I’m not one of those people. It’s the concepts themselves that are important to learn and once you understand you should be able to know what to search for or even implement the code yourself.

One aspect I appreciated was that most of the concepts started with an explanation first in one dimension, then two, then three.  This was especially helpful as it’s conceptually simple to understand something like motion in only 1 dimension and it gradually builds upon that. Some other books jump straight into higher dimensions right off the bat, and that may be difficult to some without prior knowledge. The author also provides ample diagrams, graphs, charts and sample code. She also makes effort to show unit conversions when needed, and emphasizes differences between easily confused units.

Wendy Stahler’s book is, however, somewhat dated being originally published in 2004. While the core material is still relevant, and hasn’t really changed much in those years, some of the samples are written for antique computer systems. For example, for one demo included on the CD-ROM she recommends that the “minimum system requirements for the program are a 700MHz processor, a graphics card with 8MB of memory, and 64MB of RAM.” Those specs would have been laughable even in 2004, when the book originally came out. However, it is humbling to consider my smart-watch has specs that would put the machine those demos were build for to shame.

Overall I enjoyed the book, even with the caveat the nearly all the material was a refresher for me. If you are already a professional game developer, then there probably won’t be much to learn here. I’ve been kind of on a binge of game math and physics books, so I figured I’d give this a shot. I also like to have material to recommend to people new to game development and I find it interesting to read books of different levels to get a broader perspective. If you are just starting out, this may be a nice resource to get your feet wet before graduating to the more complex, but much better math books out there.

3D Engine, Game Engine, Math, Programming, Review

Review: Foundations of Game Engine Development, Volume 1: Mathematics by Eric Lengyel

Volume 1 Mathematics

I’ve always been a big fan of Eric Lengyel, from both his work on the C4 Engine (and now the new Tombstone Engine) and his previous math book, Mathematics for 3D Game Programming and Computer Graphics, which is on it’s 3rd edition and is one of the definitive texts in the genre. This latest book, Foundations of Game Engine Development, Volume 1: Mathematics, I feel does it again and is well worth reading.

The text, which clocks in at around 200 pages (short for a technical book) actually has a decent amount of information crammed into those pages. Lengyel breaks it up into 4 chapters, each focusing on a different aspect. Chapter 1 starts with vectors and matrices, then continuing to transformations, next to geometry and the finishing chapter on advanced algebra. The first 3 chapters are about what you’d expect from a game math book, but explained clearly and succinctly. Early in the book, when discussing vectors, the author states: “Loosely speaking, the dot product provides a measure of how much one vector is like another.” Though it seems obvious now, I’m not sure I’ve ever heard it explained quite as clear before. Much of the rest of the coverage in the first 3 chapters feels like this. While it may be a refresher to many, it’s like seeing some of these concepts in a new light just from the stellar delivery.

As I mentioned, chapters 1 through 3 cover the basics, that most game programmers are likely familiar with. Vector and matrix operations, transformation spaces, finding relations between points, lines, and planes, etc.  I’d consider this to be a good refresher for people at least somewhat familiar with game mathematics. Though I could also see it as an decent introduction for some, there may not be enough hand holding for a complete novice.

However, in chapter 4, Lengyel dives into new territory with Grassmann algebra. Though the math is very old, I’m not sure I’ve ever seen it covered or mentioned in any of the popular game math books I’ve read. The concepts are actually quite interesting, and seem to tie together some different areas that originally seem disparate. To be honest, I think I’d have to read this chapter a second time for the concepts to really sink in. It did make some sense but, being somewhat new material to me, I wasn’t sure how I’d immediately apply the knowledge. That said, I applaud the author for bringing something new to the table and I can’t imagine it being described better.

One part I really did appreciate were the code listings, shown in real C++ code that, while I did not type them in a computer and compile, seem like they would be ready to basically lift off the pages and use in a project. I also very much liked the coding style, which felt clean and modern, unlike some other books I’ve seen where it looked like the code came from a 1980’s mainframe.

Overall, I very much enjoyed this book. It was able to cover basic game mathematics in an extremely clear and concise manner, and introduce new concepts along the way. I think this would make an excellent edition to any game development library. While the book was refreshing at only 200 pages, that brevity meant that some concepts could have been in more depth, and other topics weren’t covered at all. For more thorough coverage, I’d look to  3D Math Primer for Graphics and Game Development by Fletcher Dunn or to Lengyel’s prior book, Mathematics for 3D Game Programming and Computer Graphics. That said, whatever your skill level, I think Foundations of Game Engine Development is a worthy read.

Math, Physics, Programming, Review

Review: Mathematics & Physics for Programmers by Danny Kodicek and John P. Flynt

MathAndPhysics

This book was quite an interesting read. Though a book of math and physics sounds like it would be boring, I found the text to be pretty engaging. At  688 pages, it’s not the longest technical resource, but the authors manage to pack a good deal in those pages. Of course, there is a lot of math in here, but that’s not all. Even some random topics like mazes and game theory pop up near the end. I really did enjoy the book and it seems worthwhile.

Some of the areas of focus include even basic number representations, arithmetic, algebra and trigonometry, vectors and calculus, to mass and acceleration, collision detection, force and motion, friction and more. Finally, in the last section, the authors cover some tangential topics like tile-based games, mazes, game theory and AI, even search techniques. Really, a good roster.

One of the main reasons I purchased this book, aside from general interest, was to gain some knowledge to apply to a custom physics engine. While that’s still (in my mind) a debatable goal, I do feel like Mathematics & Physics for Programmers has helped, at least with the general concepts.

Unfortunately, I did not try to implement any of the equations or pseudo code from the book, so I won’t comment on the accuracy of the code. It’s possible there were errors that I did not notice. I typically don’t base my implementations directly from books. I use the books to understand the big picture, to get a sense of what’s possible, and to understand the vocabulary and terms that I need to search for. Then I’ll find resources online when it comes to writing the code.

What I will say, though, is that the text is not as good as the other big 3d math books, specifically 3D Math Primer for Graphics and Game Development by Fletcher Dunn or Mathematics for 3D Game Programming and Computer Graphics by Eric Lengyel. For sure, if you are only buying one or two math books for game development, get either of those first. However, if you are like me and you’ve already read the popular books on the topic, this isn’t such a bad choice as a refresher or to round out your knowledge.

Gaming, Graphics, Programming, Review

Review: Game Programming Algorithms and Techniques: A Platform-Agnostic Approach by Sanjay Madhav

GameProAlgo

Game Programming Algorithms and Techniques is one of those books that tries to be as general as possible, and I believe the author was successful in that. Too many books target one specific piece of software or even one particular version of a framework and end up becoming dated rather quick. However, the core ideas in game development have not fundamentally changed in a while. Sure graphics get better, and there are more complexities to working with modern hardware, but the programming algorithms themselves are still very much the same.

Sanjay Madhav starts the book with an overview of some classic games, how a game loop works, handling timing in games, and the idea of game objects. Next he discusses 2D games, sprites, scrolling, and tile maps. There is a quick chapter on linear algebra. Then the author continues with a treatment of 3D graphics, including  coordinate spaces, lighting and shading, visibility and transformation. Handling input is covered as is sound. There is a chapter on physics, which I much appreciated, and then some quick coverage of cameras, artificial intelligence, user interface, scripting, and networking. Finally, the book closes with two example projects.

The author does a great job of explaining complex concepts in easy to understand language, especially in the math and physics chapters, which could be confusing otherwise. One of the pieces that I gained a lot from was the explanation of mouse picking 3D objects, which was described beautifully and made a lot of sense.  The chapter on scripting languages was also helpful and relevant.

Overall I enjoyed the book, and think it would be helpful to beginning programmers, or experienced coders in other fields looking to get into game development. I feel that for intermediate to advanced game programmers, much of this book will be a review. Not to knock the book for that, though, I think it’s a great book if you understand the audience it’s aiming for. I mean, there were even a few bits of information that were new to me, however much of the book was about stuff I’ve seen before.

That said, I do like to read texts of various levels, and even beginner books can help you look at familiar problems in new ways. So I think it’s very much worth reading, especially if you are just starting out in game development.

3D Modeling, Art, Review

Review: Anatomy for 3D Artists: The Essential Guide for CG Professionals by Chris Legaspi

Anatomy for 3D Artists

This book really is “The Essential Guide” for 3D character artists. Though you can probably make a decent model just following reference images and common sense, I think a solid basis of knowledge of the human form really is the foundation for taking your art to the next level of realism. If you are looking for that foundation, or just want to up your skills in the character department, look no further.

The chapter structure in Anatomy for 3D Artists has a variety of different artists tackling a few chapters each, giving the book some different flavor and allowing for these best-in-breed artists to highlight their strengths. It begins with 2D study, and has several chapters each detailing both male and female figures. This beginning part is very much foundational, and shows the basic proportions of the body as well as the basics of bone and muscle structure. This follows up with similar treatments of bone and muscles in a 3D context. Finally, they finish the book with some full sculpts of both male and female bodies in dynamic poses.

It really goes deep into the names and relationships between the bones and muscles, moreso than I was even expecting. And to put this into context, I went to art school for college and I don’t even recall ever going this deep. For example, the text is peppered with lines like: “The bone of the femur rotates inward around its longitudinal axis. The tensor fasciae latae, the gluteus medius, and parts of the gluteus minimus allow this movement.” I won’t lie, some of this descriptions are thick and I doubt I will remember the specifics. Though it is still helpful to understand, and you could always refer back to the text in cases of confusion. And, despite some of the heavily worded descriptions, the text remains very approachable.

Anatomy for 3D Artists is a great place to look, not only for guidance but also inspiration. They spared no expense at having literally every page packed with multiple full color illustrations of each step along the way. Especially for a book of this nature, pictures are key to understanding the material, and the presentation is beautiful. There’s also a few sections in the middle and end just to showcase finished artwork, which is appreciated.

One other great aspect, is that the instruction is not tied to any particular 3D modeling package. Though it’s clear most of the authors are using ZBrush, they stray from going into the specific technical aspects of the application. Pretty much all the instruction is general and could be applied to whatever software you or your studio prefers.

All in all, I consider this book to be a huge success and should be a key element of any character artist’s bag of tricks. Although there are other anatomy books going back years, this is one of the first specifically for 3D artists. I found it helpful and I think you will too.

C++, Gaming, Review

Review: Programming Game AI By Example by Mat Buckland

ProgrammingAI

Programming Game AI By Example by Mat Buckland is one of those books that comes highly recommended and was one I had been meaning to read for a long time. In fact, I originally purchased the paperback in 2006 and never got around to reading it. The interesting part is that the book is still very much relevant today and is not dated in the least. Well now maybe some of the engines and middleware have this stuff built in, but the fundamentals I think I still important to understand.

The book starts with a quick primer on math and physics. The basics are explained, like Cartesian coordinates, trigonometry, vectors, coordinate spaces, and some physics. Like most people reading a book of this level, the beginning was a light refresher. However, I’m a big stickler for reading books from cover to cover with no skipping around, so I did not mind a short recap. Next Buckland gets into state-driven design and demonstrates a simple command-line app using the concepts. I found this approach successful, and it was able to show the concepts without complex 2D or 3D math getting in the way.

He followed up with autonomous moving agents, mostly based on steering behaviors. I was already somewhat familiar with steering behaviors, but I found the author’s description and code to be clear and concise and explained the concept better than I’ve seen before. He then applies the previous topics to a simple soccer game. This was a great next step, and really compiled the knowledge being taught into something concrete. In the next chapter, the author went into graphs; what they are, how to use them, and some popular algorithms link Dijkstra and A*. I always wanted to know what A* was, and this book explains it fairly well.

Buckland then devotes a section to cover scripting languages and why they are useful. In this case, he chose Lua (not a bad choice) and explains some basics about the language, how to interface it with C++, and creates a simple finite state machine. This chapter is helpful even if you’re not coding AI and just need a scripting language for your game or engine (provided you like Lua). In fact, a lot of the concepts in this book are generic enough that they can be applied to multiple fields of interest for game developers.

Next, the author creates a simple overhead game framework used in the subsequent examples. Using this framework he then shows practical path planning, goal driven agent behavior, and finishes up with fuzzy logic. Fuzzy logic is another one of those buzzwords that always intrigued me but I never really understood. Buckland concludes with a quite excellent explanation of the concept.

Overall I found this book to be stellar on all accounts. I feel that any game developer could gain insight from this text, even if they aren’t primarily working with AI programming. The scripting coverage could be used in many games, and the algorithms covered are generic enough to apply to different disciplines. While this is the first book I’ve read on AI, I really can’t imagine a better introduction. Highly recommended.

Gaming, Review, Unity

Review: Getting Started with Unity 5 by Dr. Edward Lavieri

GettingStartedUnity5

Getting Started with Unity 5 is mostly what it bills itself as: a way to get started in Unity for beginners. The book is clearly targeting beginners, and takes the reader from having never used Unity to making a simple farming-type game. I enjoyed reading it (in the whole 3 days it took to finish), however I’m not sure exactly how much I learned (if anything at all).

At 195 pages, the book is not extremely thorough, but does cover a lot of the basic fundamentals of game development with Unity. Unfortunately, that coverage is brief and only really scratches the surface. Some of the topics featured include: downloading Unity (an easy one), the editor views like scene/game/project/etc., game design, importing assets, animation, C# scripting, UI, and sound. Looking at that list, it seems like a lot of stuff, but some chapters are barely even 20 pages long. Not that it’s bad as an introduction, it could be a good place to start, but I feel for experienced developers the book falls short.

Besides the brevity of the coverage, I found some of the instructions confusing. For example, on the topic of programming, the author explains how to code different animals in a farm to do similar things like eat or have babies. This would seem like a classic text-book example for using object-oriented programming principles. Instead, the author concocts some cryptic array of numbers, where a 0 means a pig and a 1 a chicken or something or another. Not to say that this won’t work, sure, it will compile. It’s just not a great way to teach programming concepts to a beginner.

I don’t especially like giving bad reviews, and I don’t want to say the book is bad. It’s titled as a “getting started” book and that’s just what it is. I’m just not sure it’s the best instruction for a beginner, and the programming sections in particular were lacking for me. There are not many Unity 5 specific books available today but, truthfully, much of what’s covered in this book would have worked the same in Unity 4. Even so, the older Unity books I’ve read were much more comprehensive and useful than this one. So if you’ve just started to learn now, this book may be worth picking up as a quick intro if you understand it’s not very deep at all. Experienced Unity developers should keep moving.