0

抱歉,这可能是一个非常基本的问题,我有多个不同大小和坐标的小纹理,我想在此应用一些过渡。所以我需要将所有这些纹理组合成一个大纹理,以制作一个单一的屏幕尺寸纹理。

4

3 回答 3

1

你正在寻找的是所谓的纹理图集

在实时计算机图形学中,纹理图集是一个大图像,或“图集”,其中包含许多较小的子图像,每个子图像都是 3D 对象某些部分的纹理

谷歌搜索将为您提供生成它们的摘要和工具。

于 2011-09-05T10:54:53.643 回答
0

我会说如果您不需要实时完成此操作(即源纹理不会更改),那么只需在您最喜欢的图形编辑器中执行此操作(例如 mspaint!)。


如果您确实想在游戏中执行此操作,请查看以下问题:Render buffer to texture2D object in XNA

于 2011-09-05T07:09:25.600 回答
0

为您的任务修改此内容:

    /// <summary>
    /// Line up the textures in list horizontally. Warning: All textures MUST BE one height and in strong order
    /// </summary>
    /// <param name="device">D3D device</param>
    /// <param name="textures">List of textures</param>
    /// <returns>Combined texture</returns>
    public static Texture LineUpTexturesHorizontally ( Device device, List < Texture > textures )
    {
        int dstWidth = textures.Select ( texture => texture.GetSurfaceLevel ( 0 ) ).Select ( surface => surface.Description.Width ).Sum ( );
        int dstHeight = textures [ 0 ].GetSurfaceLevel ( 0 ).Description.Height;
        Texture dstTexture = CreateTexture ( device, dstWidth, dstHeight, Color.Orange, TexMipLevels, true );
        Surface dstSurface = dstTexture.GetSurfaceLevel ( 0 );
        Point insPoint = new Point ( 0, 0 );
        for ( int i = 0; i < textures.Count; i++ )
        {
            PaletteEntry [ ] pal; // = new PaletteEntry[ 256 ];
            Texture srcTexture = textures [ i ];
            Surface srcSurface = srcTexture.GetSurfaceLevel ( 0 );
            int srcWidth = srcSurface.Description.Width;
            int srcHeight = srcSurface.Description.Height;
            Rectangle srcRectangle = new Rectangle ( 0, 0, srcWidth, srcHeight );
            Rectangle dstRectangle = new Rectangle ( insPoint, new Size ( srcWidth, srcHeight ) );
            SurfaceLoader.FromSurface ( dstSurface, out pal, dstRectangle, srcSurface, out pal, srcRectangle, Filter.None, 0 );
            insPoint.X += srcWidth;
        }
        return dstTexture;
    }
于 2018-09-30T16:13:24.260 回答