-
Notifications
You must be signed in to change notification settings - Fork 2
Working with star cluster snapshot
- The rendering is done with the Universal Render Pipeline so the 'glow' from the stars is using the Bloom option in the Global Volume. Currently working through the cluster disappearing rather than combining the luminosity into a a blob object in the distance.
- The 'glow' is from a custom star shader, and modifying the material of one star, will update the material for all stars regardless of whether or not in play mode
- The x,y,z coordinates in the snapshots refer to x,z,y respectively in the Unity world. Beware.
- The units are in PC and can be modified in the InitializeStars GUI (default is 1 pc)
- Toggling the checkmark next to a script either enables it or disables it on play
- The size of the sphere to be 0.01 is hard coded in the StarTypes script and that is associated to the Sphere object in the Star prefab.
- If you have true selected for both Camera Start Centre, and Camera Start Outskirts, the camera will start at the outskirts of the cluster.
- Gravity is turned off.
- In Unity Hub, open up the '3d-cluster-unity' project

The main screen:

On the left hand side, under Hierarchy, you will see the list of GameObjects that are associated with the Scene that control how the snapshot will be loaded: Main Camera, Directional Light (doesn't do anything, but exists), InitializeStars, and Global Volume.
The main camera has a starting location 0,0,-10 in this example where the -10 means that it is 10 pc away from the centre of the world coordinates coming out towards the screen and faces towards the centre of the cluster.
The c# script MoveCamera is associated with the GameObject and controls the movement of the camera from the keyboard.
Variables:
- Angle Per Sec: [10 default] : This controls how many angles per second the camera will rotate about the x and z axis.
- Camera Move Speed: [0.5 default] : This controls how far in the unit space a press of the button will move the camera location per second
Keys:
- Forward: W, up arrow
- Back: S, down arrow
- Left: A, left arrow
- Right: D, right arrow
- Up: E
- Down: Q
- Rotate Left: J
- Rotate Right: L
- Rotate Up: I
- Rotate Down: K
This script will start at wherever the camera is initialized and then move towards the centre of the cluster to world coordinates of 0, 0, 0.
Variables:
- Auto Camera Speed: [0.5 default] : the distance per second that the camera will transform its position.
Initialize Stars is an empty game object that launches GetStars script to gather the information from the listed file location name [managed by Addressable Assets] and initialize the scene with the parameters given.

Variables:
- Pc units: [1 default] : the distance, in parsecs, that each unit of the scene accounts for in physical space. With a distance of 1, items in the centre of the cluster are more likely to overlap.
- Cluster Max Radius: [0 default] : This shouldn't be exposed and will need to be fixed. Don't touch this.
- Camera Start Centre: [false default] : When checked this will start the camera at the coordinates of 0, 0, 0.
- Camera Start Outskirt: [false default] : When checked this will start the camera at the coordinates of 0, 0, - maximum radius of any star object in the cluster.
- Star: [Star prefab] : the prefab to use for generating the stars in the cluster
- Asset File Location: The location given by the Addressable Asset file location. See
Adding Star Cluster Snapshot Files - Time Step: [1000 default] : The time, in years, that each second of the star cluster will represent. For many stars, their motion is noticeable between 1000-10000 years. A lower time period will have less stars noticeably move but will have the higher velocity stars be more obvious.
- Step Size: [1 default] : The distance in the file between stars that are initialized. A step size of 1 will initialize every star. A step size of 100 will initialize 1% of the cluster. This is helpful when dealing with large star clusters and wanting to get a general feel of how the scene will render.
Notes:
- If you have true selected for both Camera Start Centre, and Camera Start Outskirt, the camera will start at the outskirts of the cluster.
- If neither are selected for Camera Start Centre, and Camera Start Outskirt, the camera will start at the location given by the MainCamera GameObject as seen in the Inspector when game play is not running.
The DataFiles folder under Assets in the bottom panel is where the snapshot files are uploaded.
To upload a file, drag the file into the DataFiles folder with the Unity GUI, rather than moving it over on the hard drive directly; this will ensure the meta file is created at the same time.
Check the box 'Addressable' and enter in a name that the file will be referred to in the InitializeStars script.

The file structure expected is that the csv will have 3, 6, or 8 fields in the following order:
- x : The x position in parsecs
- y : The y position in parsecs
- z : The z position in parsecs
- vx : The x-direction velocity in km/s
- vy : The y-direction velocity in km/s
- vz : The z-direction velocity in km/s
- mass : The solar mass of the star
- tag/type : The type of object it is; this determines how the object is rendered by the StarTypes script.
Types associated to Unity tags:
- 1.0 : Main Sequence [MS]
- 2.0 : Evolved Sequence [ES]
- 3.0 : White Dwarf [WD]
- 4.0 : Neutron Star [NS]
- 5.0 : Black Hole [BH]
With the variables configured to how you'd like the star cluster to be formed, press the forward arrow at the top centre to play the scene. To exit play mode, press the forward arrow again. Most changes made in play mode will not be reflected once play mode has been exited, except modifications made to the star materials due to how the shader and rendering is set up (best guess).
When the cluster is initialized, all the stars will show in the hierarchy view with their index number and their tag information. The mass of the star (in solar masses) is tied to the Star Prefab in the Rigidbody.

Under the Star GameObject hierarchy, there are two children. In the Star Sphere, the scale is set to 0.01 and that is hard-coded at this point in the StarTypes script.
The Trail GameObject is visible when the stars are moving to help show their displacement in 3D space.

Under Window > General > Recorder you can either select Quick Record that will start the Scene and begin recording immediately, or you can launch the recorder window. In the recorder window you can select the output types of the recordings, such as a movie or a gif. This will continue to record until it is selected to stop recording or the play mode ends.

The star prefab is what is launched with the InitializeStars, and the script for managing how stars are displayed are tied to the Sphere object in the Star prefab. This is being added for informational reference at this point.
