Semester wrap up

2 cold spells, 1 imagine cup and 1 demo day later, this semester is over, the Christmas break has arrived and a quick wrap up is in order.

Cosmopolis was selected as a finalist for the US Imagine Cup which will be held in Washington DC sometime late April. We’ll get shipped up there for a weekend of who-knows-what. With some luck and a lot of hard work, we’ll hopefully break into the international finals in Poland later that year.

Demo Day* was a huge success an enormous failure at the same time. Huge failure because I somehow managed to book my flight back to Iceland in the morning meaning that I’d miss the entire Demo Day, something I did not realize until 2 days before. I need a personal assistant to book my flights in the future. The Cosmopolis demo however was a huge success from what I’ve heard, the best one there by most people’s accounts. Just wish I had been there.

*Demo Day  is a dedicated day at the end of the semester where people from the game industry come to USC and watch students present the best projects of the semester for almost an entire day.

With that in mind, here is what matters, the videos presented at Demo Day. Keep in mind that these are probably unnecessarily  long, intended for someone to be talking while they are playing. Maybe we’ll put up annotations sometime. The videos are in HD, so fullscreen + HD is recommended.

What I specifically worked on in this is pretty much the programming of everything you see (and don’t see, ie core engine stuff) except the animation system. I wrote all the shaders and pretty much everything graphics related (vegetation, terrain, water, time of day, shadows, particle system, etc), as well as a big part of the gameplay (including network) for both (sub)games.


Cosmopolis: United Nations Millennium Challenge.

This game (or subgame actually) was our Imagine Cup submission, although the graphics have been improved a little bit since our original submission. The premise here is that you play as a United Nations officer trying to build up a war torn nation. The specific gameplay that we implemented was de-mining. You have a mine detector and a map at your disposal and take a part of a collaberative and persistent de-mining efftort, where individual score is kept track of. The mine detector is sound based and and once you have locked down the position of the mine you throw rocks at it to blow it up.


Cosmopolis: WarPipe.

This subgame is compltely different from UNMC and is meant to be used for research purposes in the near future. Right now the gameplay is pretty much just a free for all killfest involving an assault rifle and 3 types of grenades (smoke, flashbang and frag). Teamplay is the #1 thing to add in the next semester.


Cosmopolis: World Tools

This is just a demo of the tools we used to create the Cosmopolis world.

Chris Metzen

Today’s Game Design class had a guest speaker, Chris Metzen. I had heard the name before but wasn’t really sure on any details, so I did some research. His wikipedia article is pretty conservative, basically stating that he is a long time Blizzard employee, so I wasn’t sure what, or who, to expect.

I soon found out however, that I was standing (or sitting rather) face to face with the father of the Warcraft universe and the reason that Warcraft 2 (and presumably installment #3 and WoW too) was made. And he’s pretty damn cool too. He spoke (in a very entertaining ranting manner) about how Blizzard just barely managed to avoid bankruptcy and rise to be (in my opinion) the top game studio in the world today. He also described the “every voice counts” creative process at Blizzard. What stood out though was that no matter what he said, incredible passion and devotion shone through his words.

Not going to write up any details, aside from one. He really, really.. really really really likes Modern Warfare 2. I haven’t played through the campaign yet as I tend to get bored of single player stuff (although Spec Ops mode has been keeping me entertained) but just listening to him describing it gave me goosebumps. He literally said that MW2 has changed his vision and has forced him to rethink everything.

On that note… I’m off to a session of Modern Warfare 2.

Ps. He also said that my middle name (Thor) is epic. So that’s my name from now on.

Pps. Note to Chris, if you ever happen to google your name or something: Thanks for taking the time for this great lecture / QA session!

ImagineCup deadline is in 13 hours!

Random screenshots are always fun!

Another view of starting town.

Another overview of starting town.

Time of day system.

Much improved vegetation. More dense and blends into the ground smoothly.

Accurate shadows from alpha mapped polygons.

The Quest for Shadows

Cosmopolis has a very large dynamic world. Players can modify terrain and building placement at runtime, in addition to day/night cycles. This brings up a plethora of issues in regards to shading and shadowing. Most video games use precomputed global illumination lightmaps to make the lighting look great at the cost of a single texture lookup. Unfortunately for us (well, fortunately for me as I enjoy attempting to solve this problem immensely) we must make things look pretty at runtime.

Starting with shadows, there are a number of issues that I have run into and I just wanted to prevent people from doing the same mistakes, so here are a few tips:

  • All shadow tech demos/examples generally have a tiny scene to show off their shadowing technique.
    • Don’t be fooled into thinking that it could scale to fit your 8km view distance scene (or even 150m view distance).
  • Most shadow tech demos/examples have a static/hardcoded positional light.
    • If you have a sunlight (directional with infinite position) you run into a new set of problems.
      • The light view matrix must be placed somewhere… How do you determine this point? CameraPosition + (-LightDirection * 10000) seems like a good idea, but if you do that you have no resolution in your depth map. CameraPosition + (-LightDirection * 100) seems like the obvious answer to that, but that creates a parallax effect as the camera moves.
  • Screen Space Shadow Maps are an interesting idea, but blurring them is a terrible idea.
    • Viewed up close the “pixels” of your shadow map are way too big on your screen to be blurred together
    • Viewed far away the shadows will bleed into nearby objects that are not supposed to have shadow at all

With that in mind, I have mixed together PSSM (Parallel Split Shadow Maps) and SSSM (Screen Space Shadow Maps) with acceptable results (for now). PSSM is used to position 3 “light cameras” based on the position and rotation of the player camera, each at a different distance. The first covering the immediate surroundings and last covering about 250m view distance. To avoid the hard shadow edges I render a screen space shadow maps using PCF (Percentage Close Filtering) and then use the results of that map as an input to the objects that can receive shadows.

I render a depth map every other frame as opposed to rendering every depth map (remember there are 3) every frame. They are scaled to cover more than exactly the player’s view frustum to afford some leniency. I do however have to create the SSSM every frame, with a pretty expensive pixel shader, which is probably what I’ll try to tweak in the future.

Here are the results:

Cosmopolis 2009-10-23 14-48-16-86

And here you can see the 3 depth maps rendered on the screen (top) and the SSSM results in the middle-left:

Cosmopolis 2009-10-23 14-49-16-62

Point sprite scaling in XNA

Today, to my horror, I realized after creating a point-sprite based particle system for Cosmopolis that XNA does not seem to support point-sprite scaling. Meaning that if you set your point sprite to be of size 100, it will occupy 100 pixels on your screen whether you are viewing it up close, or miles away. After a decent session of googling I found a solution which involves setting renderstates that the XNA does not allow you to set in code. You instead need to set them in the HLSL shader pass definition (which I normally do not like to do for various reasons). This will suffice (and set up a “correct” scale according to the previously linked article):

1
2
3
4
5
6
7
8
9
10
11
12
pass Pass0
{
      VertexShader = compile vs_1_1 VS_Particles();
      PixelShader = compile ps_1_1 PS_Particles();
 
      POINTSCALEENABLE= TRUE;
      POINTSCALE_A = 0.0f;
      POINTSCALE_B = 0.0f;
      POINTSCALE_C = 1.0f;
      POINTSIZE_MIN = 0.0f;
      POINTSIZE_MAX = 9999.0f;
}

Just be aware that you can not set these renderstates back through XNA, although it shouldn’t affect anything else.