Monthly Archives: February 2013

.Net Random numbers and portability

Working on fractals and procedural generation, I faced an “interesting” problem…

 

.Net Random does not guaranty to produce the same output with the same seed on two different platforms (Framework implementation)… See:
System.Random

 

In most cases I need the result to be the same across platforms (I need to generate the same landscape, event if I change the machine I am working on)… So the only workarounds are to override System.Random or implement my own random number generator.

For a good random number generator example (with tests and proof), see:
Simple Random Number Generator

 

For the design part, I have abstract the System.Random methods with an interface IRandom then developed a “portable” random number generator:

Random design

Random design

 

Some unit testing then go 😉

Advertisements

TODO: XCOM: Ennemy Unknown, le retour.

Analyse de XCOM: Ennemy Unknown version 2012.

XNA, continuation… And free wheel until replacement.

As I said it, it was artistic vague about XNA…

 

Now it’s not any more really:

http://www.gamasutra.com/view/news/185894/Its_official_XNA_is_dead.php#.URAnNnrLSHt

On the other hand, with Windows 8, its Windows Store and its novelties, it is certain that Microsoft turns to ” the future ” (next Xbox, more and more PC turning under Direct3D11, multi-platforms Xbox Play…)

Well, XNA “still works” (i.e. we can display games on Xbox Live) under Xbox 360, Windows Phone 7.8 and Windows Phone 8… Still works under PC and apparently we have at least one year of visibility.

But that makes a small plucking all the same… It was an attractive Framework. Later it’s not as if we were not used to baby’s thrown with bath and bathtub on behalf of Microsoft 😉

Personally, it’s not going to prevent me from pursuing my projects on this Framework, while looking what takes place on the side of C ++/ Direct3D or C#/XAML in Windows Store. I would think it over when the successor will be known (or not).

 

Wait and see.

Postmortem: Old .Net project

Back to 2006, I start to work on a personnal game project involving C#, .Net and Managed DirectX.

The goal was a X-COM/Master of Orion/Prevateer cross-genre “clone” (yep… perhaps I should clarify later 🙂 ). No need to say that I wasn’t able to end that game 😉

But during the process, I have worked on interresting topics:

  • Procedural generation;
  • Parrallax mapping;
  • Atmospheric scattering;
  • Scene Graph;
  • Xml DataSet.

 

In fact the most important thing I have worked on was the procedural generation based on Perlin noise. The aim was to generate planets surfaces, clouds, etc. using fractals methods (mainly based on Fractal Brownian Motion, or fbm).

Explanations on Perlin noise can be found here:
Noise Machine

Explanations on fbm and landscape generation:
Real Time Procedural Universe

Here some exemples of the result.

Planet and its moon

Planet and its moon

Another planet

Another planet

Another planet

Another planet

The basis for me was a seeded 3D fractal noise generator (with the same seed you generate the same output), the said Perlin Noise, use it with fractal methods (frm and like) to generate a heightmap (surface storing the result for each x/y coordinates).

In a second time, I generate a texture representing the surface of the planet using the generated height against a texture atlas (depending on the climate of the planet).

In a third time, I generate a normal map (floating point texture storing the normal vectors) based on the planet texture and the heightmap to be used by the parallax mapping shader to simulate depth by displacing texture coordinates.

Description of the Parallax Mapping:
Parallax Mapping

I also generate cloud cover with that tool, using this method.

Procedural Texture

Procedural Texture

Normal map

Normal map

For the setup of the scene graph reprensenting the different star systems, I use a .Net DataSet saved as a xml file. The DataSet allow to define tables, collumns, primary keys, foreign keys, so you can use it as a lightweight database (it have to stay small, everithing is loaded in memory). Nothing complicated (the model is strongly inspired from Master of Orion II 😉 ).

Database editor

Database editor

Star map

Star map

 

In conclusion:

 

By using procedural generation, I was able to fill a large world with unique planets and that was cool 😉

The main frustrating point for me was the performances. By the time of the project, fractal generation wasn’t fast enough in .Net to process at runtime, so it was limited to the editor part to generate content.

I will continue to investigate in procedural generation and perhaps more sophisticated methods (like Biomes, etc.).

%d bloggers like this: