Close

Unity 3D – Volumetric Procedurally-Generated Galaxy

Creating a volumetric galaxy, procedurally generated based on a bitmap, is relatively easy in Unity. The key idea is to use the Particle System, not employing the generator, but rather placing particles programmatically. This is demonstrated in the file GalaxyCloudForge.cs.

Some parameters have to be set correctly, like “Local” simulation space and the settings of the “[X] Render” component of the Particle System. In addition, the template bitmap must be set to “Read/write enabled“.

The source code of the Unity project can be found here: https://github.com/imifos/unity3d-workspace. It uses only standard assets, so I can share it without restriction.

In order to make the code more readable, GalaxyCloudForge.cs uses 2 separate loops. This can be merged into one single loop with a little bit of additional logic. Performance can be improved further by replacing GetPixel() by GetPixels32(), adding a bit of logic. Again, for education purpose, I did not use this in this example project.

 

Note: Low frame rate in video due to hardware limitation on laptop while recording.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close