ENG New site

Advanced search

[ New messages · Forum rules · Members ]
  • Page 1 of 2
  • 1
  • 2
  • »
Procedural Programming
NeonDate: Friday, 10.06.2011, 17:58 | Message # 1
Explorer
Group: SE team
Australia
Messages: 208
Status: Offline
Vova,

I was wondering if you could explain procedural programming?
I understand the principle, the computer generates the content,
but I'm curious in how different it is to work in regards to
normal procedures. I have done a little programming at
Uni, but I found it wasn't my thing. lol
 
SpaceEngineerDate: Saturday, 11.06.2011, 16:01 | Message # 2
Author of Space Engine
Group: Administrators
Russian Federation
Messages: 4800
Status: Offline
What do you want to know? Procedural generating of stars, planets, or generating of surface textures and geometry?

The first simply uses random() function that generates a pseudo-random number each time it calls. There is another function randomize(x) that recieves a number x, that initializes generator. So if you use the same x, all number sequences generate by calling random() will be the same. For example, the function, that generates planetary system, calculates x from star number (RS 8404-123-625...) and than calls randomize(x). Then all calls of random() inside the functions will generate a sequence of random numbers, that are used to calculate planets orbits, radiuses etc. Another star has different unique number, so its system will be different. The next time engine needs to generate system for a star, the x ("seed") will be the same as last time, so the system will be the same. Appearance of system depends only on star id (set of numbers after RS), and this id is unique for each star in the Universe.

*





 
SpaceEngineerDate: Saturday, 11.06.2011, 16:21 | Message # 3
Author of Space Engine
Group: Administrators
Russian Federation
Messages: 4800
Status: Offline
Generation of planetary surface goes another way. It is based on splitting the surface on a set of square-shaped regions (tiles or patches), that organized in the quadtree data structure. Each region has its own color texture and heightmap texture. Textures are generated using "fractal functions". These functions receives a 3D coordinate of pixel and give a pseudo-random value that depends only on coordinates and changes smoothly with coordinate (google perlin noise, cellural noise). 3D coordinate is a coordinate point on the sphere, that can be easily obtained from indexes of tile and coordinates of pixel of tile's texture.

SpaceEngine uses several fractal functions (perlin, ridged multifractal, crater noise etc) that combine in several ways (add, multiply, etc). Parameters to these functions like frequencies, magnitudes and switchers are generated for each planet when the solar system is generated. So all planet appear unique. Generation of textures in SpaceEngine is done on the GPU with a special huge shader. It is possible to have done this on CPU using C++ code, but GPU is much more faster than CPU (up to 100 times!). I haven't designed CPU generator code, so procedural planetary surfaces are only available if you have powerful GPU with shaders 3.0 - this is why system requirments are so high.

*





 
NeonDate: Saturday, 11.06.2011, 19:46 | Message # 4
Explorer
Group: SE team
Australia
Messages: 208
Status: Offline
Ahhh I see... yes that's what I wanted to know. Very interesting approach.

Thanks Vova, been wondering this for awhile.
 
TinoDate: Tuesday, 16.08.2011, 21:14 | Message # 5
Observer
Group: Newbies
Angola
Messages: 7
Status: Offline
Hello Space EngineeR, Congratulations! Space engine is the only working procedural generated universe simulator!
I have a question for you, since I'm making a little game that uses some of the technology seen in SE!

How do you connect the planet patches together? In other words, how do you deal with the seams?

Another question is:
What is SE? A space simulator or a Game? Are you going to add physics, collisions to the objects?

I'm already a fan!
 
SpaceEngineerDate: Wednesday, 17.08.2011, 07:50 | Message # 6
Author of Space Engine
Group: Administrators
Russian Federation
Messages: 4800
Status: Offline
Hello Tino,

To connect patches, I make a complex system: Skip every second vertex on the corner of patch that connects to low-resolution patch, requesting the LOD of neighbor, generating textures with the border with data from neighbouring patches, and requesting data from the neighbor border. But this system can't works properly. It has many issues and glitches. So I simply make skirts on the perimeter of patch, and that's all. This is easiest way.

In future I plan to implement the vertex shader based landscape (google for pdf "Continuous Distance-Dependent Level of Detail for Rendering Heightmaps (CDLOD)"). No geometry for patch generate. Engine will use only one unique vertex buffer with "flat" geometry, and will performs displacement of verticies in the vertex shader using texture fetch from heightmap texture. In this approach it is easy to implement geomorphing to smooth connection of patches: no vertex popping seen when flying over mountains in SE.

Next step is the ray-casting rendering of the patches (google for pdf "GPU Ray-Casting for Scalable Terrain Rendering"). This is a kind of relief mapping shader. No geometry needed to render the surface, only a set of cubes with a complex shader that performs ray casting in the height map texture. This is a reasonably fast method and gives very high detail landscape (per-pixel detail), but consumes more video memory to storing additional textures (quad tree textures to quickly find intersection of the ray with the ground).

*





 
TinoDate: Wednesday, 17.08.2011, 18:55 | Message # 7
Observer
Group: Newbies
Angola
Messages: 7
Status: Offline
When I flew under the planet surface and saw the terrain patches, I guessed you were using the skirt method!
Thank you for replying!
If you plan in using vertex shaders, are you not using collision on the planet surfaces?
And my second question? What do you plan to do with SE? A game like Infinity? Or a space simulator like Celestia(well SE is already superior that Celestia)
 
SpaceEngineerDate: Thursday, 18.08.2011, 06:12 | Message # 8
Author of Space Engine
Group: Administrators
Russian Federation
Messages: 4800
Status: Offline
Quote (Tino)
If you plan in using vertex shaders, are you not using collision on the planet surfaces?


Collisions are a hard thing. In my current realisation of landscape renderer, I throw height data from GPU to CPU and build meshes for patches on CPU. So I have height data on CPU, and can implement collisions. But downloading the heightmap to CPU is a huge bottleneck, it gives big slowdown at surface generation stage. I want to escape this by implement heightmap fetch in vertex shader or ray casting. But since all will be done on GPU. CPU has no heightmap data to compute collisions. But I can use GPU to do it: Render heightmap into a small texture that is placed under colliding body, then throw that texture to CPU built triangles and compute collision. Or compute collision directly on GPU with "physics pixel shader", render data to small texture and throw that to the CPU. Or implement all physics on GPU only. The last idea is much more impressive than the other: I can precisely compute spaceship motion in gravity field of all bodies in solar system, or compute spaceship explosion with thousands of debris bouncing off the ground.

Quote (SpaceEngineer)
And my second question? What do you plan to do with SE? A game like Infinity? Or a space simulator like Celestia(well SE is already superior that Celestia)


I want to make both. The free planetarium mode as now, and the online exploration game with spaceships, landing shuttles, city building on planets etc. If I make the game with money subscription, and it becomes popular, then I can leave my current job and spend all my time working on SpaceEngine smile

*





 
RobbieDate: Thursday, 18.08.2011, 07:41 | Message # 9
Pioneer
Group: Global Moderators
United Kingdom
Messages: 590
Status: Offline
Quote (SpaceEngineer)
I want to make both. The free planetarium mode as now, and the online exploration game with spaceships, landing shuttles, city building on planets etc. If I make the game with money subscription, and it becomes popular, then I can leave my current job and spend all my time working on SpaceEngine


Ah, I was wondering about that: Whether Space-engine was a full-time job or a part-time hobby for you. Are you a programmer in your day job too? smile

*





Quad Core i7 930 CPU o/c 3.8 GHz - 6GB DDR3 1600MHz RAM - ATI HD 5870 1024Mb - Intel SSD X25-M Gen 2 - Win 7 64-bit
Add Your PC Spec To Your Signature Or Post It Here
 
SpaceEngineerDate: Thursday, 18.08.2011, 10:00 | Message # 10
Author of Space Engine
Group: Administrators
Russian Federation
Messages: 4800
Status: Offline
I am an astronomer. My main job is engineer-observer at the Pulkovskaya observatory, but I work less hour there than I do in my second job, where I am an advertisement designer at that company.

*





 
TinoDate: Thursday, 18.08.2011, 19:22 | Message # 11
Observer
Group: Newbies
Angola
Messages: 7
Status: Offline
That is very nice!
I'm building a similar game, but am a beginner programmer!
I want to know, where do you get the galaxy's data? At least the position of the known stars! Unfortunately, the way I'm doing my galaxy, I'd have to place the stars by hand!
In any case, I have a few more questions for you:

I suppose your rendering engine is home made, so how many triangles can it render? How do you light your planets? The lighting is great by the way!
How do you manage to get, or how do you handle space(how do you get over the 32bit float limitation)?

Quote (SpaceEngineer)
Or compute collision directly on GPU with "physics pixel shader", render data to small texture and throw that to the CPU. Or implement all physics on GPU only. The last idea is much more impressive than the other: I can precisely compute spaceship motion in gravity field of all bodies in solar system, or compute spaceship explosion with thousands of debris bouncing off the ground.

If you plan on doing a game out of the SE, then, you'll have to rewrite the planet generation code? Will you add detailed textures, like sand, rocks, etc, will you add detail meshes such as trees, rocks, etc?

*
 
SpaceEngineerDate: Friday, 19.08.2011, 09:59 | Message # 12
Author of Space Engine
Group: Administrators
Russian Federation
Messages: 4800
Status: Offline
Quote (Tino)
I want to know, where do you get the galaxy's data? At least the position of the known stars! Unfortunately, the way I'm doing my galaxy, I'd have to place the stars by hand!


I use HIPPARCOS star catalog (google for binary data). It consists of 120k stars with precise celestial coordinates and parallaxes (distances). Note, that in 3D you need 3 coordinates, so other catalogs with huge number of stars (several billions!) have only 2 celestial coordinates, and are not suituable here. HIPPARCOS consists of stars in our neighborhood only: several hundred parsecs from the sun for bright giant stars, to several parsecs for small dwarf stars. In the other parts of galaxy I generate stars procedurally, using "fade out" function, that kills bright procedural stars near the sun - this make a smooth transition from the HIPPARCOS data-set to my procedural stars.

Quote (Tino)
I suppose your rendering engine is home made, so how many triangles can it render?


Some million triangles with real-time frame rate. For modern hardware and complex pixel shaders, the limitation is number of pixels (resolution), not triangles.

Quote (Tino)
How do you light your planets?


For moons without atmosphere I use Lommel-Seeliger lighting model, for gas giants I use Lambert, for terrestrial planets with atmosphere - a mix of other two with atmosphere of Eric Bruneton.

Quote (Tino)
How do you manage to get, or how do you handle space(how do you get over the 32bit float limitation)?


First, I use double precision calculations. I compute all matrices on CPU in doubles, and convert it to float and load to GL before rendering only. Second, I use hierarchical coordinate system: universe -> galaxy -> star. This mean that when the camera enters a galaxy, a new coordinate system starts to use origin at that galaxy's center. All stars are placed in this system. All updates of the camera position are made in two systems (universal and galactic) simultaneously. When the camera approaches the star, the third system starts to use it with origin at planetary system center. Maybe in the future I make a fourth system - planetary. Another way to handle space scales - is making your own huge 128-bit fixed point numbers and arithmetic functions with them. These numbers can handle a scale of 100 billion light-years with precision of... 1 micron! smile

Quote (Tino)
If you plan on doing a game out of the SE, then, you'll have to rewrite the planet generation code?

Yes, I must optimize texture generation time and eliminate lags.

Quote (Tino)
Will you add detailed textures, like sand, rocks, etc, will you add detail meshes such as trees, rocks, etc?


I am currently working on detailed textures (read the blog). Detailed meshes will be a future development.

*





 
TinoDate: Friday, 19.08.2011, 19:32 | Message # 13
Observer
Group: Newbies
Angola
Messages: 7
Status: Offline
Quote
Second, I use hierarchical coordinate system: universe -> galaxy -> star. This mean that when the camera enters a galaxy, a new coordinate system starts to use origin at that galaxy's center. All stars are placed in this system. All updates of the camera position are made in two systems (universal and galactic) simultaneously


Hmm, very interesting, I use the same system Galaxy->Star System-> Planet. However, because of the Game engine I'm using, there are still limits, a 4th system (universe) cannot be added without bad movement calculations.
Also this system might be at the root of your system's errors. Sometimes, you click on a planet and the cross appears next to it, not at the center!

Quote
Another way to handle space scales - is making your own huge 128-bit fixed point numbers and arithmetic functions with them. These numbers can handle a scale of 100 billion light-years with precision of... 1 micron!


We all would like to have that... unfortunately, I'm more an artist than a programmer and am bound to the engine's limitation.
Thank you for the links, and your patience! You don't mind if I take your game as reference for mine?
I'll still be around!
A piece of advice:
Maybe for the game, you could limit the game to the Milky way, if the space to explore is too big, players wont be able to explore it at all, or settle somewhere!
Also the time might be accelerated, to keep player on planets, atmospheric changes can capture a lot of attention!
I'll be travelling around for a while!

*
 
SpaceEngineerDate: Friday, 19.08.2011, 20:05 | Message # 14
Author of Space Engine
Group: Administrators
Russian Federation
Messages: 4800
Status: Offline
Quote (Tino)
Also this system might be at the root of your system's errors. Sometimes, you click on a planet and the cross appears next to it, not at the center!

On the contrary, these bug appears because I forgot to use local coordinate system and always render cross in the universe system. This is already fixed.

Quote (Tino)
You don't mind if I take your game as reference for mine?

I don't mind smile

Quote (Tino)
Maybe for the game, you could limit the game to the Milky way, if the space to explore is too big, players wont be able to explore it at all, or settle somewhere!

Why must I limit the engine capabilities? I plan to make procedural galaxies of at least 100 giga-parsec in area. It's up to you where you want to go in Universe smile

*





 
TinoDate: Friday, 19.08.2011, 21:06 | Message # 15
Observer
Group: Newbies
Angola
Messages: 7
Status: Offline
Quote
Why I must limit engine capabilities? I plan to make procedural galaxies in at least 100 gigaparsec area. It's up to you, where to go in Universe

For playability reasons. But it's cool to be able to fly out of galaxies... Only then the universe will seem too small and too vast at the same time...
What's the maximum ships speed going to be?
 
  • Page 1 of 2
  • 1
  • 2
  • »
Search: