Пример #1
0
        // Generate a generally boring metallic-like texture (ships and stations use this)
        public static SS_Texture GenerateBaseTexture(int seed, int textureWidth, int textureHeight, int detail)
        {
            SS_Texture tmpTexture = new SS_Texture(textureWidth, textureHeight, Color.clear);

            Perlin noise = new Perlin(0.005, 2, 0.5, 6, seed, QualityMode.Low);

            int offsetX = tmpTexture.Width / detail;
            int offsetY = tmpTexture.Height / detail;

            for (int y = 0; y < tmpTexture.Height; y += offsetY)
            {
                for (int x = 0; x < tmpTexture.Width; x += offsetX)
                {
                    float n1 = (float)noise.GetValue(x, y, 0);
                    n1 = (n1 + 3.0f) * 0.25f;
                    n1 = Mathf.Clamp(n1, 0.5f, 1f);

                    float n2 = (float)noise.GetValue(x, y, 0);
                    n2 = (n2 + 3.0f) * 0.25f;
                    n2 = Mathf.Clamp(n2, 0.95f, 1f);

                    Color c = new Color(n1, n1, n1, 1f);

                    SS_Drawing.RectangleFill(tmpTexture, x, y, offsetX, offsetY, c, c);

                    Color current = tmpTexture.GetPixel(x, y);
                    Color c3      = new Color(current.r * n2, current.g * n2, current.b * n2);
                    SS_Drawing.Line(tmpTexture, x, y, x, y + detail, c3);
                    SS_Drawing.Line(tmpTexture, x, y, x + detail, y, c3);
                }
            }

            return(tmpTexture);
        }