Exemple #1
0
        // E X A M P L E   M A T E R I A L S

        public static Texture SKY(int w, int h, float density)
        {
            var colors = new uint[2];

            colors[0] = 0x003399;
            colors[1] = 0xFFFFFF;
            return(PERLIN(w, h, 0.5f, 2.8f * density, 8, 1024).colorize(
                       ColorUtility.makeGradient(colors, 1024)));
        }
Exemple #2
0
        public static Texture MARBLE(int w, int h, float density)
        {
            var colors = new uint[3];

            colors[0] = 0x111111;
            colors[1] = 0x696070;
            colors[2] = 0xFFFFFF;
            return(WAVE(w, h, 0.5f, 0.64f * density, 6, 1024).colorize(
                       ColorUtility.makeGradient(colors, 1024)));
        }
Exemple #3
0
        public static Texture WOOD(int w, int h, float density)
        {
            var colors = new uint[3];

            colors[0] = 0x332211;
            colors[1] = 0x523121;
            colors[2] = 0x996633;

            return(GRAIN(w, h, 0.5f, 3f * density, 3, 8, 1024).colorize(
                       ColorUtility.makeGradient(colors, 1024)));
        }
Exemple #4
0
        public static Texture RANDOM(int w, int h)
        {
            var nc     = (int)MathUtility.Random(2, 6);
            var colors = new uint[nc];

            for (var i = 0; i < nc; i++)
            {
                colors[i] = ColorUtility.random();
            }

            var persistency = MathUtility.Random(0.4f, 0.9f);
            var density     = MathUtility.Random(0.5f, 3f);
            var samples     = (int)MathUtility.Random(1, 7f);

            return(PERLIN(w, h, persistency, density, samples, 1024).colorize(
                       ColorUtility.makeGradient(colors, 1024)));
        }
Exemple #5
0
        void readTexture(BinaryReader inStream, bool textureId)
        {
            Texture t = null;

            switch (inStream.ReadSByte())
            {
            case 1:
                t = new Texture(readString(inStream));
                if ((t != null) && textureId)
                {
                    texturePath     = t.path;
                    textureSettings = null;
                    setTexture(t);
                }
                if (!((t == null) || textureId))
                {
                    envmapPath     = t.path;
                    envmapSettings = null;
                    setEnvmap(t);
                }
                break;

            case 2:
            {
                var   w           = readInt(inStream);
                var   h           = readInt(inStream);
                int   num4        = inStream.ReadSByte();
                float persistency = readInt(inStream);
                float density     = readInt(inStream);
                persistency = 0.5f;
                density     = 0.5f;
                int samples = inStream.ReadByte();
                int num8    = inStream.ReadByte();
                var colors  = new uint[num8];
                for (var i = 0; i < num8; i++)
                {
                    colors[i] = (uint)readInt(inStream);
                }
                switch (num4)
                {
                case 1:
                    t = TextureFactory.PERLIN(w, h, persistency, density, samples, 0x400).colorize(ColorUtility.makeGradient(colors, 0x400));
                    break;

                case 2:
                    t = TextureFactory.WAVE(w, h, persistency, density, samples, 0x400).colorize(ColorUtility.makeGradient(colors, 0x400));
                    break;

                case 3:
                    t = TextureFactory.GRAIN(w, h, persistency, density, samples, 20, 0x400).colorize(ColorUtility.makeGradient(colors, 0x400));
                    break;
                }
                if (textureId)
                {
                    texturePath     = null;
                    textureSettings = new TextureSettings(t, w, h, num4, persistency, density, samples, colors);
                    setTexture(t);
                }
                else
                {
                    envmapPath     = null;
                    envmapSettings = new TextureSettings(t, w, h, num4, persistency, density, samples, colors);
                    setEnvmap(t);
                }
                return;
            }
            }
        }