简体   繁体   English

基于体素的游戏的纹理映射或纹理平铺? (统一)

[英]Texture mapping or texture tiling for a voxel-based game? (Unity)

I'm building a voxel-based game that visually resembles Minecraft in many aspects, namely low-resolution textures and square blocks.我正在构建一个基于体素的游戏,它在许多方面在视觉上类似于 Minecraft,即低分辨率纹理和方块。

Obviously optimization is important for these kinds of games for a whole host of reasons, but there are two that I have come across that seem mutually exclusive: texture mapping and texture tiling.显然优化对于这类游戏很重要,原因有很多,但我遇到过两个似乎相互排斥的:纹理映射和纹理平铺。

With texture mapping, I would generate a single texture map of all existing block textures, which I've read can greatly improve performance.使用纹理映射,我将生成所有现有块纹理的单个纹理映射,我读过它可以大大提高性能。 The issue with this optimization is that texture tiling doesn't appear to be possible, as that technique relies upon the first and last pixels of a texture file being for the same texture, which is no longer true when mapping is used.这种优化的问题是纹理平铺似乎是不可能的,因为该技术依赖于纹理文件的第一个和最后一个像素用于相同的纹理,当使用映射时不再如此。 This also means that the messes of neighboring blocks can never be combined as far as I am aware.这也意味着就我所知,相邻块的混乱永远无法合并。

With tiling, large groups of blocks with identical textures can be combined into a single, 2 tri mesh.通过平铺,可以将具有相同纹理的大组块组合成一个单一的 2 个三网格。 While efficient, each texture would need its own Material object, which means each differing block texture would need its own submesh.虽然高效,但每个纹理都需要自己的 Material 对象,这意味着每个不同的块纹理都需要自己的子网格。

Which of these would be more likely to offer superior overall performance?其中哪些更有可能提供卓越的整体性能?

They seem mutually exclusive, but they aren't realy.它们看起来相互排斥,但实际上并非如此。
Minecraft doesn't repeat the texture, it repeats the UV's. Minecraft 不会重复纹理,而是重复 UV。

How it works:这个怎么运作:
For all rectangles sharing a texture, make sure they have their UV's at the same place.对于共享纹理的所有矩形,请确保它们的 UV 位于同一位置。
For example, all grass rectangles should have their UV's on top of the grass texture in the atlas.例如,所有草矩形都应该在图集中的草纹理顶部有它们的 UV。
To make it looks nice, you would need seamless textures .为了让它看起来不错,你需要无缝纹理
Also to prevent edge bleeding, you would need to make sure that all textures have some padding in between.同样为了防止边缘渗色,您需要确保所有纹理之间都有一些填充

Example:例子:
I made a quick blender project showing it.我做了一个快速搅拌机项目来展示它。
The sideways rectangles all have the UV at the same texture area, while the top one has it's UV on a different texture area.横向矩形都在同一纹理区域具有 UV,而顶部矩形在不同纹理区域具有 UV。
The "repeat" is done by using seamless textures in the atlas. “重复”是通过在地图集中使用无缝纹理来完成的。
In this case.在这种情况下。 no padding was added, as it's not needed for pixelated textures.没有添加填充,因为像素化纹理不需要它。

在此处输入图片说明 Texture is taken from Minecraft.纹理取自 Minecraft。

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

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