Posts

Multi-Res Performance Optimisation for Atmosphere + Clouds

Image
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...

Clouds and Video

Image
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, wat...

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.  P...

Rendering Nebulae

Image
New Nebulae Recently I began replacing the old particle-based nebula standin with proper volumetric nebula shaders.  The nebulae need to be many and varied, and so I want to procedurally generate them like the rest of the universe.    After being introduced to some awesome volumetric nebula examples on ShaderToy, I thought I'd too have a play around with ray-tracing a noise field to create procedural nebulae.   The end result looks something like this : Ray Tracing a Noise Field The general algorithm for rendering a volumetric noise field: - for each pixel on the screen, cast a ray from far to near (or near to far based on your needs) - at each step, accumulate density by looking up procedural noise functions - in this case, a fractal brownian motion function. - return the accumulated density, to be manipulated for the final pixel colour. This is a very basic implementation of volumetric ray-tracing, and runs very slow for the output quality. ...

Planetary Installations and HQs

Image
I hope you all had a great 2018!  I've been hard at work on Pegwars whenever I get the time, which is not as often as I would like, and have made some great improvements that I'll detail over the coming weeks.   One such feature I have working now and would like to present a teaser of is Planetary Installations. Planetary Installations Imagine purchasing and equipping your frigate with some heavy planetary bombs, and seeking out an enemy planet. Hypering in, you orbit the planet with eyes out cockpit window for any valuable targets - depots, airports, perhaps even the enemy HQ.  Evading the orbital defences you plunge into the atmosphere over your target, only to discover ground-based defences surrounding it are now opening up on you.  You dodge and weave fearlessly through the laser artillery fire until expertly maneuvering into place to drop your bombs on the perfect trajectory to ultimately destroy the enemy installation, causing immediate political and e...

Gameplay Concepts

Image
Over the last 6 months I've been working almost exclusively on new adding gameplay elements to enrich the overall game environment.  Some are general concepts, applicable to the main universal sandbox.   Others are more specific and fill out the lore of the gameworld.   Others such as missions, factions etc. are still to come. Here are the last 6 months worth of gameplay concepts, in alphabetical order. Air Resistance When ships enter/leave atmospheres they encounter air resistance.   This is imparted as a drag on the physics of the ships, with the primary effects being reduction of top speed, and dampening of flight controls. Ships may or may not come with wings, be careful flying into a planetary atmosphere without wings! The intention is to impart air resistance to the damage model, causing ships entering an atmosphere too fast to burn up and be destroyed. Target speed is set at 1000 km/h, but due to air resistance, it is currently max...

Ship Dashboards

Image
Here's a quick look at a prototype dashboard for spaceships.   Like everything else in the game so far, the artwork is 100% prototype.  In Pegwars, spaceships are like future cars, so I've modeled the prototype from an 80's classic sports car.   The 80's really was the bomb, I love it how car designers tried to get so futuristic for a period of time. The gauges, from left to right : - Hull Integrity - Shields - Engine Revs - (Top) Set Speed - (Bottom) Actual Speed - Current Gravity Forces - Power Usage - Power Available Left and right of the dash will be a couple of MFD's (multi-function displays) that the pilot can customise to display whatever info they like. Beneath the speed readouts are a couple of icons that I haven't used yet, but the idea is they will function as 'check engine' lights much like in cars today.  Expect that when you are under heavy fire and damage to see a whole row of bright red icons indicating your ship is about...