制作更好的游戏纹理:'2的幂次'和适当的图片大小

制作更好的游戏纹理:'2的幂次'和适当的图片大小

太阳火神的美丽人生 (http://blog.csdn.net/opengl_es)

本文遵循“署名-非商业用途-保持一致”创作公用协议

转载请保留此句:太阳火神的美丽人生 -  本博客专注于 敏捷开发及移动和物联设备研究:iOS、Android、Html5、Arduino、pcDuino,否则,出自本博客的文章拒绝转载或再转载,谢谢合作。

转自:http://www.katsbits.com/tutorials/textures/make-better-textures-correct-size-and-power-of-two.php

制作更好的游戏纹理:'2的幂次'和适当的图片大小

Making better textures for games, 'power of two' and proper image 

Contents
Resources

There are a couple of fundamental 'rules' applicable to making content for any sort of interactive media or 'game' that need particular attention paid to them. Whilst ignoring them won't always or necessarily 'break' a game the content is going in to, doing
so will effect performance detrimentally, and to varying degrees, depending on how poorly implemented they are.

The following tutorial will discuss one of the core 'rules', that of texture size, their dimensions and how that relates to a form of texture optimisation, something commonly called the "power of two" rule.

What type of games use this rule ^

All of them, because it's an underlying technology requirement so it's applicable to First Person Shooter(FPS) games as much as it is to Massive Multi-player Online (MMO), Role Playing Game (RPG), or tovirtual worlds or 3D
chat
 services. The technology behind every type of game is built on the same fundamental power of two ruleirrespective.

Why do I need to use 'power of two' ^

You don't, but your media most certainly does and that's regardless as to what you do to it. The rule is a fundamental necessity due to the way game engines work, there's actually a long history associated
with game and content development that has to do with the way computers manage and process data in 'chunks' for purposes of efficiency. For game content creation, textures in particular, it's these chunks that are important with regards to the power of
two rule
 as it sets hard coded, physical restrictions on media in such a way that it must conform to it directly.

And here-in lies the problem where textures are concerned, if they don't conform to the expected parameters, game are forced to physically alter assets and in so doing, waste resources both in terms of time and processing power, fixing the problem.
In effect the essence of the power of two rule is 'optimisation',
being as efficient and 'lite' as possible whilst providing the user an appropriate visual experience.



A visual representation, in Blender, of what a game would do to a texture when applied to something if it didn't resize and fix badly proportioned images. A) would happen if texture were loaded in 'as is' when incorrectly sized - red areas
indicate areas of the model that wouldn't have anything applied. B) is what happens when a game resizes a bad texture, note the areas of mismatch between faces, something commonly the result. And C) a properly and correctly sized and proportioned texture applied
to an object without any of the aforementioned problems.

So what's the problem I hear you ask. If you think beyond just a single image to that of a scene full of content, all of which is covered with randomly sized and jumbled textures that adds up to a lot of additional processing time and power that could have
otherwise been used to do something more meaningful. It's not a singular problem either because every time the game pulls in a texture to render to screen, it's having to waste resources resizing to fit, each and every time.

What is the power of two rule ^

In short, it's a simple set of criteria applicable to all game related images that makes sure they conform to a series of regular dimensions. Typically this means doubling up or dividing down by two. So texture sizes that
have or are limited to "8", "16", "32", "64", "128", "256", "512", "1024", "2048" (or higher for more modern
games) in one or more width/height direction are regarded as being valid and properly optimised for quick loading into a game and processing into memory.

Shown below are some typical examples of textures made for games. The first set (orangey coloured ones on the left) use the correct (or 'valid') power of two dimensions. The second don't (the blue coloured ones to the right), as is highlighted by the visible
red area representing the amount of space the texturesshould be occupying; the amount of red visible directly correlates to the amount of forced resizing an engine is required to do to fix the problem of incorrect proportions so the textures can be
used properly.

These are valid or recommended

  • 64 x 64
  • 128 x 128
  • 256 x 64
  • 256 x 128
  • 256 x 256

These are invalid or not recommended

  • 46 x 60

  • 120 x 123

  • 235 x 57

  • 250 x 111

  • 239 x 216

Conclusion ^

Ignoring the power of two rule has a number of knock-on effects for texture making, one of which relates directly to image quality. Because a game engine has to physically adjust the size and dimensions of incorrectly proportioned image it degrades the fidelity
of the image itself, so fine details - the freckles on a character models skin, or the pattern of fabric on a piece of furniture - become blurred, pixilated or have some other visual artifacts appear due to the resize process having to extrapolating the necessary
data from what's available. For example, an image that's 239x216 (51,624 pixels) is missing the additional 13,912 pixels that would make it a correctly proportioned 256x256 image (65,536 pixels). As this 'extra' data has to come from somewhere, the engine
looks at what's available and then 'interpolates' as best it can, essentially it's making stuff up so it can fill the gaps; the blurring is the direct result of additional pixels created by the process, filling in the missing data.

  • Blurring due to forced resize in additional to compression artifacts from JPG images


  • Close up shows pixilation issues due to image resizing by the game engine - note additional distortion pulling the "3" out of shape compared to the original
  • Compression only artifacts as a result of using JPG images - image left 'as is'


  • Close up showing jpg compression only artifacts, despite the jpg format the number "3" is still relatively 'clear' and undistorted

This then leads the texture artist to think there's a problem with the format being used, exacerbated when using a 'lossy' formats like JPEG, or that there's a problem with the game engine and technology, when that fact it's neither and instead a matter of
not knowing about proper texture proportions.

The fix isn't to change to a format that has 'better' compression, i.e. a format using 'loss-less' compression like PNG, TGA et-al, and usually at the expense of increasing file size a few kilobytes or megabytes. Nor is it to use much larger textures, again
at the expense of increasing file size - especially moot where textures are physically resized smaller at runtime. The solution is to pay greater attention to the size of the original image, making sure they're properly proportioned so they're loaded into,
and displayed by, a game 'as is'.

In other words, it's always best to get image proportions right from the get-go, avoiding over-taxing the system and forcing it to mess up your work.

You are: Home » Tutorials » Texturing

Please note full support is better suited posted to KatsBits Forum.
Comments are moderated.

时间: 2024-12-20 23:52:56

制作更好的游戏纹理:'2的幂次'和适当的图片大小的相关文章

高级游戏制作:Flash制作物体弹跳电脑游戏

高级 标签:flash游戏开发 Flash实例教程 Flash Actionscript制作游戏 Flash高级技巧. Flash制作物体弹跳电脑游戏,这是一种背景不动的一个物体可以弹跳,可以左右走动的小游戏.比较基础的游戏.在文章的最后提供所有演示的Flash源文件. 启动Flash,首先修改文档属性. 首先制作两个电影剪辑一个是背景,绘制一个矩形小块来当背景.加入AS为:stop(),让它开始就停止. 另外一个是运动的物体,给大家截图如下. 回到主场景,我们用Actionscript来实现其

Photoshop制作华丽的金色祥云纹理鸡年生肖字

  ps教程          Photoshop制作华丽的金色祥云纹理鸡年生肖字            效果字重点是文字纹理和质感部分的制作,尤其是中间的纹理层,用图层样式先做出质感和颜色,然后在纹理中加入祥云图案,这样就可以得到浮雕纹理效果. 最终效果 1.打开PS软件,选择菜单:文件 > 新建,尺寸设置如下图,然后确定. 2.把前景色设置为暗黄色#37280d,然后用油漆桶工具把背景填充前景色. 3.点这里打开文字素材图片,在图片上右键选择"图片另存为"保存到本机.再用PS

Photoshop制作大气的中秋节岩石纹理字

  Photoshop制作大气的中秋节岩石纹理字          效果字的纹理部分直接使用了纹理素材,其它部分如浮雕.立体面.投影等都是用图层样式制作,一个图层样式出不了效果,就用多个图层样式叠加来完成. 最终效果 教程开始之前需要先定义一款图案.把下面的纹理素材保存到本机,再用PS打开,选择菜单:编辑 > 定义图案,然后命名后关闭. 1.按Ctrl + N 新建画布,尺寸为1000 * 750像素,分辨率为72像素/英寸,如下图,确定后把背景填充黑色. <图1> 2.保存下面的文字素

PS+AI制作水浒传血战沧州游戏3D文字效果教程

介绍用PS和AI制作水浒传血战沧州游戏3D文字效果,字体的选择没有硬性的要求,但考虑到后期材质物资的表现,还是选择粗一些的字体为宜. 效果图: 点击图片查看大图 点击图片查看大图 点击图片查看大图 分类: PS文字教程

利用Photoshop制作个性黄褐金属纹理字教程

  利用Photoshop制作个性黄褐金属纹理字教程,金属纹理字制作并不复杂.大致分为两个部分,金属字字及纹理部分.金属字用图层样式来做,纹理部分则用相关的纹理素材叠加即可. 最终效果 1.新建文件:设定宽和高为700像素,分辨率72dpi,名称:Angel text. 2.素材Concrete Bunker texture填充画布. 3.合并背景图层与素材Concrete Bunker texture所在图层. 4.图像>调整>色相/饱和度 参数设置如下. 5.滤镜>锐化>锐化,

PS制作漂亮的网页方块纹理背景

PS制作漂亮的网页方块纹理背景         注:更多请关注photoshop教程栏目,三联PS教程群:181754111欢迎你的加入 分类: PS入门教程

Azure的“网站”和“虚拟机”哪一个更适合网页游戏?

问题描述 Azure的"网站"和"虚拟机"哪一个更适合网页游戏? Azure的"网站"和"虚拟机"哪一个更适合网页游戏?能不能用它搭建私服?会不会被追查出来? 解决方案 想搞一个私服放在Azure上,请问Azure上的软件如何伪装IP? 解决方案二: 这种问题就真的没法回答你了.你要干坏事,那就不要怪工具.azure又不是无声手枪.

PlayFabl借助IBM Watson帮助开发商打造更好的游戏体验

众所周知,视频游戏比几乎任何其他形式的娱乐提供的数据和指标都更多,因此PlayFab公司希望利用IBM的Watson人工智能平台,将数据转化为游戏开发者的宝贵资料. PlayFab提供的后端平台令游戏创造者可以更容易地实现众多的在线游戏功能,包括玩家账户认证.好友列表,程序电商等等.PlayFab还提供大量基于游戏数据的分析,用上Watson后此功能更会大放光芒. PlayFab首席执行官James Gwertzman表示,"现代互连游戏提供了巨大的艺术和商业潜力,但要将潜力变为现实,开发人员需

结果显示:比起和女友做爱做的事,男人更喜欢玩游戏

最近,加州大学公布了一项关于游戏和妹子的研究,结果显示:比起和女友做爱做的事,男人更喜欢玩游戏.在100个男性志愿者中,其中67%的男性在玩游戏时会比XXOO时分泌更多的肾上腺素.他们玩过的游戏包括<超级马里奥银河2>和<战神3>(马大叔果然功力不浅). 志愿者先去玩30分钟以前没有玩过的游戏,然后再去和妹子做30分钟爱做的事.最后这个无比雷人的结果就出炉了. 尽管研究结果很雷人,不过通常情况下我们了解到的情况确实就是把妹子扔在一边,在游戏机或电脑前一坐就是几个小时.所以还是和妹子