Free Particle Editor Module for Spiral Galaxies

Create your own galaxy tutorial

OK, here is a quick tutorial for everyone who wants to create a kickass galaxy for their game :wink:

  1. Import the code posted above into your engine source folder
    Unzip the file into the UE4 github project folder or place the code there manually.

  2. Compile your UE4 project
    If you encounter any compile-time problems, make sure you added the ParticleModuleLocationGalaxy.h file to your Visual Studio solution:

  1. Create a new particle system

  1. Right-click on the emitter and set TypeData to “GPU Sprites”
    We want to have a lot of stars in our galaxy and this is only possible with GPU sprites.

  1. Create a particle material
    I just used the “radial gradient” material from the starter content. It is a really simple material but gets the job done. Make sure “Responsive AA” is enabled, otherise the stars smear when the galaxy is moving on the screen.

GPU sprites.png

  1. Set up the basic particle modules
    Here are the settings for the basic emitter modules:

  1. Add the galaxy location module
    Right now the particle editor shows just a blob of particles, which does not look very interesting. Now we add the galaxy location module and set it up. Play around with the values (especially the delta angle and the ellipse values) until you are satisfied with the shape of the galaxy. You do NOT want to change these values later, because we duplicate emitters and then you have to change these values on each emitter separately.

  1. Copy the emitter to add stars with different color/size/location
    To add some variation to your galaxy you have to duplicate the emitter.

For example, let’s add some big blue stars, but only to the fringes of our galaxy, not to the core.
This time, we spawn only 500 particles with a size of 50 (twice as big as the other stars) and a shiny blue color. The trick to get them to only spawn at a certain distance is to modify the “start radius” min value. You also have to set the falloff-factor to 0, otherwise they are partially pulled back into the core of the galaxy. Just play around with the value to see what looks good.

  1. Add nebulas and other stuff to the galaxy
    I used the cloud-particles from the content examples folder to create a nebula, the process to add them is them same as above. You can also add other stuff now, e.g. lights or some blinking stars, stars with cross-shapes, etc.

  2. PROFIT!

As an additional tip, the galaxy looks best in-game when slightly rotating, because then the player can really see the spatial positions of the individual stars as they move relative to each other.