In this After Effects tutorial I use only included effects to build a galaxy. This tutorial builds on previous knowledge to distribute the particles using the Fibonacci or Golden Spiral code I shared in that tutorial.
First I show how to spread the stars out in the correction formation, then duplicate the particle layer to create interstellar gas and copy it again to create the dark dust. The galaxy is 3D and able to be flown through with a virtual camera.
Y = 0; X = Math.sin(Math.PI*galaxySize)*Math.exp(galaxySize)*direction; Z = Math.cos(Math.PI*galaxySize)*Math.exp(galaxySize)*direction; [X,Y,Z]
Dan Ebbert’s toWorld Expression
L = thisComp.layer("Spiral Null"); L.toWorld(L.anchorPoint);
Expression to fade particles based on the camera’s distance from the centre
distanceToCentre = length(thisComp.layer("Camera 1").transform.position, thisComp.layer("Galaxy NULL").transform.position); linear(distanceToCentre, 0, 2000, 0, 1.5);