Esempio n. 1
0
        public void  SetPixel()
        {
            Texture3D tex = new Texture3D(2, 2, 2, 4, 32);

            tex.SetPixel(0, 0, 0, new ColorRGBA(1, 2, 3, 4));

            Assert.AreEqual(1, tex.GetChannel(0, 0, 0, 0));
            Assert.AreEqual(2, tex.GetChannel(0, 0, 0, 1));
            Assert.AreEqual(3, tex.GetChannel(0, 0, 0, 2));
            Assert.AreEqual(4, tex.GetChannel(0, 0, 0, 3));
        }
Esempio n. 2
0
        public void  GetChannelBilinear_IsCorrect()
        {
            int width    = 33;
            int height   = 32;
            int depth    = 32;
            int channels = 3;
            int bitDepth = 32;

            Texture3D tex = CreateIndexFilledTexture(width, height, depth, channels, bitDepth);

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    for (int z = 0; z < depth; z++)
                    {
                        float fx = x / (width - 1.0f);
                        float fy = y / (height - 1.0f);
                        float fz = z / (depth - 1.0f);

                        for (int c = 0; c < channels; c++)
                        {
                            int idx = (x + y * width + z * width * height) * channels + c;
                            Assert.AreEqual(idx, tex.GetChannel(fx, fy, fz, c));
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public void  GetChannel_IsCorrect()
        {
            int width    = 33;
            int height   = 32;
            int depth    = 32;
            int channels = 3;
            int bitDepth = 32;

            Texture3D tex = CreateIndexFilledTexture(width, height, depth, channels, bitDepth);

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    for (int z = 0; z < depth; z++)
                    {
                        for (int c = 0; c < channels; c++)
                        {
                            int idx = (x + y * width + z * width * height) * channels + c;
                            Assert.AreEqual(idx, tex.GetChannel(x, y, z, c));
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        public void  BilinearFilter_DoesClamp()
        {
            int width    = 2;
            int height   = 2;
            int depth    = 2;
            int bitDepth = 32;

            Texture3D tex = CreateXYZFilledTexture(width, height, depth, bitDepth, TEXTURE_WRAP.CLAMP);

            Assert.AreEqual(0.0, tex.GetChannel(-0.5f, 0.0f, 0.0f, 0));
            Assert.AreEqual(0.0, tex.GetChannel(-0.25f, 0.0f, 0.0f, 0));
            Assert.AreEqual(0.0, tex.GetChannel(0.0f, 0.0f, 0.0f, 0));
            Assert.AreEqual(0.25, tex.GetChannel(0.25f, 0.0f, 0.0f, 0));
            Assert.AreEqual(0.5, tex.GetChannel(0.5f, 0.0f, 0.0f, 0));
            Assert.AreEqual(0.75, tex.GetChannel(0.75f, 0.0f, 0.0f, 0));
            Assert.AreEqual(1.0, tex.GetChannel(1.0f, 0.0f, 0.0f, 0));
            Assert.AreEqual(1.0, tex.GetChannel(1.25f, 0.0f, 0.0f, 0));
            Assert.AreEqual(1.0, tex.GetChannel(1.5f, 0.0f, 0.0f, 0));

            Assert.AreEqual(0.0, tex.GetChannel(0.0f, -0.5f, 0.0f, 1));
            Assert.AreEqual(0.0, tex.GetChannel(0.0f, -0.25f, 0.0f, 1));
            Assert.AreEqual(0.0, tex.GetChannel(0.0f, 0.0f, 0.0f, 1));
            Assert.AreEqual(0.25, tex.GetChannel(0.0f, 0.25f, 0.0f, 1));
            Assert.AreEqual(0.5, tex.GetChannel(0.0f, 0.5f, 0.0f, 1));
            Assert.AreEqual(0.75, tex.GetChannel(0.0f, 0.75f, 0.0f, 1));
            Assert.AreEqual(1.0, tex.GetChannel(0.0f, 1.0f, 0.0f, 1));
            Assert.AreEqual(1.0, tex.GetChannel(0.0f, 1.25f, 0.0f, 1));
            Assert.AreEqual(1.0, tex.GetChannel(0.0f, 1.5f, 0.0f, 1));

            Assert.AreEqual(0.0, tex.GetChannel(0.0f, 0.0f, -0.0f, 2));
            Assert.AreEqual(0.0, tex.GetChannel(0.0f, 0.0f, -0.25f, 2));
            Assert.AreEqual(0.0, tex.GetChannel(0.0f, 0.0f, 0.0f, 2));
            Assert.AreEqual(0.25, tex.GetChannel(0.0f, 0.0f, 0.25f, 2));
            Assert.AreEqual(0.5, tex.GetChannel(0.0f, 0.0f, 0.5f, 2));
            Assert.AreEqual(0.75, tex.GetChannel(0.0f, 0.0f, 0.75f, 2));
            Assert.AreEqual(1.0, tex.GetChannel(0.0f, 0.0f, 1.0f, 2));
            Assert.AreEqual(1.0, tex.GetChannel(0.0f, 0.0f, 1.25f, 2));
            Assert.AreEqual(1.0, tex.GetChannel(0.0f, 0.0f, 1.5f, 2));
        }
Esempio n. 5
0
        public void  GetChannel_DoesMirror()
        {
            int width    = 4;
            int height   = 4;
            int depth    = 4;
            int bitDepth = 32;

            Texture3D tex = CreateXYZFilledTexture(width, height, depth, bitDepth, TEXTURE_WRAP.MIRROR);

            Assert.AreEqual(2, tex.GetChannel(-2, 0, 0, 0));
            Assert.AreEqual(1, tex.GetChannel(-1, 0, 0, 0));
            Assert.AreEqual(0, tex.GetChannel(0, 0, 0, 0));
            Assert.AreEqual(1, tex.GetChannel(1, 0, 0, 0));
            Assert.AreEqual(2, tex.GetChannel(2, 0, 0, 0));
            Assert.AreEqual(3, tex.GetChannel(3, 0, 0, 0));
            Assert.AreEqual(2, tex.GetChannel(4, 0, 0, 0));
            Assert.AreEqual(1, tex.GetChannel(5, 0, 0, 0));

            Assert.AreEqual(2, tex.GetChannel(0, -2, 0, 1));
            Assert.AreEqual(1, tex.GetChannel(0, -1, 0, 1));
            Assert.AreEqual(0, tex.GetChannel(0, 0, 0, 1));
            Assert.AreEqual(1, tex.GetChannel(0, 1, 0, 1));
            Assert.AreEqual(2, tex.GetChannel(0, 2, 0, 1));
            Assert.AreEqual(3, tex.GetChannel(0, 3, 0, 1));
            Assert.AreEqual(2, tex.GetChannel(0, 4, 0, 1));
            Assert.AreEqual(1, tex.GetChannel(0, 5, 0, 1));

            Assert.AreEqual(2, tex.GetChannel(0, 0, -2, 2));
            Assert.AreEqual(1, tex.GetChannel(0, 0, -1, 2));
            Assert.AreEqual(0, tex.GetChannel(0, 0, 0, 2));
            Assert.AreEqual(1, tex.GetChannel(0, 0, 1, 2));
            Assert.AreEqual(2, tex.GetChannel(0, 0, 2, 2));
            Assert.AreEqual(3, tex.GetChannel(0, 0, 3, 2));
            Assert.AreEqual(2, tex.GetChannel(0, 0, 4, 2));
            Assert.AreEqual(1, tex.GetChannel(0, 0, 5, 2));
        }