Jump to content
This site uses cookies! Learn More

This site uses cookies!

armedunity.com uses cookies to improve user experience.

By continuing to use this site, you agree to allow us to store cookies on your computer.

Leaderboard


Popular Content

Showing content with the highest reputation on 11/14/2018 in all areas

  1. 1 point
    This is the final version(by final I mean the version containing nothing else than the necessary features required for our own project) of my simple starfield generator. The generator does not support box shape types or custom meshes, being made to be used mainly for sphere and hemisphere(shell emission or otherwise) types. Feel free to use it as you will in your projects, commercial or otherwise. You are not required to give credit to me, but of course, if you find good use of it, it would be nice. This was created to be used generally with Unity 5's procedural skybox, to make up for a nice fantasy looking cold night in some scenes. However, since I have no shader writing knowledge good enough to do something similar(yet!), I decided to make it a particle system. So if you wish to use it on Unity's procedural skybox, make sure to include a subtle bloom effect in case you use stars with a variety of colors(set the color palette on the particle system, do not change anything else). I know most members here are probably in no need for such thing, but new members may find it useful and help them learn more about how unity works. Usage: As described, if you want to use different star colors, make sure to set the color palette/grandient in the particle system's field, you are not required to change anything else. -If you accidentally get an unsatisfying result, re-read the first part of the post. If you have any questions I will gladly try and answer them. using System.Collections; using System.Collections.Generic; using UnityEngine; public class StarField : MonoBehaviour { public ParticleSystem StarEmiter; //The particle system that will act as the star field public int MaxStars; //Maximum number of stars to be created public int FieldRadius; //How big should the field be? public float MinimumStarSize; //The smallest allowed star size public float MaximumStarSize; //The biggest allowed star size public ParticleSystemShapeType StarFieldShape; //Drop down menu containing types of particle system shapes void Start() { //WARNING DISPLAY Debug.LogWarning("Box shape Particle System types are not currently supported!,neither are custom meshes or cones"); //Prepare Default Particle System Variables for star field generation StarEmiter.loop = true; var mainModule = StarEmiter.main; mainModule.prewarm = true; mainModule.startSpeed = 0; mainModule.simulationSpace = ParticleSystemSimulationSpace.Local; mainModule.startLifetime = 1000000; var shapeModule = StarEmiter.shape; shapeModule.shapeType = StarFieldShape; //Star field variables StarEmiter.maxParticles = MaxStars; var shape = StarEmiter.shape; shape.radius = FieldRadius; mainModule.startSize = new ParticleSystem.MinMaxCurve(MinimumStarSize, MaximumStarSize); //EMIT StarEmiter.Emit(MaxStars); } } For references visit: https://docs.unity3d.com/ScriptReference/ParticleSystem.html ScreenShots: https://www.dropbox.com/s/jpdrxsk6hvnakgy/Screenshot 2017-03-31 01.22.57.png?dl=0 https://www.dropbox.com/s/lqly19iq5l9sz26/Screenshot 2017-03-31 01.24.02.png?dl=0 Warning: Do not use more than 500 000 stars count, keep it 100 000 or below for budget machines, and <10 000 for weaker machines, and try to compensate for the amount with variety of size.
×
×
  • Create New...