Example #1
0
        protected override void NextQuad(ref SgtStarfieldStar star, int starIndex)
        {
            var x        = Random.Range(-1.0f, 1.0f);
            var y        = Random.Range(-1.0f, 1.0f);
            var z        = Random.Range(Offset, 1.0f);
            var position = default(Vector3);

            if (Random.value >= 0.5f)
            {
                z = -z;
            }

            switch (Random.Range(0, 3))
            {
            case 0: position = new Vector3(z, x, y); break;

            case 1: position = new Vector3(x, z, y); break;

            case 2: position = new Vector3(x, y, z); break;
            }

            star.Variant     = Random.Range(int.MinValue, int.MaxValue);
            star.Color       = StarColors.Evaluate(Random.value);
            star.Radius      = Mathf.Lerp(StarRadiusMin, StarRadiusMax, SgtHelper.Sharpness(Random.value, StarRadiusBias));
            star.Angle       = Random.Range(-180.0f, 180.0f);
            star.Position    = Vector3.Scale(position, Extents);
            star.PulseRange  = Random.value * StarPulseMax;
            star.PulseSpeed  = Random.value;
            star.PulseOffset = Random.value;
        }
Example #2
0
        protected override void NextQuad(ref SgtStarfieldStar quad, int starIndex)
        {
            for (var i = Samples - 1; i >= 0; i--)
            {
                var sampleX = Random.Range(0.0f, 1.0f);
                var sampleY = Random.Range(0.0f, 1.0f);
                var pixel   = sourceTex2D.GetPixelBilinear(sampleX, sampleY);
                var gray    = pixel.grayscale;

                if (gray > Threshold || i == 0)
                {
                    var position = -halfSize + Random.insideUnitSphere * Jitter * StarRadiusMax;

                    position.x += Size.x * sampleX;
                    position.y += Size.y * GetWeight(HeightSource, pixel, 0.5f);
                    position.z += Size.z * sampleY;

                    quad.Variant     = Random.Range(int.MinValue, int.MaxValue);
                    quad.Color       = pixel;
                    quad.Radius      = Mathf.Lerp(StarRadiusMin, StarRadiusMax, Mathf.Pow(Random.value, StarRadiusBias)) * GetWeight(ScaleSource, pixel, 1.0f);
                    quad.Angle       = Random.Range(-180.0f, 180.0f);
                    quad.Position    = position;
                    quad.PulseRange  = Random.value * StarPulseMax;
                    quad.PulseSpeed  = Random.value;
                    quad.PulseOffset = Random.value;

                    return;
                }
            }
        }
Example #3
0
        protected override void NextQuad(ref SgtStarfieldStar star, int starIndex)
        {
            for (var i = samples - 1; i >= 0; i--)
            {
                var sampleX = Random.Range(0.0f, 1.0f);
                var sampleY = Random.Range(0.0f, 1.0f);
                var pixel   = sourceTex2D.GetPixelBilinear(sampleX, sampleY);
                var gray    = pixel.grayscale;

                if (gray > threshold || i == 0)
                {
                    var position = -halfSize + Random.insideUnitSphere * jitter * starRadiusMax;

                    position.x += size.x * sampleX;
                    position.y += size.y * GetWeight(heightSource, pixel, 0.5f);
                    position.z += size.z * sampleY;

                    star.Variant     = Random.Range(int.MinValue, int.MaxValue);
                    star.Color       = starColors.Evaluate(Random.value) * Color.LerpUnclamped(Color.white, GetBoosted(pixel), starTint);
                    star.Radius      = Mathf.Lerp(starRadiusMin, starRadiusMax, Mathf.Pow(Random.value, starRadiusBias)) * GetWeight(scaleSource, pixel, 1.0f);
                    star.Angle       = Random.Range(-180.0f, 180.0f);
                    star.Position    = position;
                    star.PulseRange  = Random.value * starPulseMax;
                    star.PulseSpeed  = Random.value;
                    star.PulseOffset = Random.value;

                    return;
                }
            }
        }
Example #4
0
 public void CopyFrom(SgtStarfieldStar other)
 {
     Variant     = other.Variant;
     Color       = other.Color;
     Radius      = other.Radius;
     Angle       = other.Angle;
     Position    = other.Position;
     PulseSpeed  = other.PulseSpeed;
     PulseRange  = other.PulseRange;
     PulseOffset = other.PulseOffset;
 }
Example #5
0
        protected override void NextQuad(ref SgtStarfieldStar star, int starIndex)
        {
            var x = Random.Range(Size.x * -0.5f, Size.x * 0.5f);
            var y = Random.Range(Size.y * -0.5f, Size.y * 0.5f);
            var z = Random.Range(Size.z * -0.5f, Size.z * 0.5f);

            star.Variant     = Random.Range(int.MinValue, int.MaxValue);
            star.Color       = StarColors.Evaluate(Random.value);
            star.Radius      = Mathf.Lerp(StarRadiusMin, StarRadiusMax, Mathf.Pow(Random.value, StarRadiusBias));
            star.Angle       = Random.Range(-180.0f, 180.0f);
            star.Position    = new Vector3(x, y, z);
            star.PulseRange  = Random.value * StarPulseMax;
            star.PulseSpeed  = Random.value;
            star.PulseOffset = Random.value;
        }
Example #6
0
        protected override void NextQuad(ref SgtStarfieldStar star, int starIndex)
        {
            var sphere = Random.insideUnitSphere;

            sphere.y = Mathf.Abs(sphere.y) * bias;

            star.Variant     = Random.Range(int.MinValue, int.MaxValue);
            star.Color       = starColors.Evaluate(Random.value);
            star.Radius      = Mathf.Lerp(starRadiusMin, starRadiusMax, SgtHelper.Sharpness(Random.value, starRadiusBias));
            star.Angle       = Random.Range(-180.0f, 180.0f);
            star.Position    = sphere.normalized * radius;
            star.PulseRange  = Random.value * starPulseMax;
            star.PulseSpeed  = Random.value;
            star.PulseOffset = Random.value;
        }
        protected override void NextQuad(ref SgtStarfieldStar star, int starIndex)
        {
            var position  = Random.insideUnitSphere;
            var magnitude = Mathf.Lerp(Offset * Radius, Radius, SgtHelper.Sharpness(Random.value, Bias));

            position.y *= Symmetry;

            star.Variant     = Random.Range(int.MinValue, int.MaxValue);
            star.Color       = StarColors.Evaluate(Random.value);
            star.Radius      = Mathf.Lerp(StarRadiusMin, StarRadiusMax, SgtHelper.Sharpness(Random.value, StarRadiusBias));
            star.Angle       = Random.Range(-180.0f, 180.0f);
            star.Position    = position.normalized * magnitude;
            star.PulseRange  = Random.value * StarPulseMax;
            star.PulseSpeed  = Random.value;
            star.PulseOffset = Random.value;
        }
        protected override void NextQuad(ref SgtStarfieldStar star, int starIndex)
        {
            var magnitude = Random.value;
            var position  = Random.insideUnitSphere * Mathf.Lerp(ThicknessInner, ThicknessOuter, magnitude);

            position *= Mathf.Pow(2.0f, Random.value * ThicknessPower);

            position += Quaternion.AngleAxis(starIndex * armStep + magnitude * twistStep, Vector3.up) * Vector3.forward * magnitude;

            star.Variant     = Random.Range(int.MinValue, int.MaxValue);
            star.Color       = StarColors.Evaluate(Random.value);
            star.Radius      = Mathf.Lerp(StarRadiusMin, StarRadiusMax, SgtHelper.Sharpness(Random.value, StarRadiusBias));
            star.Angle       = Random.Range(-180.0f, 180.0f);
            star.Position    = position * Radius;
            star.PulseRange  = Random.value * StarPulseMax;
            star.PulseSpeed  = Random.value;
            star.PulseOffset = Random.value;
        }
Example #9
0
 protected abstract void NextQuad(ref SgtStarfieldStar quad, int starIndex);
Example #10
0
 protected override void NextQuad(ref SgtStarfieldStar quad, int starIndex)
 {
     quad.CopyFrom(Stars[starIndex]);
 }