Starfield Shaders Unity asset contains starfield shaders for 2D and 3D projects. Shaders are custom made geometry shaders, designed for performance. I also provide powerful yet simple to use scripts for both 2D and 3D projects.
Meshes are generated through code and can be generated in-game. Up to 128000 stars per starfield.
Minimal impact on your graphics card. All shader calculations are done without textures and mainly in the geometry part. Shaders can also render low-poly style stars.
Minimal coding is required on your part. Include my scripts and generate different starfields with only a few steps.
This asset contains optimized starfields for both 2D and 3D projects. The 2D version also has the parallax effect.
While shaders and scripts for both perspectives are built in the same way, they each have their differences in features they provide and meshes they use with the help of which starfields are rendered. Meshes can provide to up to 128000 stars per starfield.
Planes are used in 2D because we don't need the additional dimension. The most important setting in this mode is the "starfield bounds" setting.
These bounds make sure that triangles aren't rendered outside of the given X (width) and Y (height) values. They are still rendered though, just on the opposite side. This gives a parallax effect.
In 3D, spheres are used. Spheres are icosahedron-based because I believe this parametrization provides the best and most consistent distribution of stars.
The 3D shader transforms your sphere into view space, removing the need of positioning your
starfield. The starfield is always visible.
When you are resizing stars, you are actually resizing their triangles. This makes sure the overdraw for transparent objects in Unity is as low as possible. Meshes do not contain the correct UV information. Instead of providing a noise texture to the shader, noise is stored in the sphere’s UV channel. The color is not sampled from gradient textures but is instead saved into the mesh itself. These decisions were made mainly for performance reasons and simplicity.