简体   繁体   English

XNA 2D Tile基于纹理的大小

[英]XNA 2D Tile Based Texture Size

I am using XNA game studio to make a 2D Sandbox RPG similar to Terraria & Starbound. 我正在使用XNA游戏工作室制作类似于Terraria&Starbound的2D沙盒RPG。
I have a great tile system but it still takes over 12-13 ms to draw a whole scene at 1920 x 1200 when the screen is full of tiles. 我有一个很棒的拼贴系统,但是当屏幕充满拼贴时,以1920 x 1200绘制整个场景仍需要12-13毫秒。
I have over 15 tile sets currently each one is all together on a 256 x 1024 texture plus each tile set has 6-7 extra tile sets of the same size for rendering the blends with other tiles. 我有15个以上的图块集,目前每个图块都以256 x 1024纹理组合在一起,而且每个图块集都有6-7个相同大小的额外图块集,用于渲染与其他图块的混合。
I am wondering if it would make much of a performance difference if I just created a larger texture at load-time and copied all of the blend textures over using SetData() . 我想知道如果我只是在加载时创建一个较大的纹理并使用SetData()复制所有混合纹理,是否会对性能产生很大的影响。

Is there any performance issues with drawing an 18 x 18 portion of a large texture such as 2048 x 1024 a few hundred times on the screen? 在屏幕上绘制2048 x 1024之类的大纹理的18 x 18部分会出现性能问题吗?

I am using spritemode.texture to draw my tiles which already improved the speed a bit but I am trying to shave off a couple more milliseconds. 我正在使用spritemode.texture绘制我的图块,这已经提高了速度,但是我试图将时间spritemode.texture几毫秒。

That number seems quite high, but the only sure way to find it would be to profile it. 这个数字似乎很高,但是找到它的唯一肯定的方法就是分析它。 SpriteSortMode.Texture and Deferred will be the fastest, some good move there. SpriteSortMode.TextureDeferred将是最快的,一些不错的举措。 If you could share a sample of your spritesheets and rendering code that would be nice, I'm not sure why you would need all of that. 如果您可以共享示例表格和渲染代码的示例,那我就不确定为什么需要全部这些。 Using SourceRectangle overloads of spritebatch should not effect your draw time, but again, the only way to find out for sure if to profile it. 使用spritebatch的SourceRectangle重载不会影响绘制时间,但是再次重申,这是确定是否要对其进行轮廓分析的唯一方法。

Ofcourse, the less texture swaps the better, so packing everything into 1 texture will be a good idea, and there is a nice code sample on MSDN about it. 当然,纹理交换越少越好,因此将所有内容打包为1个纹理将是一个好主意,并且MSDN上有一个不错的代码示例

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM