Showing posts from 2020

More Economics

Simulating a Planet's Economy from Inception The prototype economic simulation was seeded with a 'pre-rolled' population and wealth, and aimed to create some kind of stable consistency up or down in growth, given a decent start.   Each planet began with generous conditions - say 3 billion population and 60 billion credits of wealth. The real aim for the game however is to simulate each planet's evolution from first inception, such as landing just 100 colonists and giving them a measly 1,000,000 credits to eventually (hopefully) build an entire civilisation from. Under the prototype code, most planets died out very quickly.   Tiny destabilising factors that reduced population would quickly reduce the population to 0 when only starting with 100.   The large costs associated with building and maintaining production infrastructure such as mines and refineries were overwhelming to begin with and easily overpowered small populations. To cope with this I've added populatio

Simulating Planetary Economics

Planetary Economics This week I started writing the galactic economic simulation.  Each game year the universe evolves and each planet's economy grows or shrinks based on factors such as government type, stability, population size and natural resources.  Eventually you'll not just be limited to governing planets by controlling tax rates and setting government policy, but by waging intergalactic warfare you'll be able to influence the economy and populations of your enemies in more nefarious ways.  You'll be able to bomb their infrastructure and destroy large population centers such as cities.  You'll be able to pirate their freighters in order to interrupt supply chains.  But of course, if you don't defend you own empire with ground based lasers, missiles, air defences, space defence shields, orbital laser grids and battle fleets, enemy civilisations will be able to do exactly the same to you. For now however, let's just start with the basic economic simulat

Moody Screenshots

I play Pegwars far more often than I work on it.   To be honest, most of the time when I sit down after-hours to work on the game, I simply don't know where to start.  I have so many 'backlog items' and ideas and the scope of the game is so huge that it's often really hard to choose exactly what to do.  The "burden of choice" as they say. So more often than not I'll simply hop in a spaceship, fly to some random systems in the galaxy, snap some screenshots and try to get inspired to work on some new feature or polish an existing one.  Indeed I've spent so much time 'searching for inspiration' that my current screenshots folder, which goes back to June 2015, currently has 5623 screenshots totalling 63.9GB... Since the new cloud shader went in, I've come across some really moody-looking systems and planets.   Systems with a dark green sun where you can barely see.   Blue suns, Bright orange suns.  Thick rolling clouds that reach down to the gr

Commander Kroton

"Infamous for its abundant micro-climates and irradiated soil, Asta is a planet that is relatively  unimportant." A city on the planet is perched around a field of luminescent crystals, providing it not only abundant resources but untold wealth and unsurpassed natural beauty. Commander Kroton sets his ship down gently in a garden just outside the city outskirts. He rents a modest but sunny apartment on the outskirts of a city situated within the planet's pink desert sands.   For a while the easy life prevails, but the novelty of a relaxing life of luxury soon fades and sure enough Kroton again feels the need to get busy. Leaving Asta on an underground mission to deliver medical supplies, sure enough he comes up against hardened defences "somewhere above Thefrel."  Not a problem thinks Kroton as he easily dispatches the threat with his pair of brand new beam lasers. He lands at a moonbase and offloads the precious blackmarket medicine for a wonder

Multi-Res Performance Optimisation for Atmosphere + Clouds

Volumetric Raymarching can be Very Costly Volumetric Raymarching can be very costly as many 100s of ray-marching operations are performed on the GPU each pixel for each frame.  A standard HD screen of 1920x1080 contains over 2 million pixels.    In the case of my atmosphere + cloud shader, this high fill-rate cost brings the game's frame-rate to its knees. In order to play Pegwars with cool new clouds in smooth realtime and iterate on the shader, I had to shade the planet and everything within the planet's atmosphere to a half-width, half-height render target.   This approach costs 1/4 of the fill-rate and renders around 4x faster, but the results as you can see are blocky and blurry.  Especially the building edges and the horizon lines are badly aliased : Multi-Resolution Shading As the atmosphere / cloud shader is very much fill-rate limited, either optimise the number of shader instructions per-pixel, or reduce the number of pixels shaded.  The goal for this technique is to

Clouds and Video

Finally, after around 3 months of hacking away late at nights, throwing up my hands in frustration and throwing away the first 3 implementations, I've finally made the volumetric cloud + atmosphere shader that I've dreamt about ever since starting this project. The shader uses raymarching to render a volumetric noise field, and a rayleigh and mie scattering simulation to provide the lighting.   Everything is unified - the atmosphere, clouds and planet lighting - so reddening sun at sunset will light the terrain as well as the clouds, clouds cast shadows on objects flying beneath them, the atmosphere and clouds also render into the ambient cube-maps, meaning they reflect on objects and on water too! Every planet has unique procedurally-generated cloud and atmosphere properties such as particulate density which impacts scattering, climate maps to designate where clouds are and which type.   The clouds themselves have programmable features such as height ranges, water density

2019 Progress Retrospective

Happy 2020! Games take a lot of work, especially ones like Pegwars with the enormous scope of being a universal sandbox.  Although I haven't made any blog posts in quite a while, I have indeed been working hard throughout 2019 on fixing many bugs and implementing various new features. Highlights for the year are : - A beautiful procedural volumetric cloud system, fully integrated into the atmosphere shading - that unfortunately is still way too slow and so has been removed for now.  These clouds just have to go in one day, they add so much to the game and I really must work out (hopefully in 2020) how to make them fast enough to be included for good. - The UI has been rounded out and polished, bringing much of the meta-game into play.   Markets, Shipyards, the player's galactic Empire are now fully represented and playable.   3D Views are incorporated into the UI. - Combat is finally fun, mainly due to the introduction of gimballed lasers.  Prior to this it was just t