Friday, February 12, 2010

Tunescape Update

Tunescape

I've managed to avoid my standard behavior and have been pushing to try to actually finish (!!) Tunescape. It is in pretty good shape right now, and I've currently got it in playtest over on Xbox Live Indie Games.

In polishing the game, I've been doing some fun shader work. I implemented a particle system shader for my new explosion effects, and I created a "plasma" shader for the background that uses multi-resolution noise to generate a smoothly moving cloud pattern.

Tunescape

Friday, December 11, 2009

Lots of Fishes...

Lots of Fishes

Just some stuff I'm messing around with...

Friday, November 6, 2009

Music-based Gameplay

Music-based Gameplay

My latest project is a game that uses music as the gameplay content. I use spectrum information to detect energy pulses in the music and use peaks to trigger emission of particles. The object of the game is pretty simple - collect the particles while avoiding the red boulder-thingies. Grabbing stars increases a score multiplier.

Music-based Gameplay

Collecting the particles, in addition to increasing your score, fuels three kinds of colored energy - shown by the three lines inside your circle. This energy can be expended to use a shield, give you a speed burst, or temporarily suck particles toward you.

There are also cooperative and competitive multiplayer gameplay modes. This is a mode where players are "bungied" together:

Music-based Gameplay

Here is a gameplay video:

Tuesday, October 13, 2009

Steam and 3rd-Party DRM - Risen and Tages Activation

This past Saturday morning, I decide that I'd like to play Risen, the latest game from Piranha Bytes. I check on Steam, and they have it for $49.99. Amazon has it for $46.99. Boo, digital distribution! You aren't going to ship me a box, and you are still going to charge more? Still, I've been pretty happy with Steam in the past, so I was willing to spend the few extra dollars to get it quickly.

So, I make the purchase. A half-hour or so later, my download was complete. Yay, digital distribution! I launch the game, and it brings up an activation check that needs to authenticate to a server online. When I proceed, it pops up an error saying that it can't connect. There is also an "offline" activation mode, which involves entering data on a webpage (not really "offline", but whatever...), but the website can't be reached.

I check the Risen forum on Steam, and a handful of other people are having the same problem.. Turns out that all this is Tages DRM being applied to the game on top of what Steam does. And it looks like their authentication servers are down. Lovely. If you buy a physical copy of the game, it doesn't authenticate online (it uses a disk check). Boo, digital distribution! I fire off a support ticket on Steam (after having to create a support account, which is different from my Steam account).

10 or so hours later, I try again. Still not working. I'm thinking that if you are going to require online authentication, your authentication server bloody well better be up. And if it isn't, someone better be getting paged. And, of course, I had no response from Steam support. They are happy to take my money on a Saturday, but don't seem inclined to provide support on a Saturday.

The next morning, the authentication server is up, and I can play the game (which is pretty good, by the way). Still, the whole incident left me with ill will toward all parties involved. Tages, for their broken DRM. The publisher, Deep Silver, for using it. And Valve, for allowing 3rd-party DRM that is out of their control to be used on a product they sell. And for having crappy customer support.

Speaking of their customer support, I just got a response from them (3 days later) - a useless canned response about running Steam as administrator if I'm using Vista or Windows 7. Thanks, Valve!

Tuesday, September 29, 2009

Fractal Rendering on the GPU - Mandelbrot and Julia Sets in an HLSL Shader

Julia Set Shader

I've been playing with HLSL shaders recently, and it occurred to me that the horsepower of the GPU could probably be harnessed to render fractals like the Mandelbrot Set. It turns out to be a perfect task for a shader, since it involves lots of completely localized calculations - exactly what graphics cards are good at.

A bit of web searching turned up the not surprising fact that I'm not the first person to have this realization. I found some nice code examples here and here. My version takes inspiration from both of these approaches, and adds a few tweaks of my own.

The image above is of the Julia set, rendered completely by the GPU. Below is, of course, the Mandelbrot Set.

Mandelbrot Set Shader

And another view of the Mandelbrot set zoomed in a bit:

Mandelbrot Set Shader

On my GeForce 8800GT, I can zoom and pan around at a rock-solid 60 frames per second. Here is a video exploring the Julia set. The warping you see is me transforming the seed used to render the set.



Here is the shader code I ended up with. It is pretty simple. I'm using the Normalized Iteration Count Algorithm to get nicely smoothed coloring. The parameters are set to sensible default values, but you will want to pass them in from your application and map them to some sort of input device. For rendering, simply draw a full screen quad using the shader. In my application I also gild the lily a bit and apply a bloom effect.

int Iterations = 128;
float2 Pan = float2(0.5, 0);
float Zoom = 3;
float Aspect = 1;
float2 JuliaSeed = float2(0.39, -0.2);
float3 ColorScale = float3(4, 5, 6);

float ComputeValue(float2 v, float2 offset)
{
float vxsquare = 0;
float vysquare = 0;

int iteration = 0;
int lastIteration = Iterations;

do
{
vxsquare = v.x * v.x;
vysquare = v.y * v.y;

v = float2(vxsquare - vysquare, v.x * v.y * 2) + offset;

iteration++;

if ((lastIteration == Iterations) && (vxsquare + vysquare) > 4.0)
{
lastIteration = iteration + 1;
}
}
while (iteration < lastIteration);

return (float(iteration) - (log(log(sqrt(vxsquare + vysquare))) / log(2.0))) / float(Iterations);
}

float4 Mandelbrot_PixelShader(float2 texCoord : TEXCOORD0) : COLOR0
{
float2 v = (texCoord - 0.5) * Zoom * float2(1, Aspect) - Pan;

float val = ComputeValue(v, v);

return float4(sin(val * ColorScale.x), sin(val * ColorScale.y), sin(val * ColorScale.z), 1);
}

float4 Julia_PixelShader(float2 texCoord : TEXCOORD0) : COLOR0
{
float2 v = (texCoord - 0.5) * Zoom * float2(1, Aspect) - Pan;

float val = ComputeValue(v, JuliaSeed);

return float4(sin(val * ColorScale.x), sin(val * ColorScale.y), sin(val * ColorScale.z), 1);
}

technique Mandelbrot
{
pass
{
PixelShader = compile ps_3_0 Mandelbrot_PixelShader();
}
}

technique Julia
{
pass
{
PixelShader = compile ps_3_0 Julia_PixelShader();
}
}

Tuesday, September 1, 2009

XNA BloomComponent and Multisampling

The Bloom Postprocess sample provided on the XNA website has issues if you use the component in a game that is using multisampling.

You'll get the following error:

"The active render target and depth stencil surface must have the same pixel size and multisampling type."

The issue is that the render targets created by the component do not respect the multisampling settings of the graphics device. This is easy to fix, however. In the LoadContent() method of BloomComponent.cs, find the code that is initializing renderTarget1 and renderTarget2.

Replace it with the following:

           renderTarget1 = new RenderTarget2D(GraphicsDevice, width, height, 1,
format, GraphicsDevice.DepthStencilBuffer.MultiSampleType, GraphicsDevice.PresentationParameters.MultiSampleQuality);
renderTarget2 = new RenderTarget2D(GraphicsDevice, width, height, 1,
format, GraphicsDevice.DepthStencilBuffer.MultiSampleType, GraphicsDevice.PresentationParameters.MultiSampleQuality);

Friday, August 21, 2009

Cybraphon



A friend I used to work with back in my Edinburgh days has been working on some pretty fantastic stuff recently. He and his collaborators have been using computer-orchestrated electronic actuators to control a variety of physical music-producing devices.

Their latest creation (shown in the video above) is Cybraphon, a one-"man" wardrobe band.

I really like it.