Example #1
0
        public static TextureCubeMap CreateGLCubeMap(DDS dds)
        {
            TextureCubeMap texture = new TextureCubeMap();
            var            cubemap = GetArrayFaces(dds, 6);

            bool Compressed = dds.IsCompressed();

            if (Compressed)
            {
                texture.LoadImageData((int)dds.header.width,
                                      (InternalFormat)PixelInternalFormat.CompressedRgbaS3tcDxt1Ext,
                                      cubemap[0].mipmaps,
                                      cubemap[1].mipmaps,
                                      cubemap[2].mipmaps,
                                      cubemap[3].mipmaps,
                                      cubemap[4].mipmaps,
                                      cubemap[5].mipmaps);
            }
            else
            {
                texture.LoadImageData((int)dds.header.width, new SFGraphics.GLObjects.Textures.TextureFormats.TextureFormatUncompressed(PixelInternalFormat.Rgba,
                                                                                                                                        OpenTK.Graphics.OpenGL.PixelFormat.Rgba, OpenTK.Graphics.OpenGL.PixelType.UnsignedByte),
                                      cubemap[0].mipmaps[0],
                                      cubemap[1].mipmaps[0],
                                      cubemap[2].mipmaps[0],
                                      cubemap[3].mipmaps[0],
                                      cubemap[4].mipmaps[0],
                                      cubemap[5].mipmaps[0]);
            }

            return(texture);
        }
        public DefaultTextures()
        {
            LoadBitmap(uvPattern, "DefaultTextures/UVPattern.png");

            LoadBitmap(defaultWhite, "DefaultTextures/default_White.png");
            LoadBitmap(defaultPrm, "DefaultTextures/default_Params.tif");
            LoadBitmap(defaultNormal, "DefaultTextures/default_normal.png");
            LoadBitmap(defaultBlack, "DefaultTextures/default_black.png");

            LoadBitmap(renderFont, "DefaultTextures/render_font.png");
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (float)TextureMagFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (float)TextureMinFilter.Nearest);

            LoadBitmap(iblLut, "DefaultTextures/ibl_brdf_lut.png");

            using (var bmp = new Bitmap("DefaultTextures/default_cube_black.png"))
                blackCube.LoadImageData(bmp, 8);

            LoadDiffusePbr();
            LoadSpecularPbr();

            foreach (var prop in GetType().GetProperties())
            {
                if (prop.PropertyType == typeof(Texture))
                {
                    TextureByName.Add(prop.Name, (Texture)prop.GetValue(this));
                }
            }
        }
        public void BitmapFaces()
        {
            // Will fail if exception is thrown.
            var texture = new TextureCubeMap();

            texture.LoadImageData(new Bitmap(8, 8 * 8 * 6), 8);

            Assert.AreEqual(8, texture.Width);
            Assert.AreEqual(8, texture.Height);
        }
Example #4
0
        public static TextureCubeMap CreateGLCubeMap(DDS dds)
        {
            TextureCubeMap texture = new TextureCubeMap();
            List <byte[]>  cubemap = GetArrayFaces(dds.bdata, 6);

            texture.LoadImageData((int)dds.header.width, new SFGraphics.GLObjects.Textures.TextureFormats.TextureFormatUncompressed(PixelInternalFormat.Rgba,
                                                                                                                                    OpenTK.Graphics.OpenGL.PixelFormat.Rgba, OpenTK.Graphics.OpenGL.PixelType.Float), cubemap[0],
                                  cubemap[1], cubemap[2], cubemap[3], cubemap[4], cubemap[5]);
            return(texture);
        }
        public void NotCompressedInternalFormat()
        {
            var textureCubeMap = new TextureCubeMap();

            var e = Assert.ThrowsException <ArgumentException>(() =>
                                                               textureCubeMap.LoadImageData(128, InternalFormat.Rgba,
                                                                                            mipmaps, mipmaps, mipmaps, mipmaps, mipmaps, mipmaps));

            Assert.AreEqual("The InternalFormat is not a compressed image format.", e.Message);
        }
        public void UncompressedGenerateMipmaps()
        {
            var texture = new TextureCubeMap();
            var format  = new TextureFormatUncompressed(PixelInternalFormat.Rgba32f, PixelFormat.Rgba, PixelType.Float);

            texture.LoadImageData(128, format,
                                  mipmaps[0], mipmaps[0], mipmaps[0], mipmaps[0], mipmaps[0], mipmaps[0]);

            Assert.AreEqual(128, texture.Width);
            Assert.AreEqual(128, texture.Height);
        }
        public void CorrectFormatSameMipmapCount()
        {
            // Will fail if exception is thrown.
            var texture = new TextureCubeMap();

            texture.LoadImageData(128, InternalFormat.CompressedRgbaS3tcDxt1Ext,
                                  mipmaps, mipmaps, mipmaps, mipmaps, mipmaps, mipmaps);

            Assert.AreEqual(128, texture.Width);
            Assert.AreEqual(128, texture.Height);
        }
Example #8
0
        public DefaultTextures()
        {
            LoadBitmap(uvPattern, "DefaultTextures/UVPattern.png");

            LoadBitmap(defaultWhite, "DefaultTextures/default_White.png");
            LoadBitmap(defaultPrm, "DefaultTextures/default_Params.tif");
            LoadBitmap(defaultNormal, "DefaultTextures/default_normal.tif");
            LoadBitmap(defaultBlack, "DefaultTextures/default_black.png");

            using (var bmp = new Bitmap("DefaultTextures/default_cube_black.png"))
                blackCube.LoadImageData(bmp, 8);

            LoadDiffusePbr();
            LoadSpecularPbr();
        }
        public void InvalidMipmapCount()
        {
            List <byte[]> mipmapsBig = new List <byte[]>
            {
                new byte[16]
            };

            var textureCubeMap = new TextureCubeMap();

            var e = Assert.ThrowsException <ArgumentOutOfRangeException>(() =>
                                                                         textureCubeMap.LoadImageData(128, InternalFormat.CompressedRgbaS3tcDxt1Ext,
                                                                                                      mipmaps, mipmaps, mipmaps, mipmapsBig, mipmaps, mipmaps));

            Assert.IsTrue(e.Message.Contains("Mipmap count is not equal for all faces."));
            Assert.AreEqual("mips", e.ParamName);
        }
Example #10
0
        private void LoadSpecularPbr()
        {
            specularPbr = new TextureCubeMap();
            var surfaceData = new List <List <byte[]> >();

            AddCubeMipmaps(surfaceData, "x+");
            AddCubeMipmaps(surfaceData, "x-");
            AddCubeMipmaps(surfaceData, "y+");
            AddCubeMipmaps(surfaceData, "y-");
            AddCubeMipmaps(surfaceData, "z+");
            AddCubeMipmaps(surfaceData, "z-");

            var format = new TextureFormatUncompressed(PixelInternalFormat.Rgba32f, PixelFormat.Rgba, PixelType.Float);

            specularPbr.LoadImageData(64, format, surfaceData[0], surfaceData[1], surfaceData[2], surfaceData[3], surfaceData[4], surfaceData[5]);
        }
Example #11
0
        private void LoadSpecularPbr()
        {
            specularPbr = new TextureCubeMap();
            var surfaceData = new List <List <byte[]> >();

            for (int surface = 0; surface < 6; surface++)
            {
                var mipmaps = new List <byte[]>();
                for (int mip = 0; mip < 10; mip++)
                {
                    var mipData = System.IO.File.ReadAllBytes($"DefaultTextures/specularSdr{surface}{mip}.bin");
                    mipmaps.Add(mipData);
                }
                surfaceData.Add(mipmaps);
            }
            specularPbr.LoadImageData(512, InternalFormat.CompressedRgbaS3tcDxt1Ext, surfaceData[0], surfaceData[1], surfaceData[2], surfaceData[3], surfaceData[4], surfaceData[5]);
        }
Example #12
0
        private void LoadDiffusePbr()
        {
            diffusePbr = new TextureCubeMap();

            var surfaceData = new List <List <byte[]> >();

            for (int surface = 0; surface < 6; surface++)
            {
                var mipData = System.IO.File.ReadAllBytes($"DefaultTextures/diffuseSdr{surface}{0}.bin");
                surfaceData.Add(new List <byte[]>()
                {
                    mipData
                });
            }
            diffusePbr.LoadImageData(128, InternalFormat.CompressedRgbaS3tcDxt1Ext, surfaceData[0], surfaceData[1], surfaceData[2], surfaceData[3], surfaceData[4], surfaceData[5]);

            // Don't Use mipmaps.
            diffusePbr.MagFilter = TextureMagFilter.Linear;
            diffusePbr.MinFilter = TextureMinFilter.Linear;
        }
Example #13
0
 public static TextureCubeMap CreateTextureCubeMap(NutTexture t)
 {
     if (TextureFormatTools.IsCompressed(t.pixelInternalFormat))
     {
         // Compressed cubemap with mipmaps.
         TextureCubeMap texture = new TextureCubeMap();
         texture.LoadImageData(t.Width, (InternalFormat)t.pixelInternalFormat,
                               t.surfaces[0].mipmaps, t.surfaces[1].mipmaps, t.surfaces[2].mipmaps,
                               t.surfaces[3].mipmaps, t.surfaces[4].mipmaps, t.surfaces[5].mipmaps);
         return(texture);
     }
     else
     {
         // Uncompressed cube map with no mipmaps.
         TextureCubeMap texture = new TextureCubeMap();
         texture.LoadImageData(t.Width, new TextureFormatUncompressed(t.pixelInternalFormat, t.pixelFormat, t.pixelType),
                               t.surfaces[0].mipmaps[0], t.surfaces[1].mipmaps[0], t.surfaces[2].mipmaps[0],
                               t.surfaces[3].mipmaps[0], t.surfaces[4].mipmaps[0], t.surfaces[5].mipmaps[0]);
         return(texture);
     }
 }
Example #14
0
        private void LoadDiffusePbr()
        {
            diffusePbr = new TextureCubeMap();

            var surfaceData = new List <List <byte[]> >();

            AddIrrFace(surfaceData, "x+");
            AddIrrFace(surfaceData, "x-");
            AddIrrFace(surfaceData, "y+");
            AddIrrFace(surfaceData, "y-");
            AddIrrFace(surfaceData, "z+");
            AddIrrFace(surfaceData, "z-");


            var format = new TextureFormatUncompressed(PixelInternalFormat.Rgba32f, PixelFormat.Rgba, PixelType.Float);

            diffusePbr.LoadImageData(64, format, surfaceData[0], surfaceData[1], surfaceData[2], surfaceData[3], surfaceData[4], surfaceData[5]);

            // Don't Use mipmaps.
            diffusePbr.MagFilter = TextureMagFilter.Linear;
            diffusePbr.MinFilter = TextureMinFilter.Linear;
        }
Example #15
0
        public DefaultTextures()
        {
            LoadBitmap("uvPattern", uvPattern, "DefaultTextures/UVPattern.png");

            LoadBitmap("defaultWhite", defaultWhite, "DefaultTextures/default_White.png");
            LoadBitmap("defaultPrm", defaultPrm, "DefaultTextures/default_Params.tif");
            LoadBitmap("defaultNormal", defaultNormal, "DefaultTextures/default_normal.tif");
            LoadBitmap("defaultBlack", defaultBlack, "DefaultTextures/default_black.png");

            LoadBitmap("renderFront", renderFont, "DefaultTextures/render_font.png");
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (float)TextureMagFilter.Nearest);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (float)TextureMinFilter.Nearest);

            LoadBitmap("iblBrdf", iblLut, "DefaultTextures/ibl_brdf_lut.png");

            using (var bmp = new Bitmap("DefaultTextures/default_cube_black.png"))
                blackCube.LoadImageData(bmp, 8);
            TextureByName.Add("defaultBlackCube", blackCube);

            LoadDiffusePbr();
            LoadSpecularPbr();
            TextureByName.Add("defaultSpecCube", specularPbr);
        }
Example #16
0
        public static Dictionary <NudEnums.DummyTexture, Texture> CreateNudDummyTextures()
        {
            Dictionary <NudEnums.DummyTexture, Texture> dummyTextures = new Dictionary <NudEnums.DummyTexture, Texture>();

            // Dummy textures.
            TextureCubeMap stageMapHigh = new TextureCubeMap();

            stageMapHigh.LoadImageData(Properties.Resources._10102000, 128);
            dummyTextures.Add(NudEnums.DummyTexture.StageMapHigh, stageMapHigh);

            TextureCubeMap stageMapLow = new TextureCubeMap();

            stageMapLow.LoadImageData(Properties.Resources._10101000, 128);
            dummyTextures.Add(NudEnums.DummyTexture.StageMapLow, stageMapLow);

            Texture2D dummyRamp = new Texture2D();

            dummyRamp.LoadImageData(Properties.Resources._10080000);
            dummyTextures.Add(NudEnums.DummyTexture.DummyRamp, dummyRamp);

            Texture2D pokemonStadiumDummyTex = new Texture2D();

            pokemonStadiumDummyTex.LoadImageData(Properties.Resources._10040001);
            dummyTextures.Add(NudEnums.DummyTexture.PokemonStadium, pokemonStadiumDummyTex);

            Texture2D punchOutDummyTex = new Texture2D();

            punchOutDummyTex.LoadImageData(Properties.Resources._10040000);
            dummyTextures.Add(NudEnums.DummyTexture.PunchOut, punchOutDummyTex);

            Texture2D shadowMapDummyTex = new Texture2D();

            shadowMapDummyTex.LoadImageData(Properties.Resources._10100000);
            dummyTextures.Add(NudEnums.DummyTexture.ShadowMap, shadowMapDummyTex);

            return(dummyTextures);
        }
Example #17
0
        /// <summary>
        /// Gets the SFTexture of this surface
        /// </summary>
        /// <returns></returns>
        public Texture GetRenderTexture()
        {
            if (renderTexture == null)
            {
                if (Arrays.Count == 6)
                {
                    var cube = new TextureCubeMap()
                    {
                        MinFilter = TextureMinFilter.Linear,
                        MagFilter = TextureMagFilter.Linear
                    };
                    if (TextureFormatTools.IsCompressed(InternalFormat))
                    {
                        cube.LoadImageData(Width, InternalFormat,
                                           Arrays[0].Mipmaps, Arrays[1].Mipmaps, Arrays[2].Mipmaps,
                                           Arrays[3].Mipmaps, Arrays[4].Mipmaps, Arrays[5].Mipmaps);
                    }
                    else
                    {
                        var format = new TextureFormatUncompressed((PixelInternalFormat)PixelFormat, PixelFormat, PixelType);

                        cube.LoadImageData(Width, format,
                                           Arrays[0].Mipmaps[0], Arrays[1].Mipmaps[0], Arrays[2].Mipmaps[0],
                                           Arrays[3].Mipmaps[0], Arrays[4].Mipmaps[0], Arrays[5].Mipmaps[0]);
                    }
                    renderTexture = cube;
                }
                else
                {
                    var sfTex = new Texture2D()
                    {
                        // Set defaults until all the sampler parameters are added.
                        TextureWrapS = TextureWrapMode.Repeat,
                        TextureWrapT = TextureWrapMode.Repeat,
                    };

                    if (TextureFormatTools.IsCompressed(InternalFormat))
                    {
                        // hack
                        // trying to load mipmaps with similar sizes seems to not work
                        var mipTest  = new List <byte[]>();
                        int prevsize = 0;
                        foreach (var v in Arrays[0].Mipmaps)
                        {
                            if (v.Length == prevsize)
                            {
                                continue;
                            }
                            mipTest.Add(v);
                            prevsize = v.Length;
                        }
                        sfTex.LoadImageData(Width, Height, mipTest, InternalFormat);
                    }
                    else
                    {
                        // TODO: Uncompressed mipmaps
                        var format = new TextureFormatUncompressed(PixelInternalFormat.Rgba, PixelFormat, PixelType);
                        sfTex.LoadImageData(Width, Height, Arrays[0].Mipmaps, format);
                    }
                    renderTexture = sfTex;
                }
            }
            return(renderTexture);
        }