Friday, 31 May 2019

Level Design And Level Redesign And Level Redux

Environmental level creation continues in earnest.

Level 4 is a grassland, inspired by the Asian Steppe. Originally the grass was going to be green, but the previous level was predominately green, so for variation I changed it to a more prairie yellowish-brown.

 The Steppe, home to deer-monster, Wendigo-type, thingies ...

Grasslands, by their very nature are somewhat ... well, bland. There's a lot of grass and low rolling hills with more grass and not very much else. The level is mostly wide and flat open spaces, with high, dark, rock walls to limit the playable environments outer reaches. I added a few extra rock outcrops to break up the vast expanse and created a central "hub" mountain which dominates the centre of the map to create a vaguely circular map with a lot of open space. To disrupt the near constant flow of grass I threw in a few autumn coloured bushes which help add variance to the monotony, and clumps of violet flowers for a colour deviation. The violet flowers are all clumped around the central mountain, whilst the red and yellow bushes tend to crowd towards the outer edges of the map. This helps the player orientate themselves a little to their position in the wide expanses.

Whilst planning level design I realised that as the game progressed, the levels were getting too big too quickly. I do a lot of heavy playtesting - because, well, no one else is, so it's the only way to spot issues with things. By level 3 I was getting lost quite easily in the various narrow alleyways of the canyon level.

Whilst developing the gameplay and enemies for each level, I had been using my test level with grid textures for each of the consecutive level maps. This meant that I had always been testing in the same space. When I started to create the actual individual levels I had multiplied the size.

I went back and redesigned the first three levels, first cropping them into a more square shape that would fit inside a 512 pixel heightmap rather than a long thin shape that spilled into a 1024 pixel one but didn't use up much of the available space. This saved on the amount of terrain that the engine had to render and precompile collision for, which in turn saved on the number of polygons that had to be drawn.

The original test level had later become the basis for the first level. This map has a traversable area of twelve percent. Originally I had started by doubling the size for progressive levels but this now obviously far too much. Going back, I redesigned the second and third levels with a formula to increase level size based on around 50%-70% of level 1 size. Thus level 2 now has a traversable area of >150% the size of level 1 at ~20% of the 512 pixel heightmap, and level 3 is >200% larger than level 1 with a traversable area of ~26%. By contrast level 3 has an area of  ~33% that the player can traverse.

Smaller heightmap sizes obviously reduce the amount of renderable terrain triangles and collision calls. For the first time I also used the "remove terrain tool", creating holes in the terrain in areas which the player would certainly never be able to see on-screen. This helped reduce the renderable area further.

Thick foliage.
Thinned foliage -50% polygons. Textures with less leaves show more transparency.

In the spirit of creating complex but also lean environments to reduce overhead I had another look at all my foliage. Whilst grass clearly needs all of it's polygons, I thought that I might be able to save a few on the bushes as the leaves near the undersides are not all going to be visible, obscured by those on top. I selected all the polygons that could be seen from directly above and deleted the rest. Depending on how thick the textures are with leaves, this thinned the viewable foliage somewhat, but for a saving of a whopping 50% polygons. Bushes are there to add movement in the wind and prevent the levels from looking barren, they're not there to hide the terrain beneath them so being more see-through is not a problem.

I tried the same idea with trees but the saving were so small - around 10% - that it didn't seem worth bothering with, so I left them as is.

And that, has been the month of May, 2019. Also the local internet exchange blew up and I was reduced to living a stoneage existence, devoid of memes, waifus, and all the important work related sites and indie game and engine development discord channel I rely on for day-to-day information about work.

In the meantime I rewrote various bits of code related to spawning the player in more open areas, reworked some effects and did manage to have a little play around with the (PBR) Physical Based Rendering package due for release with the next update of the engine.

PBR coming soon ... ish ...

Not entirely sure which bit of the development cycle I will tackle next. I might continue with level building as I am now 40% complete, or I might go back into 3D character modelling and finally replace that yellow placeholder cube with an actual player character.

In the meantime, have a look at some gameplay testing for level 4, The Steppe.

Tune in for next month's exciting instalment of the game development that never ends!

Monday, 29 April 2019

Placeholder Game Level Finally Replaced With The Real Thing

Well, it's been long enough, and in fact seems like forever, that my blank, grid box test level has been on show - but no more! We now have actual game play in actual game play levels!

We also still have Placeholder Player Cube ... but, one thing at a time ...

Starting with level 1 the environment is a dark and rather neglected graveyard, where the dead sleep peacefully ... at least until the player turns up and annoys the hell out of them all (DEEPEST LORE).

And here is a rather long video of the whole thing in action, save for the obviously missing parts of an actual player character and level boss, both of which are currently still placeholder cubes.

But now that we are actually into level design, I am moving quite fast and this month have managed to produce a whole 3 finalised levels.

Behold level 2, The Primordial Forest at dawn, home to ancient plants and even more ancient and decidedly angry velociraptors ... so angry some of them shoot fricken laser beams out of their fricken heads.

And here's a slightly shorter 7 minute video of the level in action. I noticed afterwards that my dinosaurs where not exploding properly and should have been throwing more splatters about. However I had a wrongly named datablock and so the extra gore was not showing up. This has since been fixed.

And finally we have level 3; which I based loosely off pictures of Wulingyuan canyon in China, where the canyon has steep sides of light coloured rock with darker, green vegetation hanging on to every conceivable flat area.

And here is a slightly more reasonable 2 and a half minutes of game play.

In the more cramped confines of the canyon level, I noticed that the enemy spawning often grouped up together at one end of the screen. To create a more even distribution of enemy starting points, I wrote a little algorithm to target the player with the least nearby enemies and then find which cardinal direction (north, east, south, west) had the least enemies and spawn new ones there. This helps to prevent the enemy all starting to one side of the player and spreads the distribution of new enemies out more evenly.

So, their we go. Indie game development is painfully slow, especially for the One Man Army, but once ready to start on creating the actual environments, I have managed to complete 3 levels in one month. That's 30% of the levels done.

Next up, more environments to complete before seeing about replacing the placeholder cubes of the player and boss characters.

Sunday, 31 March 2019

Goodbye Green Grid, Hello Darkness My Old Friend

I took a break from worrying about the minutiae of cat ears to do some level building. It's been a while - in fact around 4 years - of having a basic and rather blank grid for level 1. This has now been replaced with an actual level 1, containing ... you know, level 1 stuff.

 Old And Busted: Not Exactly Grey Box as Green Grid Box

New Hotness: Actual Art Assets 
This required actual models and textures and stuff, so I opened the long dormant folder of 3D models and 2D texture images which I have collected over the last nth years. One thing which I did get years and years ago was Forester Pro - a procedural tree and plant creator. Not only can you create a ton of different types of trees but create variations with a single click of a button. It automatically adds vertex paint which is then used in-game to add the shader effect for the wind. You can also add or remove elements like branches and leaves, though I did find that the save file dies horribly if you go too much off template. Never mind, just export out as DAE format that the Torque3D MIT Open Source Game Engine that I use, and of course can also be imported into Blender3D for making changes to the model more easily. Here I used the normal editor so that the foliage planes face upwards to avoid bad shadowing artifacts. I added an empty high above and had the normals aim for it using Directional mode, that way each plane gets a unified but still individual shadowing.

Wind Effect

Also good for grass 

 I have 10 levels planned, and the enemies all modelled and animated, though not the bosses. So I figured that I would need a few trees. One thing that I found was that the standard black alpha on textures didn't look very good. There is a free demasking tool which writes in colour information but instead I tried using different colours of the image to see what effect they had.

It transpires that alpha colour is important ... even though you can't see it ...

I also had a plant pack for Forester Pro and after exporting a few plants I amalgamated the textures into an Atlas texture to save on drawcalls, and created multiple plant objects to save on instancing.
Not seen here, mixed plant meshes

My next issue was lag. The first reason was some terrible maths which I had written and my code was attempting to spawn 1700 enemies all at once when it really only want 7. Yeah, that sort of thing is going to bring the computer core down to a shuddering halt. Next up was collision. I had set the size of terrain squares down to 0.25m which created a rather high 1568 collision calls per player, Ai and dynamic object. I played around with different settings and finally settled on a square size of 1, which seemed to give good definition visually to the terrain and only cost 128 collision calls which was a rather saner amount. SquareSize 2 would have only cost 32 calls but I preferred the look of 1 square per metre.
When you attempt to use ALL THE COLLISION CALLS

One thing which I had not previously thought about was the lighting and shadowing. Normally the camera looks through the environment and the shadows fade and lose clarity the further away they get. However using a top-down/isometric(ish) view meant that I could see shadow splits drawing across each other. A lot of fiddling with shadow settings later I finally got something that looked decent and transitions between shadow map splits were not really noticeable.
The joys of trial and error shadowMap creation with the helpful PSSM Cascade Visualizor debugging tool

As my first level is a graveyard featuring a very lazy mouse who is supposed to be the caretaker but rather neglects her duties in keeping the place tidy for her customers - level 1 enemy, the dead (DEEPEST LORE!) I opened up the old graveyard art pack which I bought years ago. Some of the model seem to have been rather hurriedly put together with a lot of opening faces - which is the sort of thing my OCD really doesn't like, so I spent a fair bit of time fixing them and amalgamating the textures into single Atlas textures for those big savings on drawcalls.

Blender3D's decimation tool got into the spirit of spookiness

I had noticed an issue with the terrain becoming washed out when the level reloaded. After much hunting around for bugs in the code I discovered that I had accidentally changed the file format for saving the terrain main texture to a low definition jpeg of only 90Kb. The default is a high quality DDS image so I must have been playing around, not noticed the difference in texture because it only updates on reloading the level, and then just forgot about it. Whoopsie!

Adding grass meshes that sway in the wind make the flat texture look a lot better

So, next up is furnishing and finalising the rest of the level and making it playable. The either on to the other levels or back to modelling catgirls.
Head pats!

Thursday, 28 February 2019

Lurgy, Ninja Type Dudes, Parallax, Fat Assed Robots and Cat Ears

Last month was all about tentacles. A swarm of tentacles is a fairly big thing, that acts as a movable barrier which can corner an unwary player and slap the hell out of them. One thing that I noticed was that they can turn on a dime, effortless switching direction, which for a big unit looks rather odd. See video below:

Testing Terrifying Tentacles!

So I went off hunting through the movement and aiming code to make the AI use a system similar to the player for rotations. Initially I spent all my time looking in completely the wrong place ... something which seems to happen a lot ... before finding the correct file class and adding a delay that could be set via the objects datablock. This way, small, nimble enemies can turn faster, and hulking great things like tentacles a lot slower.

 Turn Speed; fast, medium and slow

Of course things couldn't just be simple and I quickly realized that my entire AI attack routine was designed around the length of each enemies attack animation - and very few enemies share that data. So an enemy would turn to face the player head on, then start their attack animation and then ... well the player was miles away and out of range. To prevent this obvious pause in starting their attacks I had to write a little snippet of code that took each AI types turn speed, angle required to turn and time to swing at the player into account to make sure that when they landed their blow, it would be at the optimum moment to actually hit their target.

All whilst I was attempting all of this fancy maths malarkey, I was riddled with the vile pox of the lurgy, with puss and ooze coming out of all corners because it's winter and stuff.

Being ill really hampers your ability to into 3D vector math ...

This brings me on to modelling the last standard enemy for the game. I still have all the bosses to do (cries into hanky), but the game's rank and file enemies are not complete. Having come up with a rather interesting shader of floaty goo a bit like a lava lamp, I settled on a spear wielding opponent that looked a bit Ninja-ish and called, for want of a better description, the Shadow Sprite. I added that triple eye motif that I see in a lot of Japanese stuff as a signifier of Buddhist mysticism - like that guy with the flour bag on his head with the triple eye motif on it for ... I don't know ... reasons I guess. Having a spear gives a longer than usual range melee attack but also has a narrower angle. Cue me having to go back create new code dealing with attack radius ... radiuses? radius's? radii?

Shadow Sprite surprise!
With the final mob enemy for level 10 completed I set about testing "extended play" aka "endless mode" and found that the difficulty level ramp up quite nicely so didn't really have to tweak my challenge code. I also added a visual effect for deceased radioactive enemies to make it more obvious to the player that there is danger. Some of the enemies spawn as "elites" of various kinds and radiation is one of these. Now when I radioactive enemy is killed they leave a warning sign that that area will cause damage if the player enters it. This only lasts for three seconds.

"Ra-di-a-tion. Yes, indeed. You hear the most outrageous lies about it. Half-baked goggle-box do-gooders telling everybody it's bad for you. Pernicious nonsense! Everybody could stand a hundred chest X-rays a year! They oughta have 'em, too." - Repo Man, dir. Alex Cox, 1984

Having a break from modelling I had a look at how the PBR branch on github was doing. Rendering really isn't my thing and material systems probably even less, so I just nodded a lot ...

No idea what's going on but debugging does look pretty

Having spent rather a long time on animation and characters and the like, I went back to trying to remember the work-flow for materials and in particular parallax. I found that a rather enormous 12.7mb 2K normal map texture with a heightmap in the alpha channel didn't seem to have much better quality over half the size which only weighed in at 2.4mb, which is quite the saving for VRAM.

2048px 12.7mb top, 1024px 2.4mb bottom. I can live with that.

Finally I got round to thinking about the yellow placeholder cube, who has represented the player for nth years of development. Filled with horror at the thought of actually having to paint armature weights and rig a character from scratch I booted up the medically resourced makeHuman with the intention of exporting a basic mesh character to work on in Blender. I quickly found that COLLADA export is not that friendly to bone angles with everything defaulting to just one direction rather than following the skeleton, but FBX preserved the bones correctly.

As a test, I had a play about with the sliders to see if I could make a physical match for the 2B model from Nier Automata. Surprisingly only the pinched waist being beyond the standard sliders from the model silhouette I was working from, and the only maxed out sliders were the butt ... which is kinda understandable, considering this is the robot with the highest polygon count arse in gaming.

 All the polys ...

 When you spend all the VRAM on polygons for the robots butt, and can't afford HD textures on the scenery ...

Anyhow, I gave the proportions I wanted to my base mesh, learnt a bit about exporting and then started customising it in Blender. I've started off with a fairly high poly mesh until I decide on what I actually want so that the high and low poly versions will (hopefully) look the same.

I seem to have spent an inordinate amount of time tweaking cat ears into just the right angle even though I am fairly sure it doesn't matter, but hey OCD and all that ...

So, that's a start on a base model for the player. The idea is to have a high poly model for intro and cut scenes, as well as an animated "Doom" style bust view in the GUI where placeholder banana currently is. However I do kind of think that it might be a bit small for an animated character to be pulling faces from. Once I finalise what the character needs to look like from the rather hazy description I have in my head and multiple character types required, I'll start on the low poly version that will actually be in the centre of the screen, under the player's control.

February has ended and it is officially Meteorological Spring.

Thursday, 31 January 2019

Terrible Tentacle Terror!

So, I managed about 3/4 of Dry January before falling off the wagon. Not a record by any stretch of the imagination but there was a solid few weeks without any booze in there.

Back to gamedev ...

In the last month of the last year I left on the nail-biting cliffhanger of ... modeling yet another enemy. So yeah, 3 years in, and the player is still a placeholder cube ... anyhow, back to that enemy character.

 Tentacles, in gloriously awkward to animate 3D

Tentacles. The scourge of cartoon schoolgirls everywhere (okay, only in Japan - literally nowhere else in the world, it's just Japan).

Cthulhu moves to Japan ...

It turn out that one thing a big bundle of psuedopods has trouble with is avoiding clipping into and colliding with each other when you use the minimum amount of keyframes in an animation. Tentacles turned out to be not that difficult to animate, pose into a nice, organic tentacle shape one way, then n frames later and another keyframe the other way. Let Blender 3D do the "tweening" (which is an animation term apparently for automated process of animating between keyframes) and then tweak the middle frame if it looks funny. Unfortunately there was a lot more frames which ended up needing "tweaking" to stop the writhing mass of extremities becoming a jumble of clashing appendages.

Did I ever mention that everything in game dev takes way longer than it would first appear to? Oh, every blog post? Yep, right ...

Placeholder cube getting snug cuddles from tentacles

Anyhoo, eventually said tentacles where animated, calibrated, datablocked into actually enemy AI and unleashed into a game level for tweaking - and boy did they need some tweaking. Player ended up squished rather quickly, then it was a case of tweaking data from too easy to too hard until it met in the middle somewhere.

Big tentacle, little tentacle

During testing I noticed an issue. Every so often a tentacle would fall from the sky past the camera to where it was supposed to be in the XYZ of the game world. I've seen this happen with other models  before and each time I fixed it and then forgotten what the cause was. The last time I fixed it I remember thinking that next time I will know the cause adn solution ... except for I have forgotten it again ...

I went back and checked through my written notes on exporting animations and then through all my "how to" forum posts ... and it looks like I didn't record the reasons anywhere. It's got something to do with animation or COLLADA format export - but that's as good as my memory is helping right now ... so a bit more testing and tweaking of the model and exporter is required,

Tentacle surprise!

I also made a whole load of really cool effects, like spawning and fleeing and attacking - but in actual playtesting there was so much going on that a lot of it is easily missed and the constant rattle of tentacles bursting through the ground gets rather annoying, so I plan on simplifying the audio and also some of the particle effects.

So, that's pretty much January covered. There was some other maths related stuff concerning getting player evasion to trigger the way the player is moving when it's different from the way they are facing - which ended up being more difficult than expected because I forgot to take randomized camera rotation into account on spawning and also forgot about normalizing vectors in 3D space - but it was mostly tentacle animating.

To be continued ... possibly indefinately at this rate ... naw I'm just kidding, I'll ship before Half Life 3.