mercredi 27 janvier 2016

Procedural planets (part II)


Many weeks passed while I was fighting with my piece of code. I'm quite happy with the recent progress I made, essentially on the fractal/noise code on GPU. As my first implementation of Perlin noise was working well, but definitely too slow, I switched on Wombat GPU perlin noise (Thanks to FluffyFreak for the link) implementation, allowing me to keep a decent framerate.

Among the many links I followed while searching informations about fractal and noising, someone wrote that "fractals are beasts incredibly difficult to master" (or something like that). And hell that's true, bloody true. and when you work on it on GPU side, you just enter in a Wooooorld Of Pain.

One of the most challenging point was to combine multiple fractals calls to alternate plains and mountainous area, which is something that I have not been able to get on my previous planet engine version, 4 years ago. I now have pleasant flat coast and plains, and here
and there I can see some isolated mountain ranges, which is more realistic than endless succession of hills and mountains as that was previously the case in 2012.

Another succesful milestone was to correctly manage collision between ships (or other physical bodies) and the planet's terrain. As the planet terrain elevation is computed only on GPU side, and the physics engine (Bullet) run only on CPU side, the only way to get it is to execute on GPU a pass rendering the elevation map of the portion of land located under the body, retrieve the result
on the CPU side, and submit it to Bullet API. I had big doubts about the efficiency of this method, so I was really surprised to see that in fact it works damn well !!

Finally I spent some time on shaders generating global planet's textures. To have a nice rendering I implemented some computations about temperature and humidity (as in SOA project), to get realistic colors combinations on global planet textures. As I play with shaders inputs for temperature and humidity distribution algorithms, I can get different types of earth-like planets : temperate and various climates (Earth), desertic and arid planet (Dune, Jakku), warm and luxurious vegetation planet, or planet in full glacial era (Hoth). See those screengrabs just bellow...

Next step is texture splatting implementation (detailled textures) for planet's terrain.


Aucun commentaire:

Enregistrer un commentaire