I am super excited to present you my biggest project ever! I have been working on it for 3 years in my free time and I feel like I can share some of my progress!
This is Cosmos Journeyer:
Cosmos Journeyer is a procedurally generated universe with a virtually infinite number of star systems. Each system has a set of planets that can entirely be explored on foot (except for the gas planets of course).
The project features volumetric atmospheres, planetary rings, dynamic clouds, planetary shadows for eclipses and asset scattering on the planet’s surface.
Moreover, star colors are based on their surface temperature just like in real life, and star distribution in the universe also follows the distribution of our own universe.
Beyond stars and planets, I also have neutron stars and blackholes! (the lensing effect has some bugs but I am working on it haha)
Now, I use regular instances for rendering as this allows for individual control of the instances, which is important for individual rotation and applying floating origin.
Instances are spawned into chunks around the camera in a progressive way in order to avoid stuttering.
The physics bodies are only created for instances close to the camera, saving a lot of performance (though creating physics bodies can still create some stutters due to the JS / WASM boundary I think).
In order to have rotating asteroid across physics and non-physics, I also store 2 arrays: rotation axes and speeds. Non physics asteroids rotate using the rotate method in world space, and physics asteroid are given an angular velocity equal to axis * speed. This creates a seamless transition between the physics and non-physics world.
I found an optimization for asteroid fields that can be applied to any instancing system using Havok.
Basically the stuttering is caused by creating a new shape for each instance, thus transfering the vertex data through the WASM / JS language boundary, which takes too much time.
Instead I can create the physics shape once for the asteroid model at startup and reuse it for the new instances: we no longer need to cross the boundary.
This is not perfect because physics shape do not support scaling! This means that in order to reuse the shapes, I lose freedom in scaling.
That does not mean that all asteroids must have the same size: for each asteroid model, it is possible to clone it and scale it at startup in order to create 10 different scaling variants.
Instead of using per-instance scaling, I use an array of indices to know the base asteroid model variant for each asteroid instance.
This still solves the stuttering issue as everything is precomputed at startup, and at the same time we still retain some scaling variations.
The video quality is not the best, because I recorded on my laptop but it runs at 60fps with no issue when OBS is not recording ^^
I simplified the setting so that it is easier to see what is happening (no rotation and such). Chunks are loaded and unloaded depending on the distance to the camera. The different chunks are visible with the wireframe boxes I added.
Inside those chunks, asteroids are instanced from 2 models. To achieve different scales, I created copies of the original models at different scales so that I can precompute their PhysicsShape before starting rendering the scene.
Physics bodies are only created for asteroid close to the camera, which does not have any significant performance impact thanks to shape reuse. Asteroids with physics are highlighted in white using the PhysicsViewer .
Possible performance improvements include using another data structure to avoid looping over all asteroids when determining if a physics body should be created or destroyed.
Thanks UI is a really important part of the experience, but it is never the funniest part to develop haha
And yeah Times New Roman did not fit the Sci-Fi setting very well , Nasalization ftw
The website is still using an older checkpoint of the 1.9 version because I want to release and polish space stations alongside exploration and trading gameplay all at once (maybe at the end of august / early september). But everything is on the main branch of the repo if anyone is curious
I was reading too fast and I’ve read “to release a polish space station”… My first thought was WTF?! What else have I missed not watching the TV nor reading the news for a while?! Poland has a space station. Fuck me dead! Ok, so polish …
Who knows what Poland is up too with their secret space program But who knows if I add voice lines to station operators, some could definitely be polish!