tinySceneGraph

tinyScenegraphs's Weather Plugin


Friends of tinySG,

the Volvo Ocean Race started for its 12th edition back in October 2014, an around the world regatta with seven boats competing for the trophy. Beside the real boats there are about 180,000 virtual boats performing the same legs in a simulated environment, with the same boat characteristics and daily weather data and as the real yachts.
Because the simulation uses real, almost-live weather data, virtual skippers can take advantage of any weather forecast they can get their hands on. After having suffered on some really bad in-game forecasts (I'm the virtual skipper of the Naughty Crab), I decided to development a weather plugin for tinySG's scene editor, pulling current as well as forecast data from web weather services like openweathermap.com or WorldWeatherOnline.com.
The image above was created from wind data data taken on the 9th of December. It almost seems that Madagascar is desperately required to keep the wind from blowing the sands of Africa into the Atlantic ocean.

Animating wind particles on the GPU

Just moving particles according to a velocity field is so simple that I dropped the idea of using a compute shader for this task. Instead, the vertex shader visualising wind particles also does "en passant" updates of particle positions while rendering. The plugin maintains particle positions as pairs of latitude/longitude values in a shader storage buffer. The vertex shader picks those coordinates up and transforms them to cartesian coordinates for display.

Amongst the shader inputs, a 3D wind texture encodes wind speed and direction. While a 2D texture would suffice to represent a grid of values, the 3rd dimension offers an option to store multiple steps in time. The real nice thing is that sampling the texture provides hardware support for interpolation in both space and time! But make no mistake - interpolation of wind angles leads to the same artefacts as described in the techguide on vertex attributes when the angle changes from 359 to 001 degrees (the texture actually encodes direction vectors instead of angles to work around this issue).

Each particle's position is updated by adding the wind direction vector to it's polar coordinates, weighted by the wind speed, before control is passed on to a geometry shader: The geometry shader receives the particles position and wind direction as it's varying inputs and converts particle animation using fragment shader the point data to a line, showing the actual wind direction. Finally, the fragment shader uses the wind speed to colorise an blend the particle trajectories in hsv color space.

The performance of modern GPUs amazes me with every new shader I write. For tinyWeather, it hardly matters whether you throw a 100 or a 100,000 particles at a (high-end) GPU. The big core-i7 machine with an AMD FirePro W8000 still renders 100,000+ particles at 1000+ fps. However, a gaming laptop with a core-i5 and a GT750M drops down to 45 fps at the same particle count. Looks like memory bandwidth is key for the tinySG shader stages. Click on the image on the right to see a short video showing the shader in action.

Loxodromes vs orthodromes

The weather plugin has an additional UI tab for statistics of the Volvo Ocean Race. There are functions to measure distances and to display paths of a set of yachts.
As for the measurements, the shortest path between two points on a sphere's surface is described by an orthodrome: It is the intersection curve of a plane with a sphere, with the plane containing the sphere's center. In planar projections, these straight lines on the spheres surface actually occur curvy due to distortions introduced by the projection. However, a straight line in a nautical chart intersects the grid of latitudes and longitudes with a constant angle. This type of curve is known as loxodrome. They are always longer than orthodromes, with the exception of longitudes and the equator where they are both the same.
The image to the left shows distance measurements in 3D using orthodromes.

Finally, the official web site of the Volvo ocean race publishes position reports of the real boats in regular intervals. The plugin allows to visualise trajectories using this data as simple polylines. Combined with the positional notes a virtual skipper takes, you can analyse how well you are doing compared with the professionals.

Keep rendering,
Christian



Acknowledgements and links:

  • The Volvo Ocean Race offers a free-to-play virtual regatta, competing with the real yachts taking part in the race. Virtual weather conditions are updated twice a day and match the real weather.
  • tinyWeather sources it's weather data from either openweathermap.com, worldweatheronline.com or nfdf.com.
  • A nice 3D weather visualisation and forecast service is available on meteoearth.com.
  • The earth texture is by courtesy of NASA.



Copyright by Christian Marten, 2009-2015
Last change: 24.03.2015