void Texturize(SS_Texture texture, Color targetColor, Color tint, bool highlights, bool shading)
        {
            Perlin perlin = new Perlin(0.025, 2, 0.5, 8, Seed, QualityMode.Low);

            SS_Texture BaseTexture = SS_StellarSprite.GenerateBaseTexture(Seed, texture.Width, texture.Height, 8 * (random.Range(1, 2)));

            for (int y = texture.Height / 2; y < texture.Height; y++)
            {
                for (int x = texture.Width / 2; x < texture.Width; x++)
                {
                    if (texture.GetPixel(x, y) == targetColor)
                    {
                        Color hullShade = BaseTexture.GetPixel(x, y);

                        // Pixel shade
                        float pixelNoise = (float)perlin.GetValue(x, y, 0);
                        pixelNoise = (pixelNoise + 3.0f) * 0.25f; // 0.5 to 1.0
                        pixelNoise = Mathf.Clamp(pixelNoise, 0.5f, 1f);

                        hullShade *= tint * pixelNoise;

                        if (shading)
                        {
                            SS_StellarSprite.PixelLighting(texture, x, y, ref hullShade);
                        }

                        hullShade.a = 1.0f;
                        texture.SetPixel(x, y, hullShade);
                    }
                }
            }
        }
Exemple #2
0
        private void Texturize(SS_Texture texture, Color targetColor, Color tint, bool highlights, bool shading)
        {
            Perlin  perlin            = new Perlin(ColorDetail, 2, 0.5, 8, Seed, QualityMode.High);
            Voronoi hightlightVoronoi = new Voronoi(ColorDetail, 2, Seed, true);

            SS_Texture BaseTexture = SS_StellarSprite.GenerateBaseTexture(Seed, Size, Size, 16);

            for (int y = Size / 2; y < Size; y++)
            {
                for (int x = 0; x < Size; x++)
                {
                    if (texture.GetPixel(x, y) == targetColor)
                    {
                        Color hullShade = BaseTexture.GetPixel(x, y);

                        //Pixel shade
                        float pixelNoise = (float)perlin.GetValue(x, y, 0);
                        pixelNoise = (pixelNoise + 3.0f) * 0.25f; // 0.5 to 1.0
                        pixelNoise = Mathf.Clamp(pixelNoise, 0.5f, 1f);

                        hullShade *= tint * pixelNoise;

                        if (highlights)
                        {
                            // Pixel shade
                            float hightlightNoise = (float)hightlightVoronoi.GetValue(x, y, 0);
                            hightlightNoise = (hightlightNoise + 1.0f) * 0.5f; // 0.0 to 1.0
                            hightlightNoise = Mathf.Clamp(hightlightNoise, 0.0f, 1f);

                            if (hightlightNoise <= 0.75f)
                            {
                                hullShade = ColorBase * pixelNoise;
                            }
                            else
                            {
                                hullShade = ColorHighlight * pixelNoise;
                            }
                        }

                        // Check the current pixel and find when it hits a solid black outline.  if it does
                        // Make the current pixel a bit darker - do for all 4 dirtections
                        if (shading)
                        {
                            SS_StellarSprite.PixelLighting(texture, x, y, ref hullShade);
                        }

                        hullShade.a = 1.0f;
                        texture.SetPixel(x, y, hullShade);
                    }
                }
            }

            // Mirror
            SS_StellarSprite.Mirror(texture, SS_Mirror.Vertical);
        }