Saturday, May 23, 2009

Trying out some more games

Half Brick Echoes

A very polished title. The basic arcade-style gameplay doesn't really appeal to me, but some things I liked:
  • very well done menu system
  • very artistic (I wish I had an artistic touch like that)
  • it explains things quickly and clearly, and gradually introduces more complex elements

Basically, it gets a lot of things right.

Hexement

Catchy box art and the screenshots looked nice, so I downloaded the trial. Notes:

  • Menus are basic and buggy, and don't conform to norms (e.g. B for back)
  • No instructions on what to do by pressing the default buttons.
  • I'm still not sure what to do
  • Music was nice and soothing... graphics are pretty good.

I get the feeling there is some interesting gameplay here, but there isn't much explanation of what's going on (perhaps part of the enjoyment is figuring it out? but that doesn't leave much upsell potential). There are a number of basic "gameplay rules" that are broken here.

A Fading Memory

Beautiful introduction. Nice music, very evocative art style. I like games that are art.

Gameplay: it is too easy to die and then I restart at the beginning of the level. I think the controls are a little weird, and don't behave like other platformers (when you center the stick you immediately stop moving if you're jumping... feels a little weird).

This may be a good game if you like twitchy precise platformers. But it kind of feels like Braid, and Braid is anything but a twitchy "must jump precisely the exact amount" platformer. The demanding precision here doesn't seem to mesh with the dark emotional feel of the game.

If it wasn't so difficult (I am impatient and grow frustrated when I keep dying and get no rewards), then I would probably buy this game. I'm curious how long it is, and what comes next.

A Wizard's Odyssey

Great music. Best I've heard in a community game.

The visuals are an interesting mix of beautiful and bland. The toon shaders are nice. The environment seems a little spartan a low poly. Looks like there is some ambient occlusion going on here? Looks fancy in some areas, but not in others. I thought there were no shadows at first, but I do seem them where light floods in from stained glass window. But only there (which is like 1% of the level).

This game seems interesting, but I don't know what I get by buying the full version (other than being able to play for more than 8 minutes). How long is the game... how many levels?

Again, the art doesn't seem to have a common theme, which is a bit unsettling.

Mithra - episode 1, chapter 1

This is a full-blown professional-looking game. Definitely the most graphically advanced game I've seen on XBLCG.

They aren't getting 60FPS, that's for sure. And there is a short (garbage collection?) pause every few seconds.

Though it was beautiful, it didn't seem too exciting to me.

Thursday, May 21, 2009

Seablast

Every one in a while I'm going to try to look at some of community games and see what I like and don't like. I saw positive reviews on Seablast, so I downloaded the trial.

http://marketplace.xbox.com/en-US/games/media/66acd000-77fe-1000-9115-d80258550141/

At first glance, it is frighteningly like Tank Negotiator!

For example:
  • Tank-in-a-maze: check (except it is subs in the sea, but same deal)
  • Menu system that is slightly 3d: check
  • Vortex: check (I freaked out when I saw this - it's my prize weapon!)
  • Nice particles: check (but - they are not "soft")

Over all the game is quite polished. These are some of the things I liked:

  • You can practise with the controls
  • Campaign that gets you into it smoothly
  • Quick to load
  • Visuals are polished

The things I don't like:

  • Low constrast selection on some of the menus
  • Things are a little too small (the subs/players, the text). I have this problem too, when I zoom out from the board (with lots of players)
  • No tips during gameplay (I kept forgetting the controls)

I was a little shocked that it seemed, in some ways, a lot like TN.

Some other thoughts:

  • There is a flow mechanic in some of the levels (water flowing, which pushes you). I was thinking of having a weapon/powerup like this too!
  • The terrain doesn't seem to be involved much in gameplay. This is the case with TN too. I wish I could think of ways to integrate it more (like you can with a shooter where you take cover, for instance)
  • Has the same unit movement as TN, which some people don't like (you aim straight ahead at all times)
  • 8 level shapes... about the same as TN.
  • Music is a bit cheesy.
  • Apparently no network multiplayer

There seem to be a lot less weapons/skills than in TN, and no upgrade path. The campaign seemed a little boring - I'm worried this will be the case with TN too. It's really meant as a multiplayer game.

There are several people on the credits (3 or 4). I'm just me!

Wednesday, May 20, 2009

Nav meshes


I'm finally getting back to what I need to do: AI.


A necessity of any AI is good pathfinding. I had a basic point-based pathfinding system working long ago, but didn't have proper steering algorithms (as proper as they could be for a point-based system). Overall it was not very convincing, despite it (usually) getting from point A to point B.


More recently, I investigated navigation meshes and decided I would like to try implementing them. The basic A* algorithm I have will still work here (they are just another graph after all), but I need to actually create these meshes somehow.


In the interest of saving time (and allowing for the possibility of users creating their own mazes), I investigated automatic generation of the meshes. I basically start with a rectangle, and subtract additional polygons from it (each polygon representing a wall I add). I used an algorithm for subtracting one polygon from another (not really trivial) and another for generating the "minimum decomposition" of an arbtrary polygon into a series of convex polygons (convex polygons are a necessity for navigation meshes). Some pretty heavy and boring math here, and I could never get it all to work.


What stopped me were floating point inaccuracies. When two convex polygons are adjacent and floating point precision comes into play, one of the polygons may no longer be technically convex. The algorithms I was using did not like that. After a week of trying to get things working, I (temporarily) gave up, decided it was not worth it.


I'm now back to creating nav meshes manually. As an aid, I auto-generate points based on the wall positions that will be useful for creating the polygons.


At the top of this post is an example of a completed nav mesh using the in game maze editor.
One benefit to creating them manually is that I get control over how they are positioned. I may want the individual polygons to be evenly distributed in terms of size/position if I end up using polygon-level conditions (e.g. an enemy is in this polygon, so increase the cost of moving through this polygon).


HDR

HDR rendering means you do all your pixel/lighting calculations in a higher precision than that which is used for display, in a more "open-ended" color space. For example, you might use a 16bit per channel floating point surface. Normally, the output for each color channel is clipped to (0, 1). So if your lighting calculations meant that a pixel was brighter than full brightness, that information was lost. A floating point surface will allow for values greater than 1 (just using an 8 bit per channel FP surface won't technically give you any greater precision than your standard RGB, but makes calculations easier since you can just let values go above 1).

Unfortunately, none of the floating point surface formats on the Xbox support alpha blending. So that was pretty much a deal-breaker.

I could use a regular 32 bit ARGB render target, and just divide all my output pixel values by some factor. And then draw that render target to the back buffer and multiply by that factor again. But then I am losing precision. I played around with this before, and it wasn't too bad - but I dropped it because I perceived it to be a problem.

D3D supports a R10G10B10A2 format... 10 bits per color, and 2 alpha channel. This would suit my purposes, but the 2 bit alpha channel always worried me. Although, conceptually I didn't understand why the alpha channel of the render target mattered at all. So I coded this up again and was pleased to see it work fine.

On the PC.

On the Xbox, all my translucent objects were reduced to 4 levels of alpha. Why? They are only being drawn on top of the 2-bit alpha render target. Some searching on the XNA forum again showed that the Xbox converts the output of the pixel shader to the format of the render target before applying it to the render target. Foiled again!

Further research showed that this was only a problem for "translucent" alpha blending: where the final result included the original destination pixel in its calculation. Most of my non-particle alpha objects were like this (e.g. the shield, the planet atmosphere, the spotlight cones). Most of the particles used additive alpha blending. This wasn't an issue for additive alpha blending.

I found that I could mostly emulate the effect I want solely using additive alpha blending. A few things look a little worse, but I hope the gain I get from "true" HDR will be worth it.

What does it give me? Well, I don't need the contrast range necessary for realistically rendering indoor/outdoor scenes, and adjusting "exposure" (since the game takes place in space). What I do get is bloom: washing out the brightest parts of the scene with a glow.

The effect is often over-used in games, but I think it will help make things look more "professional".

Recent changes

These are some of the recent changes and visual polish I've been working on (since submitting to PAX10).
  • Soft particles
  • HDR

I finally got around to implementing soft particles. This is visual polish that avoids the ugly seams that appear where particle billboards intersect the scene geometry. There were a number of challenges for me here. I had tried this before and given up after some roadblocks I didn't have the skills to solve at the time.

The main problem was the construction of the depth buffer. If you don't get this exactly right, things won't work, and I only now am comfortable enough with PIX to enable me to debug some of the tricker problems. One problem I see many making (in looking at online tutorials) is using a depth calculation that involves passing (position.z / position.w) from the vertex shader to the pixel shader. Because you are dividing by w, this value will not be interpolated properly from vertex to vertex. This will only show up if you have triangles of varying size (as I do, for example, on my floor - which is one big quad - and the walls, which are much smaller): the depth value for touching geometry will not be continuous where they touch. The shadow mapping sample on the official XNA site is guilty of this, but of course it doesn't show up as a problem with the scene objects they use. The solution is not to divide by w. Leave it as z, or divide by a constant if you want to keep the output value between 0 and 1 for more floating point accuracy.

Another problem I encountered on the Xbox 360 only, was that of discontinuities in the depth buffer (I was using a 32 bit floating point buffer). Strange gaps in the depth values that were interpolated (presumably). With some tests, I found they were occuring at "even" numbers, such as when the value was 0.5, or .0625. I was finally able to repro the problem just drawing a simple gradient to the buffer. It turns out the problem was using something other than point sampling when reading the depth buffer. Anything but that (on the Xbox) will cause issues with floating point surfaces.

Very exciting.

With those problems solved, I figured I would first try just drawing a quad to the screen using the "soft particle" technique. The vortex is the obvious choice, because it looked terrible where it intersected with the tanks (the vortex *is* a particle system, but at the point it is drawn to the screen, it has already been rendered to a texture, so it is no longer). This worked well, and so I followed that with changing the particle system too. Things were working great!

... until I tried running it on the Xbox. No dice. Eventually I observed that things worked fine on the top half of the screen, but not in the bottom half. Uh-oh. predicated tiling.

Eventually I realized it was the convenient VPOS semantic I was using. This gives you screen position in the pixel shader, which I use to look up the correct spot in the depth texture. VPOS apparently "resets" for each tile. And the XNA framework handles the tiling for you, so there is no way to know which tile you're rendering from within the pixel shader. No problem, I can calculate the screen position in the vertex shader, and give it to the pixel shader in a TEXCOORD.

Except - I'm using point sprites for the particle systems. That workaround is fine for a quad (the vortex), but won't work for my point sprites (since they are a point, and there is nothing to interpolate). I certainly didn't want to re-write the complex particle system to use quads.

Eventually I realized I could figure out my screen position using: 1) the screen position of the center of the sprite. 2) the current texture coordinate, and 3) the pixel side of the sprite. And so that's what I did, and so far it seems to work. Since TEXCOORDs don't work for point sprites, I need to use a COLOR semantic to store all these values to pass to the pixel shader. COLOR semantics apparently only have 8bit precision on many PC graphics cards (which is insufficient for my uses here), but luckily on the Xbox they have greater precision (likely 32 bits).

One additional hurdle was that I was hoping to use MRT (multiple render targets) to help render the depth texture, so I didn't need to render the scene geometry twice. This worked fine on the PC, but again - not on the Xbox. I need to switch out the depth render target (at index 1) so I can read from it, while still keeping the main render target (index 0) to continue rendering to. However, the contents of the main render target are lost when any other render target is removed. It has to do with the nature of the Xbox's 10MB of EDRAM, and predicated tiling. It is obvious why this has to happen if you think about it.

So in the end I had to go with a separate rendering pass. I'm still getting 60FPS at 1080p, so so far so good.

This post is too long already, so I will discuss HDR in another post.

Tuesday, May 19, 2009

Gameplay video

Here is a gameplay video for the "beta" version I submitted to PAX10. Unfortunately it is low quality, despite my following the instructions for "upload HD videos, up to 1GB!". The youtube uploader tool apparently recompressed the video on my machine before uploading, since it took only a few minutes to upload a "600MB" video, and I ended up with this result: