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.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Making a galaxy look more realistic

Discussion in 'Scripting' started by Noxbuds, Jul 14, 2015.

  1. Noxbuds

    Noxbuds

    Joined:
    Mar 17, 2015
    Posts:
    57
    So I have made a system which generates a galaxy. When far away, it'll just place cloud billboards on positions for the arms. But it seems to spiral-ly and too unrealistic:
    upload_2015-7-14_13-48-16.png

    Here's the code for making billboard positions:
    Code (CSharp):
    1.         for (int i = 0; i < c_chunk.galaxy.armcount*2; i++) {
    2.            
    3.             c_x = 0;
    4.             c_z = 0;
    5.            
    6.             c_rotation += c_chunk.galaxy.armcount/swirl_value;
    7.            
    8.             for (int j = 0; j < c_armlength; j++) {
    9.                
    10.                 c_x += Mathf.Cos (c_rotation * Mathf.Deg2Rad) * (generator.generate_int(4,j)/7500) * 0.25f;
    11.                 c_z += Mathf.Sin (c_rotation * Mathf.Deg2Rad) * (generator.generate_int(4,j)/7500) * 0.25f;
    12.                
    13.                 c_chunk.galaxy.arm_waypoints[i,j] = new Vector3 (c_x+x_offset,y_offset,c_z+z_offset);
    14.                
    15.                 c_rotation += swirl_value;
    16.                
    17.             }
    18.            
    19.         }
    I mean, it looks pretty good, but not quite like these 2:



    What would I do to make it seem more realistic?
     
  2. traderain

    traderain

    Joined:
    Jul 7, 2014
    Posts:
    108
    Try to use random particle effects on the arms. Place lighting in the middle and try to randomize as much as you can.
     
  3. Noxbuds

    Noxbuds

    Joined:
    Mar 17, 2015
    Posts:
    57
    Thanks, but I am wondering how I would make it more cloud-like. If you take a look at mine, it's just circle textures with blurred edges placed on billboards in a spiral. If you look at the other images, it looks more cloud-like, a bit misshapen and a bit blended in with the others, with coloured streaks. I want to know how I'd go about doing that.
     
  4. traderain

    traderain

    Joined:
    Jul 7, 2014
    Posts:
    108
    Last edited: Jul 14, 2015
  5. Noxbuds

    Noxbuds

    Joined:
    Mar 17, 2015
    Posts:
    57
    Thanks. I will have a look at it.

    I don't have a GTX Titan, so I worry how my GT740 will react...
     
  6. TwiiK

    TwiiK

    Joined:
    Oct 23, 2007
    Posts:
    1,729
    I got sort of a deja vu now because I feel like I've made galaxies in Unity before. :p

    I think I based mine on this script:
    http://wiki.unity3d.com/index.php?title=Particle_Spiral_Effect

    I'll check when I get home from work if I still have my project somewhere. It's probably Unity 3.x and using the old particle system, but it could serve to get you started.
     
  7. traderain

    traderain

    Joined:
    Jul 7, 2014
    Posts:
    108
    • Foreground stars: use 5-15 'flare' pre-made gray-scale textures (1 per size) and colorize them slightly so each star has its own hue.
    • Nebulae: Generate a random rectangular texture with perlin noise. The alpha must also be controlled by the perlin noise, so the image is transparent in some spots. Make them big and fade the borders, so they are seamless. Each nebulae must be colorized. Experiment putting very faint, big nebulae in the background, so the space isn't completely black in all places.
    • Galaxies: Same as the nebulae, except that with much less alpha, and the border fading is less gradual and more "oval" in shape.
    I don't recommend pulsing. If you want to add some animation, simulate movement by adding different scroll levels (so the objects that are far away don't move at all, but the ones near the camera move more)
     
  8. Noxbuds

    Noxbuds

    Joined:
    Mar 17, 2015
    Posts:
    57
    Thank you for the reply. Although I am unsure what you mean for the galaxies.
    Do you mean that I generate the shape with Perlin Noise or something else?
     
  9. traderain

    traderain

    Joined:
    Jul 7, 2014
    Posts:
    108
    yes so its random.
     
  10. Noxbuds

    Noxbuds

    Joined:
    Mar 17, 2015
    Posts:
    57
    I want a lot of my galaxies to be spiral galaxies...

    It is so easy to make an elliptical galaxy using noise. Spiral is tricky, and I like the look of spiral galaxies.