Archive for the 'Uncategorized' Category

Is this thing on?

Wednesday, July 30th, 2008

I’m not dead! Really! I’ve just been very busy during the last few months. Turns out that once you decide to get married, your life is taken over by wedding planning until you’re married (well, at least if you decide to have a really short engagement). Oh, and yah, I’m getting married!

So, in an attempt to keep my life somewhat normal while everything runs around crazy, I’m going to try getting this blog back in order. If you’re still out there watching, you deserve at least something for your patience, eh? I’m probably going to start it off with some simple tutorials on the engine I work on, FlatRedBall. The engine has really grown out of the “2.5D” that it started in and into a decent 3D engine - with some of my help of course ;)

Aside from that, I might as well share some awesome stuff I’ve seen/played lately:

GemCraft: a tower defense game with a twist - your “towers” hold gems, which actually do the attacking. They can be upgraded and moved around, and as you level up later on you can use your new skills to go play old levels (without being bored to tears). You can also respec your skill point distribution at any time for free - which is really nice. I recommend it as a study of how to create a game where your character can get stronger without previous areas being any less boring to play (and without “leveling up” previous areas to match your new character).

Team Fortress 2: I know, I caught the boat late. If you haven’t played this yet, go get it off Steam! If you have, and you’re reading my site, you must be some sort of developer, in which case you should read about the rendering methods used in TF2 here and here.

Final Fantasy Tactics A2: Final Fantasy Tactics really drew me in back in the Playstation days, and I’ve played it quite a few times since. I also played all the way through FFTA (the first Final Fantasy I actually finished). So getting this was a no-brainer. Now that I have it, I really appreciate all the variety they’ve added to the game. I also really appreciate how the game is broken into “quests” which each take about 10 to 30 minutes to complete. With the amount of running around I’ve been doing lately, it’s really nice to be able to pull out a game that I can play for 15 minutes or so when I have to wait for something.

Rock Band: I always hated rhythm/music games - there was only ever one song on DDR I was good at, and it was in a very specific arcade version that was in a city I didn’t live in. Other than that, I was horrible. My first experience with Guitar Hero wasn’t that great either - they started me on Medium and I did horrible. However, my fiancée started talking about liking it (she played it with some of her friends), and always on the lookout for new games to play with her, I picked up both Guitar Hero 3 and Rock Band. That was it - we played all the way through Guitar Hero 3, and I still have groups of people over all the time to play Rock Band. It’s a lot of fun to play with friends - and it’s a game that a group of people can really enjoy playing (without having to really be any good at games). Just don’t make people feel bad if they start on easy - it’s not the hardest of hardcore games after all.

So that’s a pretty good list of games that’ve been holding my attention lately. There’s a few others, and I’m always on the lookout for good co-op games I can play with my fiancée (know of any?). Of course there’s also Shizoid - I tried the demo with my best man, then we played it all afternoon. I’ve also played it quite a bit with my fiancée - the one-stick controls are really easy for anyone to pick up. Unfortunately, the difficulty really ramps up around the checkerboard stages.

Oh, and look at my wrist, I’ve gotta go.

Edit: One final note: I’m going to try upgrading to the newest version of Wordpress soon - I’ve used it on another site and it’s much nicer. So a little downtime in the next day or so is to be expected.

Edit(again): Alright, that was relatively painless - only lost the categories for a while. I’ve updated to the newest version of Wordpress. Let me know if anything is broken.

Particle Life Source

Tuesday, May 13th, 2008

Much later than anticipated, here is the source code for my screen saver, Particle Life - and a short discussion of some techniques used to make the screen saver. I used GPU processing, pre-rendered depth blurring, and some fun camera tricks.

Particle Life Source Code

GPU Processing

You’ll see this in PositionsEffect.fx. Basically, I pre-generate a velocities texture with random noise, and pre-generate a positions texture with incremental depths for particles (to ensure a good distribution of particles) and random x/y values (with the camera’s frustum). Then every frame I sample both position and velocity, add the two together (multiplying the velocity by the elapsed time) and write the new values to the positions texture.

Now, here’s where I could use vertex texture fetching, but I wanted something that’d work on shader model 2.0 (and my laptop), so I did something simpler. The position texture is stored as a HalfVector4. Every frame, I dump this straight into an array and then push it into a vertex buffer of HalfVector4 vertices. Since I’m using point sprites, that’s all I need to do. It’s not the most efficient piece of code (the dump sure isn’t nice), but it works.

Pre-rendered Depth Blurring

I wanted particles to look blurry as they became more distant. However, with alpha-blended particles, I can’t quite do this in a post-processing step. I’d have to basically blur the texture whenever I rendered particles by taking several sample taps on the texture for each pixel. The fill rate would become horrible.

Life Particles

So, I took the easier route. Instead of doing all that work on the GPU just to get particles to blur, I just built the mipmaps in the texture by hand. If you open up part.dds, you’ll notice that each successive mipmap is not only smaller, but blurrier. Since the mipmaps are automatically blended when I sample the texture, that does the blurring for me for free.

Camera Work

One of the important things to take from this sample is that sometimes there’s ways you can “cheat” without being caught by the end-user, and save a lot of processing power in the meantime. One more example of this is how the particles are “culled”. Nothing exists outside of the camera’s viewing frustum. There’s no reason for it to - it’s not visible to the user, and it’d just waste processing power if we dealt with it. So when a particle leaves the camera’s frustum, it’s wrapped around to the other side.

So how do I know if the particle has left the view? Well, I could do a bunch of nasty math involving rotation, tilt, field of view, etc. Or I can just align the camera straight down the Z axis. Then I know that there is a linear relationship between the particle’s Z position and the width and height of the camera plane at that Z. This is the tangent of the field of view. So I just set that as a variable in the shader (or variables in this case: FieldWidthFactor and FieldHeightFactor in PositionsEffect.fx). Now I don’t even have to do any transformations of the particle positions.

One final note

GTA IV Depth of Field

You might recognize this, it’s from Grand Theft Auto IV (image from gtanet.com). If you’ve played the game, you’ll probably have noticed how short the full-detail draw-distance is. After a couple blocks, cars turn into headlight circles (a simple circle to show headlights) and everything becomes really blurry. My theory is that, to help with memory streaming and file sizes, a lot of the intermediate mip-maps in textures have been cut out. That way the full-detail texture maps only have to be loaded when you’re close to an object, but it can still have some definition if it’s in the background. However, due to either space or processing constraints, they couldn’t show too far away, so a post-processing effect adds some grainy blur for distant objects, helping to hide the low-resolution textures.

That’s in no way the official word on things, just my guess - but it’d be a good example of how you sometimes can make clever use of graphics tricks to keep your asset size and processing requirements low while still maintaining good visual quality.

XNA 3.0: MP3/WMA/WAV support!

Wednesday, May 7th, 2008

So, I was a little disappointed about the XNA 3.0 CTP when I read about it. It looked like the only big feature was Zune support (being without a Zune, or any friends who have a Zune, I have quite the lack of interest in developing for it). However, after a little prodding, it looks like with Zune support comes much better media support, including the ability to import and process MP3, WMA and WAV files without going through XACT! They seem to be converted to WMA files, which is fine by me, though the options available for compression are pretty simple still.

I made an example project which shows how to process and load an MP3 song in your program:

Download the Example!

It’s pretty trivially easy, but there’s really no how-to that I could find that explains this. The big thing is the MediaPlayer class, which lets you do a lot of different things with Song classes. Check it out in the documentation for the XNA 3.0 CTP.

And of course, you’ll need the XNA 3.0 Community Technical Preview to compile and run this example.

Now, if they add FriendGamer.CurrentTitle by the next release, I’ll be happy!

Feed Fixed!

Friday, February 29th, 2008

Looks like when I switched some stuff on my server, I nuked the feed! I fixed it, and hopefully you’re all getting this post as well as my last one! (I’m not dead yet!)

Enjoy this screenshot of my in-development screen saver at huge resolution (not giant yet - haven’t got to test it on 1080p yet):

Giant Screenshot

Site Maintenance

Wednesday, January 23rd, 2008

My site will be down for a few days while I update some stuff. So if you’re watching my site - fear not, I’ll be back!

edit: Looks like it didn’t take long to fix up! Let me know if you encounter any broken links!

Depth of Field Tutorial

Saturday, January 5th, 2008

I’ve submitted a new tutorial to Ziggyware about creating a Depth of Field effect. It includes a lot of information about Gaussian Blurring as well. Check it out at Ziggyware. And If you like it, vote for it in the Ziggyware Holiday Contest.

Back, with a threading tutorial!

Wednesday, October 3rd, 2007

Alright, so long story short - I didn’t slip off the earth, just found a new cave to inhabit. About the time of Gamefest my University Advisor contacted me and informed me that there had been some mistakes in my scheduling, and instead of having graduated in May, I still had 5 credits left to complete! Imagine my dismay! So I pulled things together pretty quickly and managed to work it out so I can complete those credits by using XNA more - lucky me!

First of all - I’m now helping out on the FlatRedBall engine. It’s a 2.5D engine - meaning it renders 2D objects in 3D space. It’s got tons of great features - collision detection, particle systems, great debugging tools, a wide range of graphical options, and now, post-processing. Go check it out!

Second, I’m rebuilding Dream Sower. Our first version was wonderful, but needed something extra to take it over the top. I’ve got a lot of feedback on it, and I’m rewriting some of the low-level code to get it ready for reimplementation. I really really really need an artist, so if you have services you could offer (or know someone who can), please let me know! I’m decent with 3D art, but I’d much rather have a game that has more than programmer art!

Third, and last for today (may we meet again soon!) - I’ve written an article on multi-threading using XNA for Ziggyware’s XNA Article Contest. It has some good information on writing a background loader, teaches you about some common pitfalls in multi-threading, and I even threw in a managed thread class I developed for my game. Let me know what you think of it, and if you like it a lot, go vote for it!

That’s all for now!

Finished with College

Tuesday, May 22nd, 2007

I finished my final final exams last week, and I’m now packing up to head back to the United States. After handling the jet lag, I’m thinking I’ll write a new tutorial. What would you like to see? Let me know by posting in the comments - I’ll read them all and then decide next week when I’m finally home.

On Vacation

Monday, April 2nd, 2007

A quick update before my blog dies in your feed readers - I’m on vacation for two weeks from now, so there won’t be any updates for a while. When I get back, I’m going to attempt to write some tutorials, so stay tuned!

Edit: It’s really annoying to have to clean up spam while I’m away - I’ll be working to get some better protection on my comment system when I’m back. To anyone who read through all of the spam: I’m sorry.

Update: I’m back, and hopefully most of the spam will stop. I found a few spam-blocking things (notably Bad Behavior), so the spam should calm down. Let me know if you have any problems posting comments.

Back Online

Monday, March 12th, 2007

Just a quick note to say that I’m back from the weekend and so is my site. Apparently it decided to take a vacation too.

I also wanted to note that my quietness is due to final projects. I’m finishing my Computer Science degree this spring, and final projects are taking over my life. I’m going to try to keep updating with some useful information though, so if there’s anything you’d like to see let me know. Maybe I can pull together a tutorial!

Edit: Okay, it’s working for real this time! *I hope*