Author Archives Ape

Simian Squared Go Perceptual: Week 5

Frankly, the API and SDK for developing with Unity and the Perc, are well-written and comprehensive all things considered. I do not know about other teams, but from my perspective, this is far from the wild west of experimental programming back in the 8 bit and 16 bit Amiga days of copper list hacking and trial and error pioneering stuff.

That’s not to say that the spirit of those early experimental years isn’t here – it very much is! intel has managed to both inspire me and also give me pause for thought. I went into this challenge without any hope really – The Other Brothers is currently in crunch time for launch, and I have pitiful little time to devote to this challenge.

But I found time today and you know what? it made me smile. It also taught me that Perceptual Computing is NOT a fad. It’s not a here today, gone tomorrow passing fad. I’m going to go out on a limb and stake my reputation on saying that it is the future of all computing to come. Using it with a touch screen display like you get on the Ultrabooks really hits home how useful it will become.

I can see myself lazily swiping the air just to tab between apps – perhaps to check Skype messages – I could pinch gesture and throw skype into a corner of the screen and dock it there, all the while talking and the perc device would just be recording and translating this document. It would work WITH humans, not against them. If you think about it, gesturing is a natural human behavioural trait – the mouse is not. Like it or loathe it, perceptual computing is the future.

Right now it’s the wild west and I feel priveleged to be part of this wonderful challenge and it has been the only thing in recent weeks that has truely been a breath of fresh air. In fact I am now an evangelist of the technology – if people cannot see the raw potential here then perhaps I have reason to despair!

Intel are doing the right thing here, they are courting developers, and doing masses of R&D, holding challenges and more in order to bring perceptual computing under the spotlight. Like all good new things, this may take a while before it becomes an everyday part of our computing lives. But once upon a time, touch-screens were a novelty, and then they were seen as essential for mobile. Now you will find touch screens on high end Ultrabooks in your local computer store. What was once seen as a gimmick is now useful enough for everyday tasks.

 

Onto the code… reading the basic instructions seems straightforward enough -

1. Copy 3 files into your unity plugins folder. All unity programmers know this, right – done!

2. Create a cube and render gestures to a texture, with a simple piece of code, which we’ll be mapping onto the cube, just to see. Classic prototype stuff here, folks!

using UnityEngine;
public class DrawCube: MonoBehaviour
{
private Texture2D texture;
private PXCUPipeline.Mode mode=PXCUPipeline.Mode.GESTURE;
private PXCUPipeline pp;

void Start()
{
pp = new PXCUPipeline();
pp.Init(mode);
int width, height;
pp.QueryLabelMapSize(out width, out height);
texture = new Texture2D(width,height,TextureFormat.ARGB32,false);
renderer.material.mainTexture = texture;
}

void OnDisable()
{
pp.Close();
}

void Update()
{
if (!pp.AcquireFrame(false)) return;
if (pp.QueryLabelMapAsImage(texture)) texture.Apply();
pp.ReleaseFrame();
}
}

…And it does not work. That’s right – the unity example PDF is out of date, and QueryLabelMapSize interface with dll seems to imply that it wants an array of 2 ints instead. Easily fixed, but it will catch some programmers unawares. Remember, this is an SDK that is still in development. The following code fixes these issues and borrows some extras:

using UnityEngine;
using System;
using System.Runtime.InteropServices;

public class Main:MonoBehaviour
{
private Texture2D tex;
private PXCUPipeline.Mode mode = PXCUPipeline.Mode.GESTURE;

private PXCUPipeline pp;
private int[] size = new int[2]{0,0};

//=======================================================================

void Start()
{
pp = new PXCUPipeline();
if (!pp.Init(mode))
{
print("Unable to initialize the PXCUPipeline");
return;
}

if (pp.QueryLabelMapSize(size))
print("LabelMap: width=" + size[0] + ", height=" + size[1]);
else if (pp.QueryRGBSize(size))
print("RGB: width="+size[0]+", height="+size[1]);

if (size[0]>0) {
tex = new Texture2D (size[0], size[1], TextureFormat.ARGB32, false);
renderer.material.mainTexture = tex;
}
}

//=======================================================================

void OnDisable()
{
pp.Close();
pp.Dispose();
}

//=======================================================================

void Update ()
{
if (!pp.AcquireFrame(false)) return;

Process();

pp.ReleaseFrame();
}

//=======================================================================

void Process()
{

if (pp.QueryLabelMapAsImage(tex)) tex.Apply();
}

//=======================================================================

}

…So what does everything do? Well most of it is just C# setup stuff, the important part is:

pp = new PXCUPipeline();

This creates a new object called pp because that’ll stand for PXCU Pipeline, and we’ll be able to send commands to the system. For this example, only gestures are initialised, and that’s done by setting the mode with:

private PXCUPipeline.Mode mode = PXCUPipeline.Mode.GESTURE;

With the command:

pp.Init(mode)

So far, so good. Nothing scary here, but this example is pretty simple. The main update loop will terminate early if pp hasn’t aquired a frame yet, otherwise it will grab an image from the camera.

At the end of grabbing an image, it lets the system know that it’s ok to continue with its business using:

pp.ReleaseFrame();

Hitting play gives me a darkened blobby thing on screen! wait- thats ME! I do feel I need a haircut. It’s at this point I toy with the concept of wanting to make a virtual hairdressing app. I can only imagine how dazzling I would look with golden flowing locks.

But, back to business! this app is about pottery, and manipulating clay. It never goes as far as say, zbrush, because it’s designed for anyone with no know-how to be able to engage with perceptual technology, and get used to it.

In a way, it is these apps we are doing – pottery, or other similar creativity apps, that will ease computer users into thinking about gesture commands and what they do with their hands. I am quite sure one day, Windows will understand when an Italian user is feeling rather annoyed with the paperclip!

Back to work, so my first job is to be able to get sane depth, and sane numbers that can actually be used. Usually to do this you want to transform your gestures into normalised space, that is, the dimensions must be between 0 and 1, and this means we can scale that back up to resolution, or in 3D space just fine.

To calculate normalised coordinates, you divide the number you’re getting with the largest it can be, so if we’re looking at greyscale depth, the largest colour would be 255, so we divide by that. Or 256, depending on your viewpoint.

So 0 to 255 becomes 0 to 1. Now we can transform this coordinate however we like, into any other space, without worries if it will be too big, or too small, or warped.

—-

The next post will be a bumper one – Giuseppe will be video blogging from GDC, there will be a healthy serving of code-talk from Rob followed up with a  hands-on (finally) look at this project we’re calling ‘Pot’.

We will be talking on Intel’s Theater stage, so please do come and participate! We’re on stage on Thursday 28th March at 15:30 and in the booth on the 27th and 29th - follow us on Twitter to be notified of the exact times and places closer to the event.

In the mean time, here is some actual footage of the scene running on the Ultrabook itself to whet your appetite:

Originally posted on Intel.com

Simian Tech: Mode 7 Renderer – The Other Brothers Developer Diary

So what is Simian Tech: Mode 7?

It’s one part of our proprietary engine called Simian Tech, and specifically what gives The Other Brothers its distinct rendering style.

Built on top of the standard unity rendering pipeline is a dedicated set of tools, shaders and custom mesh code we’ve created that perfectly emulate 16 bit style and DOS style rendering. This technology enables us to colour cycle, flash, make things a “virtual resolution”, add realtime dithering and realtime resolution normalization so that you get a real retro feel from it as opposed to just drawing it all. It includes vignetting, plus screen “burn” effects to emulate an old monitor display as well, however that is kept to a minimum for The Other Brothers in order not to detract from the fine artwork.

Weeks of optimisation have gone into this with hand crafted shaders – none of that rubbish unity default prefab nonsense, this is coded from the ground up for speed.

We can confirm ipad1, ipad2, and the new ipad as well as iPhone 4 and 4S as running at a cool 60fps so far – this is with mode7 and vignetting, burn etc…

And most Droid owners will be really happy with 60fps!

3GS has yet to be tested but if it’s not 60fps on them it will at least never drop below 30fps. It was a nightmare to pull off because whenever I moaned about overdraw / fill rate to them they would stick their fingers in their ears and cry “la la la la la la we can’t hear you! la la la la” and happily just built levels with masses of waste overdraw – all in the name of art!

SIGH! but anyway after losing hair and sanity I think Simian’s pulled off a fine little engine to drive TOB with and the gamers will appreciate the fluid framerates and fast responsiveness.

We made a couple of design decisions such as jumping being on auto repeat (hold it down and it will jump as soon as you land again) – to minimise slips, or fingers not connecting properly with the screen (perils of a touch screen device) and much care has gone into making it feel responsive with good reason… sometimes you get a murderous amount of enemies trying to take you down – they are almost like mini bosses in some ways!

There will be a sexy new video coming very early after the weekend which I hope you guys will be pleased to view.

Thanks for reading!

The Indie Industry

Indie is about to explode. It’s no longer about David and Goliath, with the bedroom coder being jack of all trades and going it alone. Because now the “indie scene” is dominated by giants and ex console developers. The quality bar is just too high.

There’s exceptions which will always sing loudly like minecraft, but these are 1 in 1 million, literally what with development of games now open to anyone who can point and click. So to stack the odds in their favour, indies are now moving to teams to raise that quality and step in the ring with Mohammed Ali.

Indie is now standing toe to toe with the big boys, and this is changing the nature of the old fashioned game industry where you had to get a publisher, you had to go retail and so on. Now anyone can do it, and the competition is boundless.

This means quality for indie titles is now easily on par with AAA, it is just due to time and work restraints, indie titles have to have creative edge to survive. This means like in The Other Brothers, you need to think out of the box and create great AI, and playability to die for… and marry them with a stylistic and iconic retro style. That kind of stuff can only come from really hard working indie developers with prior experience.

AI

A.I

Artificial Intelligence, or Acute Idiocity? There’s a lot of fun to be had making AI and it’s actually very easy for an experienced programmer like me to invent AI that is foolproof and able to dodge your every attack while ensuring it can kill you. At Simian Squared, I’ve spent many late nights devising the perfect blend of AI, and observing my pet cats… although to be honest, I think they were observing me!

But AI is an interesting subject. Make them too smart and it becomes tiring…. make it too stupid and it becomes predictable. Instead for games, the best AI is “entertaining” AI. It must always behave interesting and make you play a little bit different for each creature, it is how you make the game or break the game.

I actually felt that the most important part for the AI in The Other Brothers would be to make the AI force the player to Play Different. Play Different is a motto of mine when it comes to playability and game mechanics. I love to make the player use the same controls, but react and act differently in response to situations the game throws up.

As you can see in the above screenshot, it shows ratty, he has a red box surrounding him which allows the level designers to change his ‘Aggro Range’ – the range in which he will get extremely annoyed with you!

The yellow line indicates the patrol route. Both are adjustable, so you can have rats which patrol a very long way, or rats that can’t see very far. The designer is able to change the tint of any creature as well as change these properties. Best of all, every property in the AI is animatable…! So without the programmer being present, it’s possible for an artist or level designer to create a virtually unlimited amount of behaviour from a simple set of behaviours. I try to discourage them though. A level designer out of control is a terrifying thing for a programmer to witness!

Each creature in TOB has 3 difficulty levels the designer can pick from. There’s stupid, average and smart. This is adjusted in the code on a per-creature basis (it’s a lot of work!) but it’s worth it because you don’t want every creature to behave the same. For example stupid dogs can’t spot you creeping up behind them, but average dogs can. Smart dogs may even avoid your stomp attacks from time to time…

Controlled Random

It’s important to have a “controlled random fury” going on with the numbers. In my AI, the system is constantly fed inputs with random variation. The player might be close, but it has a little random fudge to it as the enemy might not judge if you’re perfectly close enough to have a nibble on. Likewise this is present for their movement behaviour.

Sometimes random numbers fight random numbers which are fed in as a fudge for a normal sensory input, which makes it feel like it is making decisions (it actually is) but sometimes it will not always be a good decision.

It was important to slow down how often enemies make decisions. This is known as the time it takes to change your mind. This also has a little random edge to it as well. Nothing is completely random at all, it is merely taking a cold logical true or false, and giving it shades of grey for exciting variation.

Emotion and Logic

Each creature has a boredom level as well. If you keep diddling around it will get bored of your pranks and wander back off… maybe. Don’t be surprised if a smart one pretends to lose interest and walk off…

After all what is more fun to fight: spock or the hulk? Spock would grip you or distract you (yawn) but the Hulk has random fury and will smash the place up, you could slip away or Hulk could get distracted by a cheeseburger. You just don’t know.

Above all, the AI in TOB is very much interested in giving the player a good time rather than being infallable. It’s entertaining AI, not stressful AI. And every single creature is different.

Stay Pixelated :)

-Rob

The Other Brothers Dev Diary: Empowering Artists = Great Game

Today I’m busy polishing up a small demo for the team to display next Tobsday (see above for what tobsday is) — so you’ll be getting a SNEAK PEAK at the game itself! Work is going at a tremendous pace, and don’t forget to leave your suggestions for bosses, ideas and more either over on our facebook page (link on http://www.tobgame.com) or here!

Empowering Artists = Great Game

What is all this empowering business? Well, typically in game development, artists have to create assets or design levels with huge restrictions due to the code. You’ll be stuck with 32×32 tiles (which will look boring in the end) or have limitations on how they can develop the game.

We’ve thrown all that out of the window

1. Artists can just draw whatever they want in Photoshop, at any size, and we’ll convert it to a layered animation.

2. Colliders are not linked to geometry so we can get really creative. Artists can just pull out artwork and place it down at any depth in the editor and group them. They can add a parallax script live in editor and see it happen. They can tweak any part of it at any time.

3. There’s no limitations on anything. If an artist wants a pigeon to do a little poo randomly with a 30% chance of doing one, then they ask me and I do it. I don’t moan, I don’t make a fuss, I just get off my ass and do it.

4. Effects and particle systems that are FULLY animated as well – so you can have fully animated hand-drawn wisps of smoke, and fantastic environmental effects without the headaches.

5. They can add anything they want in any part, without any restrictions. So what is the catch?

The catch

The catch is the programmer (me) is slowly going insane. It takes a tremendous amount of effort and polish in tools and level design ease-of-use, but in a way it can be seen like I am also directly contributing towards the art goal of the project. If I can free artists to just be themselves, it means that they spend more time doing what they do best, and less time worrying about a script or going crazy over restrictions. This increases the amount of art they can shift out… Which means TOB is FULL of unique artwork, just about everywhere!

But if I’m crazy about one thing, it’s your fun. We need TOB to be a massive celebration of retro gaming, with cues taken from the history of retro games. There’s a little bit of influence from everything in here – see if you can spot them. One thing this game isn’t is… a clone. Expect the unexpected!

Please offer feedback and ideas, you never know, you might be the one to influence a level or enemy. And stay peeled for an early test demo on our livestream this coming tobsday.

Soon I will be talking about the render to texture technology the game uses and why, plus some techie AI talk (that’s right, these things will be pretty smart!)

Our facebook is http://www.facebook.com/theotherbrothersgame - give us a friendly like and post some words of inspiration, we will read every comment 

http://forums.toucharcade.com/showpost.php?p=2263136&postcount=20

The Other Brothers Dev Diary: Animation (cont.)

There’s two things which will make or break animation in a retro game like The Other Brothers.

The first thing is the animation itself. It can suck, and there’s not much you can do about that. Luckily the art quality is insane, with artists who are used to triple A work sketching them out at a cracking pace!

The second thing is how gently the programmer will treat the artist’s frames and even massage them for more amazing sparkling goodness.

1. we have animation states for everything: run, idle, jump, skid, hurt, falling, attacks and more.

2. we play the intended animation – be it a one shot, or looping animation.

So what’s different?

In TOB, I have several variables which track how fast the character is moving, how hard the player is pushing the direction and so on.

So we can weave in more frames in between, and play little one off frames to blend everything together. It’s painstaking work because it takes a lot of trial and error to get the maximum out of the frames you have.

In addition to this, its really important to speed things up or slow them down in regards to animation playback. So to this end we do things like speed the animation up as the character’s velocity increases.

We also track how long the player has being doing demanding activities, so when Joe or Jim halt for a breather, you see their idle animation play faster, before slowing down as they catch their breath.

It’s all these little touches that really can make or break a retro title. You can’t just fill it with animation frames and throw more money at it. It has to be authentic.

We’ve deliberately left in an easter egg surprise for people who have played old retro games: the classic left and right thrashing of the controls will allow you to spaz out for hilarious dance scenes, if you so choose!

Next to come will be some clips and anims you haven’t seen, as there’s been too much talk and not enough glorious sneak-peaks!

Be square (it’s cool!)

- Rob

 http://forums.toucharcade.com/showpost.php?p=2260894&postcount=17

The Other Brothers Dev Diary: Facebook Winner #2!

TA’s Brad Nicholson!

Congratulations, Brad! you may be a runner up,
but you’re still the coolest retro boss ever made!

For more information about The Other Brothers,
visit our facebook page, and follow us on the usual
social media sites! We will be leaking information regularly 

The winning shot:

http://forums.toucharcade.com/showpost.php?p=2257412&postcount=15

The Other Brothers Dev Diary: Facebook Winner #1!

Facebook Competition Winner #1 announced!

A big thanks to our facebook contest winner Gary Norbraten for being such a good sport. Bjorn Hurri had a blast creating him gloriously pixelated! We have all had good laughs at the end result! He ended up being a perfect fit for The Other Brothers!

Check out the real mcoy plus others in the gallery for the competition:

Our facebook (like it!)
http://www.facebook.com/theotherbrothersgame/

Like the facebook page and tweet about us, bookmark http://tobgame.com - keep your eyes peeled for more compos and exciting news!

Soon we will announce the second winner of the facebook competition, and this dude… we think you know him! 

Stay pixelated!

http://forums.toucharcade.com/showpost.php?p=2256398&postcount=13

EDIT: Please note, competition winners ARE actually ingame bosses. Yes you have to fend off an unlimited ninja swarm from this bonus boss. The next competition bonus boss will blow your mind though… next post should be it!

The Other Brothers Dev Diary: Ladders, Water and Moving Platforms

Today I’ll talk about Ladders, Water and moving platforms. Apparently it takes some developers a long time to figure out something as simple as the humble ladder but it took an hour here.

Climbable Surfaces

However The Other Brothers ladders were designed with the following:

1. ladders can be any shape or size, and any angle.
2. ladders can rotate (anything can in my code base), and move.
3. ladders can pass through other ladders in an intricate network or ladder-soup.

But what about playability? How do you make something as boring as a climbable area, exciting?

Here’s how!

1. player should be able to jump while on the ladder, and not catch it again until almost half a second has passed. This means there’s no point spamming jump to go up ladders faster, and the player is forced to think. This also allows you proper clearance from the ladder when doing risky jumps.

2. the ladder must allow player to pass through platforms. We solve this with some clever collision states.

3. the ladder must allow us to hang from it or attach to it at will, so we can run past it and ignore it or jump through it without a worry. This is solved by checking if the player is pushing up or down when your character passes a ladder.

Water

Water is a similar system to the Climbable Area. Once the player enters, we want to change how you play.

There is no point in water being a sort of big climbable area so the only way you can swim is to tap jump. This makes a stroke upwards. You can swim normally left and right regardless. The physics are changed to make it suitably weighty.

Again, water isn’t limited to any specific shape or size, and you can even climb up a moving ladder into a pool of water (not that this makes any sense).

Moving Platforms

It’s important to get this right. We want moving, rotating, shifting and falling areas. We want it exciting, unpredictable and varied. This is solved by having a pin cushion concept. Whenever the player moves into a zone marked as platform, it becomes a child of that zone, and inherits the parent’s movements.

Zones

You may have guessed all 3 above concepts sit on something I call a Zone. A zone is a polygon mesh or mathematical shape which can define an area of importance. The work flow for this is really cool in unity, and artist friendly. We can tell them to be anything or do anything – even start up cut scene.

Cut scenes?! Yes the cat is out of the bag, there will be many full cool cut scenes to tell the story, but that is for another diary posting!

Stay pixelated!

-Rob (@SquaredApe)

http://forums.toucharcade.com/showpost.php?p=2256362&postcount=12