Author Archive

MyAir Android Tablet App Temperature Bug

2017/11/23 Leave a comment

There is a strange bug in the current version of the app. If I set the MyZone temperature, it suddenly changes the setting with a value 3 degrees cooler!

No wonder my power bill is high



Categories: Uncategorized

n-Body Galaxy Simulation using Compute Shaders on GPGPU via Unity 3D

2014/02/01 12 comments


Following on from my prior article about GPGPU, I thought I try my hand at n-Body simulation.

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.

It’s important to remember that conventional graphics including those in games, do not use GPGPU for star fields.  Generally this is accomplished by either manipulating the star coordinates CPU-side and uploading to the GPU every frame or so; or utilise a small shader that renders a pre-uploaded buffer of stars that may or may not move over time.  In any event, it would be unlikely to perform n-Body simulation using conventional non-GPGPU means due to the slow performance.

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:

Censorship on Planetary Annihilation Steam Forums?

2014/01/25 Leave a comment

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[4]. Most authors are expressing their concerns over the price of the title [1] [2] [3].

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. [4] 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.

[1] “Came back to check on this old game. Lmao @ the price again.”,

[2] “to much money”,

[3] “I just bought PA and I feel cheated”,

[4] “I will buy it if developers add Windows XP compatability”,

[5] “The Minecraft Beta was $5….”,

Categories: Games Tags: ,

GPU General Purpose Computing with Unity Compute Shaders

2014/01/16 3 comments

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?

Categories: Development Tags: , ,

(Solved) Battlefield 4 or Forza Install Problems for Xbox One

2013/11/23 2 comments

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:

  1. In XBO Settings either disconnect your WiFi or unplug your Ethernet lead to the box
  2. Sign-out of the XBO
  3. Now return to the home screen
  4. Hi-light your game/disk icon (BF4 or Forza)
  5. Press Start (or whatever its called now) on the controller
  6. Select Cancel Install
  7. Highlight the disk icon
  8. 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.

Categories: Games Tags: , ,

The Programmer and the Paper Plane

2013/03/23 Leave a comment

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
  • bird
  • 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. Smile

Categories: Development Tags: , ,

Heightmaps and Force Fields

2013/02/23 Leave a comment

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[1] 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.

[1] “2D Water”,

Categories: SpaceSim Tags: , ,