I was starting to flesh out the third section of the tutorial when I realised I was missing a screen. (What do you mean, I keep getting distracted from the minimum shippable vertical slice level?) One of the primary ways you’ll be able to get into places you’re not supposed to be is by finding the codes to keypad locks, except… well, then you need somewhere to store those codes, so you don’t forget them. You need a Notepad.
Then I realised that there was another missing piece of the datavault: the area map. How can you find your way around without a map? (Quite easily, my levels are not going to be particularly large, but indulge me, please.)
Raiding the Datavault
Luckily neither of these features is particularly strenuous to add.
The Notepad is a list of text boxes, with a little pop-up window for editing or deleting whichever one you clicked on. These are all interaction paradigms I have in spades; there’s nothing controversial here.
One design element I did swither over, however, is where notes actually belong. My initial instinct was that notes are ephemeral, floating things that exist independently of any other context, so of course they belong in the datavault, with the sea of other random junk data you’ll pick up along the way.
However, that’s maybe not entirely true. Notes might be specific to a certain quest; after all, once you’ve opened the door to Mechface’s Military Manufactory, that code is now irrelevant clutter — most codes are going to be single-use or at least location specific. Since quests are ticked off and locations will be left behind as you advance through the Chapters, why not put notes under quests in the Journal and let them die gracefully when you move on?
I decided not to do this because while, yes, there will be notes specifically associated with quests, there may well be others that are just for fun, or are more oblique, or point to secret areas that have no attached objectives. In that case, I’d need to have the free-floating notes in the Datavault as well as quest notes, or some extra junk section of the Journal, and it would become much harder to find any particular note because you’d have more than one place to look. Soooooo they’re going in the Datavault, and it’ll be up to the player to bin or keep anything they’re interested in.
New notes are added to the top of the pile, though, so you won’t have to scroll for three hours to find the code you picked up five minutes ago. I’m not that much of a monster (also you would not believe how hard it is to make a Unity UI scroll view snap to the bottom as new items are added).
The map is a bit more fun, because it has to be generated from the landscape. Thing is, I actually already have this: the current iteration of my fog of war system has been in place for quite a long time now, though I’ve never actually written about it…
I’ve always liked the fog because it adds a layer of mystery to unexplored areas of the landscape (and, uh, means I don’t need to decorate areas that will never be accessible). There’s just something intrinsically satisfying about pushing back the shroud, and it’s a great way to remind the player of which places they’ve already visited and which they haven’t.
When I did fog of war the first time around (many, many years ago), it was tied into the procedural level generator. It used the generated world’s heightmap as a texture, which it sent to a projector to be overlaid across the whole world.
Back then, I didn’t really understand the cost implications of all that. In order to make that kind of overlay work, a projector simply renders everything twice. You may have heard me muttering about how hard I am on the renderer at the best of times, so fully doubling its workload — especially to do either nothing or show pure black — was maybe not a good idea. Ahem.
The core technique is the same — get a big texture and erode its pixels as the hero moves — but instead of getting the heightmap for free as part of level generation, I now have to build it manually. This is the oldest trick in the book — cut the world into a grid and walk across it, raycasting as you go to get the height of each cell. As the player hero moves, lines are drawn outwards from it and heights are compared, stopping if a cell is too high (actually just after a cell that’s too high, so that walls themselves are revealed but not what’s behind them). For the fog itself, the cells that are revealed are simply holes punched into the alpha channel of the solid black sheet.
Now that I understand shaders (or at least Amplify Shader Editor), I can take this texture and use it a little more efficiently. Instead of rendering everything twice, I have banged the sampling of my fog texture into the lighting calculations. It takes the world position of a pixel and uses that as the UV coordinate for the fog texture, then uses that to transition smoothly between the normal lit and textured world and the solid black of fogged areas.
This has other advantages, such as how projectors would get shirty around transparent and additive materials, whereas putting it into the lighting system means the fog can apply automatically to any kind of material I’ll ever make. (The only missing part is particles, because Amplify doesn’t seem to let you make custom particle shaders — not sure how or why, but either I’m missing something or there are some fundamental differences they haven’t built in.)
Going back to the area map, this becomes a matter of translating the fog’s underlying heightmap into a nice nightvision-style greenscale overview of the world. The contrasting heights between the river valleys and the normal walkable areas pick out the geography so you can get a good feel for the shape of the landscape, but without, say, me having to render a straight top-down screenshot of the entire world. The more innacurate height-only view also preserves some element of mystery.
Then up comes the map interface and I can stack the black mask over the heightmap. Since the resolution of the heightmap is comparatively low (the Academy level is 192×192 and I’m getting the feeling that this is going to be a touch on the large side for my performance budget), there’s no need for anything in the way of zooming or panning, and it looks suitably crunchy to fit the theme of being a grotty satellite image. Then I translate your hero’s position on the fog of war grid to the same position on the map screen for a little indicator and we’re done!
I’m a bit suspicious because that was all too easy. Is Exon really at the stage of maturity where it’s stable and I’m just fiddling around the edges? The mind boggles.
Anyway, back to finishing off the tutoria– oh, wait! I need to add some more plant decorations!