Friday, 28 December 2012

Dynamically melting snow

The most complex graphics effect in Snowball Earth is without a doubt the snow. As the player walks around and heats up the area around him, the snow melts, forms puddles and finally becomes grass. This is completely dynamic: the player can turn his heating on and off at any point, and the snow reacts correctly to that. The snow even has little piles around trees and rock walls, and these piles lower and disappear when the snow melts. So how did we make this?


A slow motion video of how the snow melts around the player.

Before I continue, I would like to mention once more that Snowball Earth is Ronimo's cancelled game from 2008, and that the complete prototype can be downloaded here:


Download Snowball Earth prototype (Torrent)


So how did I implement this melting effect? The basic trick is that for every vertex, I store the 'meltness': to what extend the ground at that vertex has already been melted. A value of 0 means snow, 0.5 means water and 1 means grass. The pixel shader then takes this value and uses it to simply choose between three textures, for grass, water and snow.

To store the correct value in each vertex, the code simply updates all vertices for which the value has been changed. This is done every frame. This would not be very efficient if the vertex count were very high, but it works well enough here. Especially since this is only a prototype and performance isn't as much of an issue as it would be in a released game.

A nice property of storing this value at the vertex, is that the value gets interpolated before it gets to the pixel shader. So if two vertices are next to each other, and one has value 1 (grass) and the other 0 (snow), then a pixel in the middle would get value 0.5 (water). This means that if I smoothly increase the value at the snow vertex during the melting, then the edge of the snow in between the two vertices smoothly moves towards the snow vertex, which looks like the snow is melting at the edges.



The water automatically always becomes a thin edge of water in between snow and grass, because vertices usually rather quickly go from 0 (snow) to 1 (grass).

So far the edges between snow and water and between water and grass would still be straight lines, since they are simply based on interpolated vertex values. This looks kind of okay, but it is still too geometrical to be really convincing. I would like to break up the border and add patterns to it, so I have a special greyscale texture that contains puddle-like patters. This texture is used to offset the 'meltness' value: I simply add the texture's value to it. The effect this has, is that wherever the offset-texture contains white, the water will disappear into grass earlier, while wherever the offset-texture contains black, the water will remain longer.

Our artist Ralph jumped on this and created two offset-textures: one for the water and one for the snow. He made the offset-texture for the water so that it contains roundish, puddle-like patterns, while the offset-texture for the snow contains long curves. This works really well in the actual game.



In practice, the grass, water and snow are all a little bit more complex than simply 'a texture'. The snow has noisy specular reflections, the water reflects the sky a bit, etc. So instead of choosing which texture I use, I choose which material to use: snow, water or grass.

I wanted this to run on shader model 2 videocards (pretty ancient these days), so I couldn't use an if/else statement to choose the material, since if/else is not supported in shader model 2. Instead, I used the step(a, b) function, which returns 0 if a is larger and 1 otherwise. With some puzzling, most math that needs if/else-statements can be replaced by step-functions, allowing quite complex things to be done on ancient shader model 2 videocards. This is also how I got the snow/water/grass choice working. Just look at this tiny bit of shader code for how that could be done (note that the final line could be replaced by a lerp(a, b, c) call instead):

float4 grassColour = tex2D(grassTexture, uv);
float4 snowColour = tex2D(snowTexture, uv);
float choice = step(0.5f, meltness);
float4 final = (1 - choice) * grassColour + choice * snowColour;

For a complete look at the shaders described above, you can check them out in the file Data\Assets\Shaders\Snow.cg in the Snowball Earth prototype.



The final element to the snow effect is that the snow has little piles around trees and such, and when it melts, it lowers and the piles disappear. This was done with a simple morph: our artists made two versions of the ground meshes: one low one for the grass, and a slightly higher one for the snow. As the ground melts, the two positions for each vertex are simply interpolated to get the final position. Every snow-pile in the game was made by hand by our art-team, who raised the vertices around trees and next to walls.



Only one of the two meshes for the ground is used to handle physics and collisions. This is the lower grass-mesh. A nice added benefit of that is that all characters walk in the snow and on the grass/sand, giving the snow just that little bit extra.



To add to the atmosphere, there are also two different sets of lightmaps in Snowball Earth, each with different colours. This way I was able to give the snowy world a colder, more blueish lighting than the unfrozen world.

Having two sets of lightmaps also has an added benefit. There are no real-time shadows in Snowball Earth, so normally there would be the problem that objects that appear dynamically (like leafs and smaller plants) cannot cast shadows. Having separate shadow maps for the frozen and melted versions makes it possible to calculate these shadows into the melted world only.

This solution is not completely correct, though. If you look closely, you can sometimes see that if an area near a big plant is already melted while the plant itself is still frozen, it already contains the shadow of that plant, even though the plant itself has not appeared yet. However, this visual error only happens at the transition from frozen to unfrozen and is hardly visible (unless you look for it), so I never really considered that a problem.

That's it for Snowball Earth for the moment! Let me know if there are any further topics about Snowball Earth you would want to read more about! In the coming weeks I'll be getting back to posting about Awesomenauts, Cello Fortress, and hopefully also about some exciting graphics experiments I have been doing!

Friday, 21 December 2012

Snowball Earth's melting effects

The part that I find most interesting and am most proud of in Snowball Earth (our cancelled game from 2008), is the melting effects. Every piece of the world is frozen and covered in snow, and by walking around with the heating turned on, the player can melt it all. In the prototype this had very few gameplay mechanics attached to it, but just seeing and hearing everything come to life is already so much fun that it could carry half the game on its own. Today, I would like to dissect this effect and give an overview of what went into it. (Spoiler: a lot of custom art by our artists Gijs, Ralph, Olivier and Martijn, and a lot of coding by me).


The melting effects in Snowball Earth

For those who haven't tried it yet: a couple of months ago (in this blogpost) we released the entire prototype we made at the time, so you can download and play it yourself. Note that this is a Torrent file, so you will need something like BitTorrent to download the game. Here is the download link:


Download Snowball Earth prototype (Torrent)


To manage the melting, the game has a big 2D map of the level (a grid, really) and for each point on the map, it stores how much it has melted yet. By walking around, the player turns the parts of the map from frozen to green. This map is then used by all elements in the level to determine to what extend they should show up melted.

A rather simple effect is the smaller plants: they are just scaled to size 0 until they are unfrozen, at which point they grow to full scale with a nice popping animation. For variation, our artists made a couple of different popping animations, but that's about it.

Key to the joyful feeling while melting things, is that every time such a plant pops up, a little bell is heard. These bells have a number of different tones, which form a happy harmony together. When several plants are unfrozen shortly after each other, their popping creates little melodies. Thanks to Aline Bruijns for the sound design on this.

Larger plants, with which the player can have collision, are already there in frozen state. As the player melts them, their texture goes from a frozen version to an unfrozen version. Leafs and such can be made to appear during the melting by setting their alpha to black in the frozen texture, and to white in the melted texture.



To make these plants look more lively, a vertex shader animates them with a simple waving motion. We have a couple of different shaders for different types of plants. Of course, this waving should not happen in frozen form, so this effect fades in smoothly as the plant is unfrozen.

If you have played the prototype, then you might have noticed that it takes a long time to load, and performance isn't quite that good. Current PCs can handle it fine, but in 2008 only the fastest PCs could run the prototype at a high framerate. The main reason for this is that there are a lot of plants in the level, and they are all separate objects that need to be loaded and updated. If the game had not been cancelled, getting this to work smoothly on the Wii would have been a huge challenge...

Performance wasn't only a problem in the game itself: the version of 3D Studio Max we used at the time wasn't up for the challenge either. To make sure our artists could re-use the same plant in several parts of the level without needing to copy-paste the entire plant, I had made a little plug-in script object for 3D Studio. This object would automatically handle an XRef object: a reference to a plant model in another file.

However, the combination of lots of scripted plugins and lots of XRefs totally broke 3D Studio. Near the end of the project, our artists had to restart 3D Studio every hour or so, and had to constantly monitor its memory usage. At some point the memory usage would suddenly go crazy, leaving about 20 seconds to save the work... This made me a little bit afraid to use existing tools in the future again, and I am much happier with our own in-game tools for Awesomenauts now. In our own code we can actually solve brutal bugs like this...

We also wanted grass, and because of the performance trouble, I immediately built that using something similar to a particle system. All the grass in an area is rendered as a single object, despite that pieces of grass can grow individually based on what part of the grass area had already been melted. I even made a nice little brush plug-in for 3D Studio to allow our artists to quickly draw the grass where they wanted it. Programming 3D brushes is immensely fun, it is a pity I haven't needed custom 3D brushes for something since!



Ice walls in the Snowball Earth prototype may look like they were made using physics, but to reduce coding time, their destruction animation was animated by hand by an artist. As a cute little extra, we also have smaller blocks of ice with frozen animals in them. When they are broken, the little rabbit inside starts walking around and makes rubber ducky noises when the player stands on it.



A more subtle element is the sound effects. The game has two tracks of ambience: one with sounds of birds and jungle, the other with chilly winds. These are subtly faded in and out depending on how much of the area around the player has already been melted. Few players will have actively noticed this, but this is incredibly important for the mood of the game. As the player walks from the happy jungle in an area he just finished, to the chilly winds of a new area, he cannot help but feel even more like it is time to melt it all and bring back the happiness!

So far I haven't mentioned the thing that is most noticeable in the melting effects of Snowball Earth: the ground. This is because the ground is my pride and joy in this topic and I find it interesting enough that it deserves its own blogpost! See you next week!

Friday, 7 December 2012

Wacky marketing thingies

In last week's blog post, I mentioned several times that doing marketing as an indie requires creativity. It is easy to buy advertisement space, but it is a lot more challenging to come up with things that are so interesting that press will write about them for free.

At Ronimo we greatly enjoy coming up with such weird marketing stuff, so here are some of the most fun/creative/weird things we have done so far, and also some that I did myself for Proun. Some only cost us time to do them, while others did require small amounts of money to produce. Note that not all of these actually worked as well as we hoped, but they are hopefully still fun to see! ^_^



Swords & Soldiers hot sauce! The game's story is all about barbeque sauce, so giving press special branded hot sauce seemed fitting. Of course having these made would be very expensive, so we simply bought standard hot sauce, removed the labels, and put our own stickers on them. All of this was done in a hotel in San Francisco, since importing large amounts of food is probably not allowed. I suppose the hotel still remembers Ronimo fondly for clogging the bathtub drain with soaked labels...



For Awesomenauts we had a little bit more budget for marketing, so we had these special bags of Awesomenuts made to hand out at Gamescom 2011. The naming pun is so good it was just impossible not to!



I still consider this one of our best marketing tricks. For players who got all the achievements in the WiiWare version of Swords & Soldiers, a special code was generated that they could e-mail to us. We promised the first people to do so a bag of Swords & Soldiers swag, which amongst other things included the special poster above (autographs of the entire team are on the back). We announced this before the game launched, and we actually saw quite a few people online discuss how fanatically they were going to play on launch day to win one of the prizes. The buzz was nice, and as a bonus it turned out that one of the winners was a game journalist, who posted the contents of what he won as a news article on a big WiiWare site.



A friendly marketeer was nice enough to help us with some press releases, and he came up with the term "Morefun (tm)", which is something we had apparently come up with in our game laboratory. It made no sense at all, but it was funny and quite a few websites picked up on it. This is a nice example of how something as small as the way you word a press release can already have an impact on how well your game is covered!



For Awesomenauts we had an intro made with a real theme song, for which this great singer was hired. The song turned out to be a great central piece for our marketing efforts. All our trailers end spectacularly on a high note by Jeffrey, and the cheesiness of it all got a lot of buzz going when we first announced Awesomenauts!



Since Sonic Picnic made such a remarkable soundtrack, we figured it would be a good idea to have it printed on vinyl as a gift for press and friends, and as a reward for competitions and such. Having a real vinyl copy of your soundtrack is indeed amazing, and everyone who receives it, seems to love it. Even those who don't even have a record player...



When we learned it was possible to order special shoes themed to your own game, we just couldn't not order them for Awesomenauts. These shoes were recently given away as the main prize in a competition that some website ran.



A lot cheaper to do were these custom Swords & Soldiers Move controllers, since we customised them ourselves. These were given away at a contest on IGN. We had hoped to reach front page with this, but in the end IGN didn't post it that big, so the actual reach of this was limited. Still, fun swag to make!



This is an example from a totally different category. Making more than one or two trailers require that you look at your game creatively. You need to think about how it can be something new and interesting in every video. For Proun I made a video in extreme slow-motion, which differs greatly from the speed of the real game, but is pretty mesmerizing to watch.



I did not choose Pay What You Want for Proun as a marketing gimmick, but it turned out to be a great trick for that indeed! As far as I know, Proun was at that point the biggest game to ever be Pay What You Want right from launch day. The Pay What You Want model was also still quite new to games at the time, so press picked up on this massively and it drove tons of extra attention and sympathy to the game.



Another example of something that was not intended as marketing, but turned out to be great for it: a couple of months after Proun's launch, I released the complete sales data for Proun, plus an analysis of what I thought it all meant. Revealing sales data like this is extremely rare in the games industry and was thus picked up as news by lots of sites. The result was a lot of extra sales, and I think in the end around 10% of the total sales of Proun happened because of that one blogpost.



The main reason De Blob managed to take off and get enough interest that THQ decided to buy the rights and make two console reimaginings, is that we put out entire version of the game online for free. Looking back, our version of De Blob can be considered to have been a prototype for the final version, which we released online as a marketing trick to increase interest in the game, and to see whether the concepts were good enough for a bigger game. Apparently sometimes just throwing your early stuff on forums can be a great marketing trick!


Most of these marketing ideas generated a decent amount of buzz for our games, but of course not all of them turned out successful. However, at the very least we ourselves greatly enjoyed each and every one of them! ^_^