Technical Review: XNA 4.0 Game Development by Example – Visual Basic Edition.

January 1st, 2012

Just finished up a detailed technical edit of the new Visual Basic version of a book I reviewed previously. The new Visual Basic version with my edits included is now available from Packt Publishing. Check it out!

XNA 4.0 Game Development by Example: Beginner’s Guide – Visual Basic Edition

Also available from Amazon

Git, push all local branches to origin

October 26th, 2011

At work when we do bug fixes we always create a numbered branch matching our ticket number off of our current production code:

git checkout -b [ticket number here] production

This makes for incredibly simple merging and passing bug fixes around. I come across the issue a lot where I will have about 5 bug fix branches created locally and cannot remember which ones I have pushed to my origin (github) and which I haven’t. There is a command to view unpushed commited branches:

git log --branches --not --remotes --simplify-by-decoration --decorate --oneline

This ugly thing pretty much just parses the log for commits not in your remotes and dumps the result with one branch per line. What it doesn’t do is push these branches for me. Instead of trying to remember that all the time I decided today to just chain a few linux commands I do remember to make it a bit easier for myself:

git branch | grep [0-9] | xargs git push origin

This much shorter command just takes all of my number named branches and tries to push them. If they are already up to date, no biggie, git just returns a nice message telling me so. Branches that need updating on my origin get updated.

This little command only works when my HEAD is not currently on one of my numbered branches, otherwise the little “*” causes way more things than I want to push to my origin. There are, I’m sure, many ways to make this command better, but this simple form with its few prerequisites (not being on one of the branches being pushed) works out great for me.

Anyone else have some tricks for keeping your origin up to date?

Ireland Trip 2011

September 26th, 2011

2011 October 7 – 2011 October 17

I will try to get photos on the map as well as we are travelling. If I’m having too much fun to add photos you’ll just have to wait until we get back to see them!

View Ireland 2011 in a larger map

Pictures

Bozeman to SLC

Dublin

Dublin to Kinsale

Kinsale and Cork

Ring of Kerry

Dingle

Dingle to Ennis

Ennis (Cliffs of Moher)

More Tessellated Terrain

August 25th, 2011

Just a quick note about some small changes I made to the terrain object in Haze. Originally its initialization code just created a single quad made of two triangles with an index buffer in the form {0, 1, 2, 2, 3, 0}. Since then I have updated the constructor to take in an initial size value (int) that sets the number of quads (width and height) in the x and z direction to create. The initialize method now just generates the starting geometry in a loop and sends quad indexes in instead of triangles {0, 1, 2, 3}

The major effect this has on things is that now there can be a single vertex for every single texel passed in as a height map. Since the max tessellation level is 64, we only have to make an 8×8 initial grid to get a full 512×512 tessellated terrain. This opens up other doors as well for things like levels of detail using different tessellation in different quads based on camera distance or view angle. Next up is to get some texture mapping going and see how much I can make things look like real terrain.

I might start with standard splatting techniques, but I’d really like to have the video card generate some of the splat “stencils” based on heights on the whole map (snowy parts at the highest points, less snow on steep slopes, etc.) We’ll see what happens.

Tessellated Terrain

August 18th, 2011

As an exercise in learning Hull and Domain shaders with DirectX 11, I decided to whip up a quick (or what I thought would be quick) height mapped terrain demo that only sent a single quad to the video card and handled everything else in the shader. Aside from some minor problems remembering to use SampleLevel instead of Sample in the Domain Shader everything came together fairly well.

At the moment I have a 512 x 512 height map texture (a simple black and white Filter > Render > Clouds in Photoshop) and a single quad that gets tessellated up to level 64 with the heights added in the Domain Shader. I am currently tessellating at the triangle level and would like to switch to quad as well just to see how it looks both ways. I’ll stick a video of the whole on here once I get the quad tessellation going and throw in a FillMode = Wireframe option to make it easier to see what is going on.

edit: Here’s the video

DirectX 11 and C++

July 17th, 2011

To try and expand my programming horizons a bit, I am working on a version of the HMEngine (codenamed Haze for the moment) using C++ and the latest DirectX version. It has been a while since I have coded anything large in C++ so I’m sure there will be a bit of a curve getting back into it. I am considering posting this version of the engine as a tutorial series alongside the XNA ones depending on how things go and if I feel the concepts are simple enough for beginning game developers. I may also just put it together as a small demo engine for more of a portfolio use. If anyone has thoughts or opinions about this please let me know in the comments.

Tabs vs Spaces

June 16th, 2011

Tabs. Period.

If you think spaces are better, you are stupid. I can’t set a space width on my editor to deal with your stupid 2 space indents. You can use tabs and set your editor to show tabs as 2 spaces though. So why don’t you stop being stupid and just use tabs so we can both read your code. Although if you are writing code that uses spaces for indentation it probably isn’t worth reading anyway.

3D Graphics with XNA Game Studio 4.0 – Review

February 14th, 2011

I recently got a copy of the  new 3D Graphics with XNA Game Studio 4.0, which (complexity wise at least) is a good follow up book for the previous XNA GDBE I just finished going through. This new book skips entirely over the 2D aspects of XNA game development and dives straight in to getting some pretty 3D graphics on the screen. My personal preference (as I noted in my review of XNA GDBE) is towards the 3D side of graphics and game development, so I felt a lot more at home in the code and content of this book.

Sean James doesn’t fool around with a lot of fluff and fillers in the book, which I see as both an asset and a liability. It is an asset for anyone who is highly familiar with the topics in the book but hasn’t personally implemented many of them. In this case the book can be used as a great reference for code (which is most of the content of the book after all) and not have to worry about the explanations of the code blocks. This specific use is actually mentioned in the book itself as one of the uses. There are a few comments sprinkled around the C# and the HLSL code to help you along if you need it, but not so much to get in the way of quickly skimming and finding what you are looking for.

I consider this same aspect a liability depending on the person who is actually reading the book. For someone who has not done a lot of HLSL or other shader development, the amount of HLSL code with very little explanation can seem daunting, but could of course also be a great challenge for anyone who really likes to learn and grow in their abilities and is perfectly fine with having to work for their knowledge (which is much more the kind of learner that I am.) I don’t say this as a criticism of the book or its writing style, as many of the code blocks in my own tutorials are put together in the same way (although I do try to make things as easy to understand as I can). I mostly am mentioning this to let people know that if they aren’t comfortable having to think a little bit about the code they are looking at, they might want to look for their code samples elsewhere.

One of the best things about this book that I have personally had a hard time finding anywhere else is actually the great amount of HLSL code for the various different types of effects presented in the book. Deferred lighting (called prelighting in the book), skinned animations, diffuse and specular lighting, materials and shadowing are all very advanced and difficult to learn effects in shaders and all of them are presented in this book in one easy to use format. Many of these topics are ones that I have been considering implementing in my own engine for a long time, but haven’t really found any concise examples of how others have implemented similar features in their own games, and haven’t found the time to just dive in and figure the whole thing out from scratch myself.

The one problem I had with the book is the lack of color visuals that I feel the topics in this book really require to get across the level of understanding of what visually is really happening in the code. One place where this becomes incredibly obvious is in one of the images that is explained as having been generated by adding eight colored point lights to a scene with a teapot, where the image itself simply looks like a single spot light shining down from above. Using a colored image to show the color blending of the lights and the point light effect instead of the plain gray spot type output that the image looks like it is showing would greatly enhance the effect that having images at all adds to the content of the chapters. Many of the Game Development Gems books get around this issue by just including large number of high resolution glossy color print pages in the middle of the book that can be turned to whenever any other chapter needs to reference a graphic or visual help to really get their concepts across. I really feel like this is probably the only thing missing from this book.

In the end, 3D Graphics with XNA Game Studio 4.0 is a great intermediate to advanced XNA book and an especially good reference for anyone looking to start learning or to learn more HLSL shading and advanced rendering techniques. As I mentioned before, finding this much good shader code across so many varied topics in one place has been almost impossible for me in the past, and I am incredibly happy that someone has finally put something out there to help other like me be able to find and learn these topics better without scouring the internet for days at a time.

Overall I am incredibly impressed with the content and the code in this book and can’t wait to find a good way to implement similar effects into the HMEngine in hopefully a way that is easy enough for everyone to understand. Hopefully I can just find the time to get some of it done!

Book Link: http://link.packtpub.com/dRrfxI

Sample Chapter: http://www.packtpub.com/sites/default/files/0041-chapter-7-environmental-effects.pdf

XNA 4.0 GDBE – Chapter 4/5 Review

January 22nd, 2011

Continuing on with the quality from previous chapters that I have now come to expect , Kurt dives right in to getting his impressive graphics straight to the screen. He starts in straight away with many of the utility classes needed to put together a standard top down space shooter and gets the basics of the game up and running in no time.

Some small code things I would have done differently:

  1. Many of the properties in the classes could have been automatic { get; set; } which can make the code look much cleaner (personal opinion)
  2. The padding parts of the asteroid collision detection system is unneeded. I actually removed it altogether in the final code and the game worked just as well
  3. The StarField, AsteroidManager, ShotManager, and many other Manager classes are very similar. I would consider seeing if they can be combined into a more generic class or set of classes.
  4. GraphicsDevice.ScissorRectangle could be used in many places instead of a hand built rectangle with the client bounds’ width and height
  5. Collision detection for asteroids is discussed and implemented in Chapter 4. All other collisions are in Chapter 5. These should be done together with a single CollisionManager

Some things I especially enjoyed in these chapters was the inclusion of sound and special effects. Both the particle explosions and the shooting and fire sounds are highly reminiscent of a simpler time in video games when kids still lived and died by their quarters. The final game is once again incredibly impressive for a beginner’s XNA book and I would have been ecstatic back in 2002 when I first started playing with Managed DirectX if I could have shown my friends the kinds of games that have come out of this book so far.

Book Link: http://link.packtpub.com/ZWicAE

Moving to git

January 17th, 2011

Just a quick message to say there will be a little downtime in tutorial update and book review posts while I move my source over to git and github.

My reasons are many, but much of the background information and research I have done on the topic is well summed up in Linus Torvalds’ talk at Google.

Do NOT follow this link or you will be banned from the site!