Generating a Galaxy

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
User avatar
WilliamKappler
Kobold
Posts: 33
Joined: Mon Feb 16, 2015 8:37 pm
Location: Raleigh, NC
Contact:

Generating a Galaxy

Post by WilliamKappler » Sun May 03, 2015 6:25 am

I'm attempting to program a game that uses a rather non-traditional map, in that locations on it are not fixed at the beginning (in the form of planets/grid tiles) but rather come into existence as the game goes on. It has a space setting, so I am dealing with galaxies, and the idea is basically that as regions of space are explored, "notable" planets (habitable/valuable) get placed on the map. This is the result of a probability function combined with a density map representing the galaxy - which causes the produced planets to look like an actual star formation, rather than just a cluster of things.

In addition to this probability+density based collection of "notable" planets/star systems, I also need to generate a background to the map, which would consist of just a visual representation of the galaxy as a whole (not just the stars relevant to the game).

Ergo, I have a question that is divided into two parts, the second being more directly related to Ogre than the first; but I feel these are closely related, so worth asking together. Overall this is pretty broad, and I'm more looking for some suggestions and opinions than an outright explanation.

Part A: Generating Density Map of Galaxy

The most basic issue here is that I need to create some sort of density map of the galaxy so that both the background decorative stars and the game-relevant notable planets can be placed in a realistic/logical fashion. This boils down to some form of fractal, but I have very little experience dealing with fractals, and they seem overall like voodoo to me.

I programmed something in Mathematica (that I have since lost) that implemented the mass-wave theory of galaxy formation; it did generate spiral arms, but it was far too uniform. I think I would instead need to approach this as some sort of procedural generation, like say creating a line and distributing density at random spaces around it.

Ie, imagine a line going around a center point. Its radius increases as it goes, and it has a little bit of randomness in that, and also generates "density" around it according to some random function. That can get tapered off (less spread, less intensity) as it reaches its end. It could take various parameters like tightness (to control radius increase) and eccentricity (to control the randomness in the path).

I think that's a promising system that in theory I know how to do procedurally, but I am at a loss as to how to reasonably implement the data storage portion of it. I don't know what to store this "density" as - an array (/vector)? Some sort of texture? Something else? It needs to be easily accessible for the sake of programming the later portions of the game, which would include things like taking averages over areas. I feel like a texture would work, but I have no idea how to approach using a texture this way in Ogre. I would need to write to and read from specific pixels pretty much freely.

For the sake of illustration, I found a picture of the milky way and made it look like what I imagine an ideal "density map" might look like: http://i.imgur.com/aSmPhU8.jpg

EDIT: I had a huge amount of success working on this part last night. I created a pseudo-array out of wrapping a pixel buffer's data pointer, and had good results with the algorithm I suggested: http://i.imgur.com/32IXyYZ.png


Part B: Converting Density Map to a Billboard/Particle Background


Once I have this density data, whatever form it takes, I need to generate a 3D galaxy to serve as the "background" to the game. I get the feeling billboards would be better suited to this than particles, but I am not sure, as I know there are tricks in Blender (for example) to use a texture to emit particles from. However, I need these to be somewhat 3D, so I am not sure if that would work.

Essentially, I need a way to convert whatever the product of part A is into billboards or particles.
0 x


User avatar
areay
Bugbear
Posts: 819
Joined: Wed May 05, 2010 4:59 am
Location: Auckland, NZ

Re: Generating a Galaxy

Post by areay » Thu May 07, 2015 9:46 am

Bakaiya wrote:Essentially, I need a way to convert whatever the product of part A is into billboards or particles.
Why not render the results of A into an RTT and use them as a skybox?
0 x

User avatar
WilliamKappler
Kobold
Posts: 33
Joined: Mon Feb 16, 2015 8:37 pm
Location: Raleigh, NC
Contact:

Re: Generating a Galaxy

Post by WilliamKappler » Mon May 11, 2015 1:53 am

Thanks for the replies. I got delayed by another project I had more urgent work to do with.
Transporter wrote:I've found some interesting articles: Also, have a look at http://www.ogreprocedural.org/. There are some procedural texture generation functions.
I'll take a look at those. There's definitely some interesting points there.
areay wrote:
Bakaiya wrote:Essentially, I need a way to convert whatever the product of part A is into billboards or particles.
Why not render the results of A into an RTT and use them as a skybox?
What I'm trying to do is sort of the reverse of what most people do. This is a space RTS/TBS game, ergo the galaxy is the map you'd be looking at as the main focus of the game UI. There are two halves to that, the half that actually has gameplay relevance (which doesn't relate to anything I've asked directly, it's sort of a separate matter) and the part that's just for show. The show part is generated from this texture I'm generating, but it's not just a texture - I wanted to do particles/billboards based on that 2D image with a random 3D component, so the "background" galaxy actually has depth.

Basically, generate an actual 3D galaxy out of a 2D density map of that galaxy.
0 x

Post Reply