Here’s my first attempt at n-Body simulation of a galaxy where n equals 10,000 stars with the algorithm running as a compute shader on the GPU. Compute shaders are small HLSL-syntax-like kernels but can run in massive parallel compared to a regular CPU equivalent.
My simulation entails n2 gravity calculations per frame or 10,0002 = 100,000,000 calculations per frame at 60 frames per second – something that is quite impossible if I attempted to do it from the CPU-side even if the GPU was still rendering the stars.
Here’s the compute kernel (note I’m hosting the Gist on GitHub as a “c” file in order to display syntax hi-lighting. Readers should be aware the correct file extension is .compute):
Here’s my Unity MonoBehaviour controller that initialises and manages the simulation:
Planetary Annihilation (PA) from Uber Entertainment (UE) is an Early Access title on Steam currently available for purchase for $59.99 USD. Early Access means that one can buy the game now even though it is not finished with the notion that one is supporting the devs in their endeavours. In other words the title is pre-alpha. This can be a good or bad thing and for the complete run-down I recommend listening to TotalBiscuit’s discussion on Early Access.
I’ve been looking over the PA forums hosted on Steam trying to become a little more informed about this interesting title; a title which was tempting me to open my wallet and let the moths fly free. Sadly I was only to discover a disturbing pattern of arguably fascist censorship by the powers that be of anything negative that people have said or even requesting features that are not aligned with the current agenda. Most authors are expressing their concerns over the price of the title   .
Now I’ve not encountered anything like this since perusing Bohemia Interactive forums – specifically ARMA xx or Carrier Command Gaia Mission where many a poor chap would be banned; or a thread locked should one sneeze or forget to pay homage to the sacrificial guinea pig.
One thread on Steam got locked for asking for a OS compatibility feature. Did I mention there were only five (5) posts in the thread.  So much for an open discussion.
Steam Green Light clearly states:
Uber Entertainment states on the Steam Early Access Game notice:
It seems the benefits of an Uber Entertainment (UE) Early Access relationship are clearly one-way and quite arrogant at that; at least that is the perception established by the UE Steam moderators. The suppression of any negative discussions only serves to raise suspicion. It is quite possible that the UE moderators on Steam are not on the same level of professionalism as UE proper; if so UE could perhaps consider reiterating company policy with all those that represent it.
I for one shall take no part in the Early Access. I think I shall wait patiently for the game’s release where upon I hope to buy should the title prove worthy.
I wish them the best of success until then.
 “Came back to check on this old game. Lmao @ the price again.”, http://steamcommunity.com/app/233250/discussions/0/648817378131765891/
 “to much money”, http://steamcommunity.com/app/233250/discussions/0/648817378087864723/
 “I just bought PA and I feel cheated”, http://steamcommunity.com/app/233250/discussions/0/648814844869954342/
 “I will buy it if developers add Windows XP compatability”, http://steamcommunity.com/app/233250/discussions/0/648816742617053191/
 “The Minecraft Beta was $5….”, http://steamcommunity.com/app/233250/discussions/0/648814845030059149/
Compute Shaders in Unity3D are a way to perform general purpose computing on a GPU card. This is known as General Purpose computing on Graphics Processing Units or GPGPU. This means you can use the GPU to perform operations that may not necessarily have anything to do with graphics. e.g. protein folding simulations (ya I don’t know what that is either). Not everything is suitable, only those operations that can run concurrently and make use of the ridiculous amount of parallelism on a GPU.
Unity’s Compute Shaders are currently limited to supporting DirectX 11 only but I suspect this will change in the future when you consider that Unity’s aim is to be cross-platform. DX11 compute shaders is also known as DirectCompute.
Compute shaders syntax is just as per HLSL so you should feel right at home.
Compute shaders are great. Normally from what I understand, if you had a ton of stuff to manipulate well you had to do it CPU side then upload it to the GPU – a very expensive operation not to be done frequently.
With compute shaders you merely allocate the data CPU side and send it once to the GPU. From then on a little program (or kernel) updates the data for you and the output is passed to a shader for rendering. All without being touched by the CPU.
Here’s my first attempt at making a GPGPU galaxy modelled with 1,000,000 stars where the stars are moved on the GPU side of things. It’s looks more like a pizza at the moment, oh well. I can manage 60 FPS on 1920×1080.
I’ll follow up with a non-pizza looking galaxy soon and some source code as documentation on anything GPGPU is quite rare.
Maybe if we get enough of these GPUs we can find out what “42″ means?
Stuck at the annoying “Installing 0%” progress on the Xbox One (XBO) when trying to play these games for the first time due to a game-specific 6GB game patch (I’m not referring to the XBO Day One Patch)? This message appears as soon as you insert the disc but before it bothers to install from it.
Here’s a little trick:
- In XBO Settings either disconnect your WiFi or unplug your Ethernet lead to the box
- Sign-out of the XBO
- Now return to the home screen
- Hi-light your game/disk icon (BF4 or Forza)
- Press Start (or whatever its called now) on the controller
- Select Cancel Install
- Highlight the disk icon
- Click to start the install again
The game will now install from the DVD. When its ready to play, reconnect your network and sign-in. You’ll still need to patch but it won’t be as big nor get stuck.
This week at work we were visited by an agile expert who presented a workshop on agile task estimation techniques such as:
During the Planning Poker segment we were to use Fibonacci sequence poker cards to estimate a hypothetical project were the aim was to create a series of items made from folded paper including:
- Simple helicopter
- Paper plane
- Decorated plane
- decorated bird
- and so on…
Having made many Origami flapping birds, cranes, frogs, flowers when I was in my teens, I eagerly raised my hand when the question was asked:
“Has anyone ever made paper items before?”
Before I realised what was going on I was being passed a sheet of paper and told to make a paper airplane in front of everyone whilst being timed. Normally I don’t like this level of attention but it was all in good fun.
I started off well, remembering to fold the paper in half but unfortunately the only design that came to mind was probably the most obvious from my early youth. I continued to fold and crease, trying my best to keep it neat all awhile the imaginary tick-tick-tick from a stopwatch from afar encouraging me to go faster.
I kept at it till it resembled something that could fly at which point it was ready to give it its maiden flight. I picked it up, raised it high above my head and carefully tossed it with all the grace I could muster into the boardroom skyline, only to watch it gently fall to the table in exactly the same way that feathers don’t.
At which point someone said:
…and this is why developers should not test their own code!
To which we all including myself broke out in hysterics.
Work is proceeding on my space war game (SWG); it would be nice if I came up with a proper name for it but for now SWG shall suffice. For the past couple of weeks I’ve been looking into missile mechanics and shield simulation. For the missiles I simulate fuel load and consumption, albeit crudely, such that the missile has a limited flight time before tumbling into a fit of self-destructing acrobatics accompanied by a flash of yellow sparkles.
A work buddy suggested that I tackle force fields next and he had the good idea to use a ripple effect – the same sort of ripple effect you get when you drop a badger into a lake. There is a very simple algorithm that you can use to produce a variable heightmap for use in a water effect and thought this would be suitable for deforming my shields.
The Update method is called once per frame to update the simulation:
Here’s some shots of the ripple effect:
…and corresponding textured-mesh view:
Then of course I went to apply it to an ellipsoid and I was sort of stumped as to how to deformate a 3D object – something with no edges no less. Realising I was a bit of a buffoon, the obvious answer was not to procedurally modify the mesh via a heightmap but rather use the heightmap as an input into a parallax shader where we can fiddle with the surface normals thus giving the illusion of heightened depth. So I kept my code above for creating the heightmap but I just tossed the mesh modification.
I wanted my shader to be transparent so the alpha component is merely the heightmap value.
Here is a short video of the outcome.
 “2D Water”, http://freespace.virgin.net/hugo.elias/graphics/x_water.htm
Having moved from XNA to Unity3D I thought I would have a play at making a simple space game. I thought this would be a good exercise at procedural asteroid fields; AI; missile simulation and nebula effects whilst learning how to use Unity3D;
The following video shows my games work in progress from a few weekends in Unity.