Space Engine - The Universe in the palm of your hand
My God, it's full of stars!Arthur C. Clarke
Which of us in childhood did not dream of “plowing the expanses of the universe,” like Captain Picard, strolling through uncharted planets of distant worlds, meeting the dawn of binary or triple stars, immersing in the atmospheres of gas giants, dropping ships into black holes? And I am no exception. Of course, partly this dream was embodied in books, films and Elite games. But all the romance in them was destroyed by the banal buy-and-sell and “pi-piu” in the “liquid” space at the speeds of airplanes of the times of the First World War. And those few virtual worlds lacked the freedom, detail and scale of the real universe.
At the beginning of the millennium, I met MojoWorld and was shocked by its capabilities. Finally, one could roam other planets and take photographs of local attractions. He became the first sign that gave hope that full-blown cosmic worlds are technically possible. But, unfortunately, the performance of iron a decade ago was not enough to transmit all the beauties in real time. And the planets remained just dead landscapes.
But now, a little over a year ago, I accidentally stumbled upon the Space Engine universe, and it just blew my brain and smeared it across the floor with its scale and incredible detail.
What does it all look like?
The first thing that catches your eye is the real dimensions of our universe. What are hundreds of billions of galaxies and hundreds of billions of stars in each of them? - just dry numbers in an astronomy textbook. But here, all this is felt on one’s own skin. And you begin to understand how insignificant our humanity is with all its petty problems and mouse wars compared to the magnitude and incomprehensibility of the Universe. No, we are not grains of sand, and not even specks of dust, we are nothing at all. And no one will even notice if our sun suddenly goes out tomorrow and the next civilization sinks into oblivion, without leaving behind any heritage.
In addition, the absolute freedom of movement is surprising. You can fly anywhere with seamless transitions between the surface of the planets, orbit, stars and galaxies.
Yes, this is not a screensaver “through the universe”, here you can visit every passing star, wander around its planets, their satellites and asteroids.
Of course, in the Space Engine, like in any other self-respecting planetarium (for example, the recently mentioned Celestia), there is a display of the orbits of cosmic bodies and detailed information on them, and time management, and various eclipses (including from planetary rings), and the ability to render in a fisheye projection for planetarium projectors. But, the most important thing is that it is not limited to the catalogs of HIPPARCOS stars and NGC / IC galaxies (which also exist), but generates the entire visible universe with all types of objects that you can find in it. But at the same time it is based solely on scientific data and relevant theories and models, which allows the Space Engine to be used as a full (and insanely beautiful) manual on astronomy.
Here you can see with your own eyes the cosmic pac-man. Although in fact, it is a black hole with a gravitational lens against the background of a blue supergiant:
Meet the rise of a double star (there are even eightfold stars):
Visit neighboring and not so galaxies, nebulae, star clusters. Find out what red giants, neutron stars, and more look like. I will not spoil much, just leave a few pictures.
By the way, what do you think will look like a planet that is always facing one of its sides to the star? Meet the tidal-synchronized (it turns out to be called) desert. On the one hand, night and permafrost, on the other - a surface scorched by a star and a huge super-cyclone that never stops.
As in Celestia, you can download official additions to the Space Engine for textures of the planets of the solar system and some of their satellites in high resolution. So, for example, the basic package “weighs” 500 MB, and the total size of all add-ons is about 10 GB.
What else is missing?
Unfortunately, a lot more. Space is much more diverse and surprising than everything that has already been implemented in the Space Engine, but with each version the author carefully transfers a part of the real to his universe. For example, in the picture with a black hole and a blue giant, for complete happiness, there is not enough accretion disk and jets, which are still in the plans. There are also plans for the tails of comets, quasars, individual stones in planetary rings and dozens of other details that will make the universe even more complete, accurate and beautiful. So there is still a lot of work.
What else can be done?
At the moment, the program is a free interactive planetarium with the beginnings of a space simulator (that is, you can fly a shuttle above the surfaces of planets and drop ships into black holes now).
In the future, based on the same engine, it is planned to develop an MMO game with a focus on space exploration, search for artifacts, construction and development of colonies and bases on planets, asteroids or orbits of gas giants. No teleportations, "liquid" space and Hollywood "pi-piu". Yes, and what to share in such a huge universe?
In order to fly between planets and stars, you have to remember at least the basics of astronomy, the trajectories of celestial bodies, what are the first, second, third cosmic velocities, characteristic velocity, specific impulse and other attributes of real space travel. You will also have to monitor fuel consumption and reactive mass (yes, these are potentially different things), so as not to remain “suddenly” in outer space without the ability to return to inhabited systems. A ship designer is also planned, as in the Kerbal Space Program, with calculations of the main dynamic characteristics, as well as the strength and stability of the structure. The only “fantastic” assumption is the hyper drive, which provides superlight flights. Without it, IMO will be impossible.
How is all this possible?
The Space Engine universe is created by almost one person, our compatriot from St. Petersburg, Vladimir Romaniuk ( SpaceEngineer ). He is an astronomer by education and profession, so you can be sure of the scientific reliability of all the simulated objects and processes. The community around his program helps keep the catalogs of galaxies, stars and exoplanets up to date, as they are opened almost every day. Fans also create models of ships, shuttles and other little things to fill the universe.
The creator does not make secrets from the technical component of his world and shares his findings with members of the forum. I will list some key points and problems that needed to be solved for the implementation of the engine.
Coordinates
One of the problems was the representation of the coordinates of objects within the universe. Those who work closely with floating point numbers know how quickly they lose accuracy with distance from zero. And the accuracy of a few kiloparsecs at the edge of the universe is nothing at all. Therefore, 64-bit fixed-point numbers and a hierarchical representation of objects are used to store coordinates. That is, the coordinates of galaxies are described absolutely, stars - relative to the center of the galaxy, and planets - relative to the star. Of course, when rendering, you have to translate everything into floating point numbers, but the conversion to the coordinates relative to the camera is calculated in whole numbers. And the rendering itself occurs in layers, since no accuracy of the z-buffer is enough to take into account the size of the universe.
Stars and galaxies
The second problem is the generation of stars and galaxies. There are hundreds of billions of stars in the galaxy, which means that in order to display them all, you will need to generate and render terabytes of data. Of course, this is not suitable for real time. It would seem, okay, we will limit the distance to the camera and we will only generate and render stars in a small amount. But here two more problems arise. Firstly, the algorithm must be deterministic, that is, despite the fact that stars are created randomly, they must always appear in the same place. Otherwise it will be strange if we fly away from the star, and then in its place there will be a void. Secondly, stars have different brightness and are visible at different distances. Dim brown dwarfs quickly disappear from view, and bright blue giants are visible almost across the galaxy. To solve both problems, an octree is used, the nodes of which store seed to generate the underlying levels, as well as the maximum brightness of stars in this cell. At the same time, brighter stars are generated at higher levels of the hierarchy, since there are much fewer of them than less bright ones. Thus, the generation of stars becomes absolutely deterministic and depends only on the seed of the tree root and the texture of the distribution of stars in the galaxy. And it also allows you to quickly generate stars with a specified limiting visible brightness (which depends on distance and absolute brightness) at any distance from the camera. the less bright. Thus, the generation of stars becomes absolutely deterministic and depends only on the seed of the tree root and the texture of the distribution of stars in the galaxy. And it also allows you to quickly generate stars with a specified limiting visible brightness (which depends on distance and absolute brightness) at any distance from the camera. the less bright. Thus, the generation of stars becomes absolutely deterministic and depends only on the seed of the tree root and the texture of the distribution of stars in the galaxy. And it also allows you to quickly generate stars with a specified limiting visible brightness (which depends on distance and absolute brightness) at any distance from the camera.
The rendering technology for galaxies and nebulae is similar to the rendering of bulk clouds. That is, this is a set of sprites that, for acceleration, will be converted into imposters or a sky box, depending on where we are: inside or outside.
Planets
The modeling principle is similar to MojoWorld. His ideas were picked up by many projects with procedural planets, such as Outerra and Infinity. How it works? Take a regular cube, break each face into several segments, and then spherize, that is, as if inflating from the inside. It turns out a ball with a cube topology. This allows you to use square textures with maximum efficiency and minimal distortion.
But evenly breaking the cube into segments is not enough. Since the planet is large and it will not be possible to generate it with maximum detail for flights above the surface (again, terabytes of data will be required). LODs come to the rescue. They are implemented as follows. Each face of the cube is the root of the quad tree. Each tree node is a square with a fixed resolution of the grid and texture. If necessary (when approaching the camera), the node is divided into four, thereby doubling the detail. And so on until the required detail is reached at this point.
The height map and texture for each tree node are created entirely on the GPU using pixel shaders of the 3rd version (therefore, you won’t be able to run SE on video cards that do not support them). Generation algorithms are beautifully described in a book from the creators of MojoWorld - “ Texturing and Modeling: A Procedural Approach ”. That is, they are familiar to most of the sounds of Perlin and Vorley, as well as their variations and various methods of fractalization. A separate algorithm creates large cyclones for tidal-synchronized planets.
But, purely procedural landscapes usually look too artificial. The fact is that on planets with an atmosphere, they undergo significant erosion, which significantly changes the outlines of mountains and valleys. Unfortunately, the classic iterative erosion algorithms are quite difficult to scale between LODs, and have not yet been implemented. But there is a simpler (positional) way to simulate this phenomenon. These are special types of noise described in detail in the article . In short, not only Perlin noise is used to generate the landscape, but also its derivative, which allows you to build a gradient at each point of the landscape and simulate leaching, or, conversely, the influx of soil by shifting the coordinates of the base noise along this gradient. This approach already allows you to create pretty nice planets.
To simulate the atmosphere, Eric Bruneton's method is used , which was adapted for other planets with different pressures and compositions.
Instead of a conclusion
Already, the Space Engine is slipping into the belt of most planetariums and realistic space simulators (Celestia, Stellarium, Orbiter) for the richness and beauty of space. And this is only the beginning of the journey. If at least half of what is planned is realized, the Space Engine will become the most complete model of our universe, aggregating all modern knowledge of mankind from the field of astronomy. And, despite the fact that the author plans to leave the code closed, everyone can make a feasible contribution to creating the largest virtual world of the existing ones.
PS: all thanks to the author of the program SpaceEngineer . I think he will be able to answer some questions on the engine, if any.
References
- Space Engine - planetarium, space simulator;
- Celestia - a planetarium;
- Stellarium - a planetarium;
- Orbiter - planetarium, space simulator;
- MojoWorld - generator of procedural planets;
- Kerbal Space Program - an arcade space simulator with a ship designer;
- Infinity - MMO with procedural planets;
- Outerra is a planetary engine with the possibility of procedural detailing on top of real textures.