Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by davidflynn2 · Dec 27, 2012 at 12:33 AM · c#shader

Procedural Generation

I am trying to find some guides or information on how to Proceduralay generate stars for my space game.

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image clunk47 · Dec 27, 2012 at 01:33 AM 0
Share

Need to be more specific, please. By stars, are you wanting to use particles, meshes, GUI, planes with textures? Is it a 2D or 3D game, will the stars be traveled to, or just used for background? Give a bit more detail on what you're going for :)

avatar image davidflynn2 · Dec 27, 2012 at 03:05 AM 0
Share

I am trying to make as real as possible of a 3d space game. I was looking at using particles but did not know if that would take to many to make a good space scene.

avatar image clunk47 · Dec 27, 2012 at 04:02 AM 1
Share

If you're using particles, you could attach a particle system to your "ship", and set the particles to "stretched" then give them a velocity scale. This would give a "travel" effect, here's an old space scene I did to show you what I mean.

EXA$$anonymous$$PLE

avatar image haroonalam · Dec 27, 2012 at 07:05 AM 1
Share

try using procedural example in unity demos, check out its "Fractal Texture" scene which uses perlin noise based texture, I think you might need to replace its texture with your star sequence sprite, I hope it would be good starting point

1 Reply

· Add your reply
  • Sort: 
avatar image
1
Best Answer

Answer by Dave-Carlile · Dec 27, 2012 at 02:43 PM

You don't need anything too sophisticated for this. The key is Random.onUnitSphere, which gives you a random position on the surface of a unit sphere. You can then multiply that by the desired radius to move the point out further. This script gives an example. Create a Sphere game object with a scale of 0.1, assign that to StarObject in the editor. Once you have it working change StarCount to 5000 and you'll have a decent looking set of stars.

Now, using spheres for this is obviously a really bad idea, but I wanted to give a simple example of the procedural part of this. It's just repeatable randomness, and for this particular thing you don't need Perlin.

To make this efficient you could use billboards for the stars rather than the spheres. Better yet, use Pro so you can take advantage of batching - should be able to do the whole thing in a single draw call.

Another option for efficiency (again, requires pro) is to generate the random sky dome using this method, then create skybox textures using render textures, and use those for rendering a sky box. You'd have procedurally generated skyboxes that way - the best of both worlds.

 public class StarDome : MonoBehaviour
 {
   public GameObject StarObject;
 
   public int Seed = 42;
   public int StarCount = 500;
   public float MinRadius = 100;
   public float MaxRadius = 120;
 
   void Awake()
   {
     // make sure we generate the same positions each time
     Random.seed = Seed;
 
     for (int i = 0; i < StarCount; i++)
     {
       // get random position on unit sphere
       Vector3 p = Random.onUnitSphere;
 
       // move it out to the sky sphere distance, with some randomness
       p *= Random.Range(MinRadius, MaxRadius);
 
 
       // instantiate game object
       GameObject star = Instantiate(StarObject, p, Quaternion.identity) as GameObject;
       star.transform.parent = this.transform;
     }
   }
 }
 


Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image davidflynn2 · Dec 27, 2012 at 05:37 PM 0
Share

Is there anyway I can proceduraly generate a ring for my planet I am new to this hole prodedural generation.

avatar image kat0r · Dec 31, 2012 at 12:34 PM 0
Share

Why not? The StarObject could be what you want, f.e. a planet with ring.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Making a Jetpack 3 Answers

Mouse Look is over riding my controller 1 Answer

Missle Distry after it reaches distance 1 Answer

Distribute terrain in zones 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges