It’s been awhile since I’ve had a chance to post on here – I’ve been in the process of pursuing employment since my day job is coming to an end in August. The results were good, and I’ll be moving to Japan in a few weeks to work on simulation building and research, but as you can imagine it hasn’t left me much time to pursue game development projects (though there are a couple things on the backburner).

However, now that its out of the way I’ve had a chance to think about game development again – specifically, reflecting back on the release of Travelogue and some lost opportunities at that time. I decided I approached the release of Travelogue a bit backwards – namely, why the heck didn’t I put it on Greenlight? 

So, Travelogue is now on Greenlight!

 

Arctangent noiseIf you recall that fluid dynamics shader I posted last week, I’ve written an article about how to write one. Check it out!

Currently I’m working on an article about using fractal noise to pick things like terrain types for procedural world generation. It turns out that getting uniformly-distributed fractal noise is a bit tricky. Usually when you add multiple independent noise sources together as you do in fractal noise synthesis, you get values that are Gaussian-distributed (in fractal noise you can get other things because of the fractal nature). If you’re using those noise values to pick from a weighted list, the weights will get all messed up because of the shape of the noise distribution. The trick is to use a continuous function to map the Gaussian-distributed noise to a uniformly-distributed range.

In practice this is tricky to do without creating undesirable shapes in the noise – for example, if you use modulo to wrap the noise to the [0,1] interval you get high-frequency bands. The solution I’ve found so far is to use two noise samples and use the arctangent to generate an angle using those samples. This will still have certain unpleasant features – ‘vortices’ where both noise functions approach zero – but they are greatly reduced compared to the modulo approach (see the picture on this post).

Update on One

its_not_all_impactI’ve been very distracted over the last few days and my sleep schedule is getting pretty messed up thanks to a game called Academagia which a friend pointed out to me after seeing Travelogue, but at least we were pretty productive last weekend before I got my hands on it. Here’s the highlights:

Jeff and I managed to put a lot of new objects into One. There are now unstable planetessimals that detonate, sending you flying across space (at a significant portion of the speed of light before we tweaked things down a bit), asteroids that change course erratically due to releasing jets of vapor from cracks in their surface, and dense, spikey asteroids that are particularly dangerous and can damage you.

There’s also a whole bunch of 3D ‘medals’ for the achievements now rather than my little 2D placeholder icons, which slide into place, rotate, zoom, etc when you hover over them in the UI. No, they’re not all impact achievements, but thats just the one icon we have for now. Among the ones on there are achievements for breaking multiple objects in a row, going fast, growing quickly, going way too fast, eating stuff every couple seconds for a long time, and changing direction shortly before slamming into something.

One gameplay thing we’re playing with right now is a ‘density’ system, where when you eat denser things you can build up density and find it easier to retain more mass from the things you collide with, as well as making it easier to break objects and draw them in with your gravity. Of course if you then eat a lot of low density stuff like dust clouds, you lose those advantages, so you have to balance your rate of growth with managing your density.

Next on the list of big things that need to be done is audio. This is a big problem because of the various levels of support for HTML5 audio across the different platforms (not to mention WebGL, but there’s not much helping that). Currently it looks like our solution will work on desktop and in Node-Webkit just fine, but its going to have some problems on Android due to the fact that it seems like you can only play one channel of audio at a time with HTML5 on Android, so its sort of ‘sound effects or music, not both’ which really sucks. I’m looking into Web Audio as an alternative, but early investigations suggest that it will have the same problems.

Things are coming along nicely with One With Everything (aka ‘the space game’). We’ve got a few more objects in, and added health and the necessary code to handle achievements and upgrades. The basic idea is that there are ‘dynamic achievements’ that give you points you can use to activate upgrades – these are things you can always in principle do better: what is your best time, biggest size, fastest speed, etc. Then there are ‘static achievements’ such as ‘break 3 objects in a row’ or ‘eat a gas giant’ that unlock new upgrades when you get them. Currently the only upgrades are the basic speed/health/etc type, and a ‘identify friend from foe’ system that color-codes objects based on whether or not you can absorb them or if they’ll damage you.

I’ve also made a little video of the current gameplay to share, check it out!

Shader retrofits

Work continues on the space game. It’s now possible to play from about 1 meter in size to somewhere around 1000km and continue to encounter new objects to absorb – planetesimals, moons, gas giants, etc.

Part of doing this has involved a somewhat tedious adaptation of Three.JS’s generic phong material. The problem is basically that you can’t easily ‘add an effect on top’  for the material, you almost have to reimplement the entire shader. I didn’t have to go quite that far, but I did have to print the shader code into the console, copy-paste it into my code, and tweak it from there. The entire thing is something like 600 lines long, and has a bunch of tricksy things you have to do to get it to work (setting defines on the material to enable features that are normally automatically configured by the WebGLRenderer).

The entire experience has made me want to make something like Blender’s node-based materials editor for shaders. If you want a glow on top of a phong material? No problem. Add an electron microscope effect too if you like, and a cartoon shader on top of the whole thing. It’d be a pretty involved project, so its not going to happen for the space game, but it seems a natural tool to have.

Anyhow, the reason for rebuilding Three.JS’s shader? We wanted to add ‘rim lights’ around objects. This effect basically just lights the material when the surface normal is near-perpendicular to the view vector (something like (1-(normal dot view))^4). It turns out that putting this on the ice shard models turns them from looking like kind of purple rocks into really looking like ice. I think its going to do wonders for planetary rims as well.

It was a bit of a slow week for game development for me with having to get some papers polished up for my physics day job, but this weekend Jeff and I have been working on the space game (now tentatively titled ‘One With Everything’). Mostly the focus has been, how do we do ‘stage transitions’ between scales that are smooth?

The game is supposed to cover about 15 orders of magnitude in scale when all is said and done. Thats enough that floating point problems could raise their ugly head. We could just cut things off every 3-4 orders of magnitude and make a new stage, but that feels artificial and abrupt. So instead the idea is to ‘curate’ position and scale every so often, re-centering the game on the player and rescaling everything to keep it in a numerically stable zone. That should take care of things up until about the planetary scale.

The problem at the planetary scale is, we want to have the player start zoomed in among a debris field and then eventually get big enough that they can start noticing their ‘orbit’. Once the player is big enough, they can either reach escape velocity (in which case the game zooms out, everything vanishes, and then it zooms in placing them in orbit around a different randomly generated object appropriate to their size) or absorb the thing they’re orbitting around, in which case they start to orbit around a new object one ‘tier’ higher (absorb a moon, you’re now orbiting a planet; absorb a planet, you’re now orbiting the sun, etc).

That means spawning an object that might be 100-10000 times bigger than the player in order to have it there (so if you go inwards in the orbit far enough you encounter it and get gobbled up). For example, in the current demo when the player is 10 meters in size, we place a planetoid 3km away that is itself maybe 1km in radius. However there’s a noticeable amount of glitching when you’re close to the planetoid – objects tend to graphically jump around on the sub-meter scale during their orbits, like they’re suffering noticeable round-off errors. The actual velocities involved aren’t that large and the orbits appear stable, so I don’t think its the numerical integrator, and it looks like the objects actually do change position when they ‘jump’, so its not just lag bursts from generating new chunks. At this point I’m not really sure what it is.

The game is playable with it though, so I’m going to give it a rest and move on to another element of the game – the progression system. The way One With Everything is set up is that you have a certain amount of time to absorb things and grow before everything disintegrates around you. This time is going to be fairly easy to maintain at the early levels, but it will get very rough at later levels. However, as you do crazy things like bounce off of objects at half the speed of light, do tight gravity assists around heavy objects, etc, you unlock achievements. These aren’t just for show – they’re the ‘currency’ for the game’s upgrade shop. Every (couple) achievements, you can buy an upgrade to your speed, maneuverability, ability to break objects, etc. You can then choose to leave these upgrades on and get their benefits, or turn them off to get a bonus to your score multiplier.

The idea is that as you play the game, yes you have to repeat the early stages, but at the same time there will still be new things you can earn during those early stages so you aren’t just retreading old ground. Hopefully that will make for a fresh and interesting take on this kind of repeated-play/progression game.