Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

[Released] 3D Starfields

Discussion in 'Assets and Asset Store' started by Nimred, Nov 26, 2015.

  1. Nimred

    Nimred

    Joined:
    Nov 1, 2014
    Posts:
    46
    Hello everyone,

    In the space game I'm working on, you can travel seamlessly between any of several thousand stars, in 3D. There's no cheating within the playable zone - all the scales are realistic, and every star you can travel to is visible in the "sky".

    I needed an efficient and good looking way to display those stars at specific 3D positions: skyboxes can't do that, unity flares were too costly and did not work well with layers, and textured particles didn't look good enough and would lose visibility in the distance. I could have drawn dots manually but I felt that using a shader would be easier and give more possibilities with glow and things like that.

    So I made a particle shader that does not use textures, and draws the star procedurally, using sizes and intensities of glow, the particle color, alpha, etc... And most importantly, the shader makes sure that a distant star does not flicker, by making sure it uses at least one pixel to render (or more if you tweak that parameter).

    Since I would have liked to find this on the Asset Store, I made an asset out of it, which got released this week. It includes several scripts to generate starfields randomly or from specified positions, and also a little demo effect of infinite interstellar travel.

    Here it is :) https://www.assetstore.unity3d.com/en/#!/content/48834

    You can also check the demo and documentation on my website: http://www.timecraftgames.com/starfields.html

    I used noticeable glows and colors for the examples but you can tweak it to whatever you like, or combine it with a skybox.

    If you have any feedback or questions, don't hesitate :)











     
    Last edited: Jul 6, 2017
    AdamGoodrich likes this.
  2. Nimred

    Nimred

    Joined:
    Nov 1, 2014
    Posts:
    46
    At the moment there is no scintillation programmed into the shader, as I made this with space games in mind, and stars viewed from space do not twinkle.

    You could potentially toy with each particle's alpha from script to produce some twinkle, otherwise I will have a look when I'm back from christmas break - it would be cleaner to put this in the star shader.
     
  3. Nimred

    Nimred

    Joined:
    Nov 1, 2014
    Posts:
    46
    Twinkle/scintillation is now implemented. It can be tweaked in strength and speed, and if you want only a number of stars to twinkle you can put them in a separate starfield and use scintillation only there.

    I've uploaded to the asset store, it might take a while until the change is approved but I can send by e-mail if needed.
     
  4. Nimred

    Nimred

    Joined:
    Nov 1, 2014
    Posts:
    46
    Minor update incoming: the random starfields were generated around (0,0,0), which wasn't great. There is now an option to generate the starfield around the object transform. Also, several warnings introduced by Unity 5.3 have been fixed.
     
  5. dpolyakov

    dpolyakov

    Joined:
    Dec 18, 2015
    Posts:
    16
    Is it possible with your asset to generate stars along a plane rather than a sphere?
    I'm making a space shooter (top view) and I need stars as a scrollable background.
     
  6. Nimred

    Nimred

    Joined:
    Nov 1, 2014
    Posts:
    46
    It's possible if you modify the starfield generation scripts. But if you want the background to be infinite, it's not enough to generate on a plane - you would have to keep discarding and adding new stars at runtime. The InfiniteStarfield script does that, but you would have to adjust it to match your top view.
     
  7. Nimred

    Nimred

    Joined:
    Nov 1, 2014
    Posts:
    46
    Looks like the asset crashes in Unity 5.5.1 - I'm waiting to hear back from Unity about this, I will post again when it is resolved.
     
  8. Nimred

    Nimred

    Joined:
    Nov 1, 2014
    Posts:
    46
    Apparently it's already fixed - but you will need Unity 5.5.1p1+ to benefit from it.
     
  9. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Hi there, there are some deprecated and shader warnings due to updated APIs for Unity 5.6. Would you mind fixing these when you get the chance? Thanks!
     
  10. Nimred

    Nimred

    Joined:
    Nov 1, 2014
    Posts:
    46
    Thanks for reporting this! I've fixed the warnings and added a space background skybox to the asset, the update will be available soon.
     
    Korindian likes this.
  11. Nimred

    Nimred

    Joined:
    Nov 1, 2014
    Posts:
    46
    Version 1.2 with fixed warnings and new background space skybox is now available!
     
    Korindian likes this.
unityunity