public void TestMipmaps()
        {
            // load checkers texture
            var tex = new TextureArray2D(IO.LoadImage(TestData.Directory + "checkers.dds"));

            Assert.AreEqual(3, tex.NumMipmaps);
            Assert.AreEqual(4, tex.Size.Width);
            Assert.AreEqual(4, tex.Size.Height);
            TestData.TestCheckersLevel0(tex.GetPixelColors(0, 0));
            TestData.TestCheckersLevel1(tex.GetPixelColors(0, 1));
            TestData.TestCheckersLevel2(tex.GetPixelColors(0, 2));

            // remove mipmaps
            tex = tex.CloneWithoutMipmapsT();
            Assert.AreEqual(1, tex.NumMipmaps);
            Assert.AreEqual(4, tex.Size.Width);
            Assert.AreEqual(4, tex.Size.Height);
            TestData.TestCheckersLevel0(tex.GetPixelColors(0, 0));

            // generate mipmaps again
            tex = tex.GenerateMipmapLevelsT(3);
            Assert.AreEqual(3, tex.NumMipmaps);
            Assert.AreEqual(4, tex.Size.Width);
            Assert.AreEqual(4, tex.Size.Height);
            TestData.TestCheckersLevel0(tex.GetPixelColors(0, 0));
            TestData.TestCheckersLevel1(tex.GetPixelColors(0, 1));
            TestData.TestCheckersLevel2(tex.GetPixelColors(0, 2));
        }
Exemple #2
0
        public void MagnifyCheckers()
        {
            var model        = new ThumbnailModel(new QuadShader());
            var checkers     = new TextureArray2D(IO.LoadImage(TestData.Directory + "checkers.dds"));
            var lvl1Checkers = checkers.CloneWithoutMipmapsT(1);

            var res = model.CreateThumbnail(4, lvl1Checkers, Format.R8G8B8A8_UNorm_SRgb, 0);

            Assert.AreEqual(4, res.Size.Width);
            Assert.AreEqual(4, res.Size.Height);

            var colors = res.GetPixelColors(0, 0);

            TestData.TestCheckersLevel0(colors);
        }
        public void MinifyCheckersMissingMipmaps()
        {
            var models       = new Models(1);
            var model        = new ThumbnailModel(new QuadShader());
            var checkers     = new TextureArray2D(IO.LoadImage(TestData.Directory + "checkers.dds"));
            var lvl0Checkers = checkers.CloneWithoutMipmapsT();

            TestData.TestCheckersLevel0(lvl0Checkers.GetPixelColors(LayerMipmapSlice.Mip0));

            var res = model.CreateThumbnail(2, lvl0Checkers, Format.R8G8B8A8_UNorm_SRgb, 0, models.Scaling);

            Assert.AreEqual(2, res.Size.Width);
            Assert.AreEqual(2, res.Size.Height);

            var colors = res.GetPixelColors(LayerMipmapSlice.Mip0);

            TestData.TestCheckersLevel1(colors);
        }