texture2d_texture和texture2d区别 - CSDN
精华内容
参与话题
  • 二维纹理 Texture 2D

    千次阅读 2016-10-28 17:54:32
    二维纹理 Texture 2D Textures bring your Meshes, Particles, and interfaces to life! They are image or movie files that you lay over or wrap around your objects. As they are so important, they

    二维纹理 Texture 2D

    原文链接http://www.ceeger.com/Manual/Textures.html

    Textures bring your MeshesParticles, and interfaces to life! They are image or movie files that you lay over or wrap around your objects. As they are so important, they have a lot of properties. If you are reading this for the first time, jump down to Details, and return to the actual settings when you need a reference.

    纹理使你的网格、粒子、和界面更生动!它们是你覆盖或环绕着对象的图片或影片文件。由于它们是如此的重要,它们有很多的属性。如果你是第一次阅读这一点,跳到细节,当你需要一个参考时返回到实际设置。

    The shaders you use for your objects put specific requirements on which textures you need, but the basic principle is that you can put any image file inside your project. If it meets the size requirements (specified below), it will get imported and optimized for game use. This extends to multi-layer Photoshop or TIFF files - they are flattened on import, so there is no size penalty for your game.

    用于对象的着色器可以指定所需要的纹理,但基本原则是可以放置项目中任何图像文件。如果它符合尺寸要求(见以下说明),它将会被导入并优化。对于多层Photoshop文件或TIFF文件——它们在导入过程中被塌陷合并,所以对于游戏没有不利影响。

    Properties 属性

    The Texture Inspector looks a bit different from most others:

    纹理检视视图看起来与其它大多数有点不同:

    The top section contains a few settings, and the bottom part contains the Texture Importer and the texture preview.

    顶部包含几个设置,底部包含了纹理导入器和纹理预览。

    • Aniso Level 各向异性级别
      Increases texture quality when viewing the texture at a steep angle. Good for floor and ground textures, see below. 
      在一个过高角度看纹理时提高纹理质量。适用于地板与地面纹理,见下文。
    • Filter Mode 过滤模式
      Selects how the Texture is filtered when it gets stretched by 3D transformations: 
      选择纹理通过三维变换得到拉伸时如何过滤:
    •     Point 点模式
      The Texture becomes blocky up close 纹理在近距离变成块状
    •     Bilinear 双线性
      The Texture becomes blurry up close 纹理在近距离变模糊
    •     Trilinear 三线性
      Like Bilinear, but the Texture also blurs between the different mip levels 
      类似双线性,但纹理也在不同的mipmap层次之间变模糊
      (关于mipmap,参见以前翻译的章节Building Scenes—Using the Scene View)
    • Wrap Mode 循环模式
      Selects how the Texture behaves when tiled: 选择纹理平铺时的行为:
    •     Repeat 重复
      The Texture repeats (tiles) itself 纹理重复(平铺)本身
    •     Clamp 钳制
      The Texture's edges get stretched 纹理的边缘得到延伸

    Texture Importer 纹理导入器

    Textures all come from image files in your Project Folder. How they are imported is specified by the Texture Importer. You change these by selecting the file texture in the Project View and modifying the Texture Importer in the Inspector.

    纹理素材都来自于你的项目文件夹的图像文件。它们如何导入是由纹理导入器指定的。你通过在项目视图中选择纹理文件并且在检视面板中修改纹理导入器来改变它们。

    In Unity 3 we simplified for you all the settings, now you just need to select what are you going to use the texture for and Unity will set default parameters for the type of texture you have selected. Of course if you want to have total control of your texture and do specific tweaks, you can set the Texture Type to Advanced. This will present the full set of options that you have available.

    在Unity 3中我们为你简化了所有的设置,现在你只需要选择你打算使用的纹理,Unity会为你选择的纹理类型设置默认的参数。当然,如果你想有纹理的完全控制并做具体调整,你可以设置纹理类型为高级。这将显示你可使用的全套选项。

    • Texture Type 纹理类型
      Select this to set basic parameters depending on the purpose of your texture. 
      选择这个,根据纹理的用途设置基本参数。
    •     Texture 纹理
      This is the most common setting used for all the textures in general. 
      通常这是适用于所有纹理的最常用设置。
    •     Normal Map 法线贴图
      Select this to turn the color channels into a format suitable for real-time normal mapping. For more info, see Normal Maps
      选择此项,将把颜色通道变成一个适合于实时法向映射的格式。欲了解更多信息,请参阅法线贴图
    •     GUI 图形用户界面
      Use this if your texture is going to be used on any HUD/GUI Controls. 
      如果你的纹理是要用于任何HUD(平面显示器) / GUI的控制,使用该项。
    •     Reflection 反射
      Also known as Cube Maps, used to create reflections on textures. check Cubemap Textures for more info.
      也称为立方体贴图,用于创建纹理的反射。更多信息查询立方体贴图纹理
    •     Cookie
      This sets up your texture with the basic parameters used for the Cookies of your lights 
      这将设置带基本参数的纹理用于你的光源的Cookie
    •     Advanced 高级
      Select this when you want to have specific parameters on your texture and you want to have total control over your texture. 
      当你想要有纹理的具体参数并想拥有纹理的完全控制的时候选择该项。


    Basic Texture Settings Selected 基本纹理设置选项

    • Generate Alpha From Grayscale
      从灰度产生Alpha
      If enabled, an alpha transparency channel will be generated by the image's existing values of light & dark. 
      如果启用,将依据图像的现有明暗值产生一个alpha透明度通道。


    Normal Map Settings in the Texture Importer 纹理导入器中的法线贴图设置

    • Generate from Greyscale
      从灰度产生
    • Bumpiness 凹凸
      Control the amount of bumpiness. 控制凹凸的总量
    • Filtering 过滤
      Determine how the bumpiness is calculated: 确定凹凸如何计算出来:
    •     Smooth 平滑
      This generates normal maps that are quite smooth. 
      这会产生比较平滑的法线贴图
    •     Sharp 锐化
      Also known as a Sobel filter. this generates normal maps that are sharper than Standard. 
      也称为索贝尔过滤。这会产生出比标准更清晰的法线贴图


    GUI Settings for the Texture Importer 纹理导入器的GUI设置

    You dont need to set any values in this case, Unity will set all the values for you.

    在这种情况下你不需要设置任何值,Unity会为你设定所有值。


    Reflection Settings in the Texture Importer 理导入器的反射设置

    • Mapping 映射
      This determines how the texture will be mapped to a cubemap. 
      这将决定纹理如何映射到一个立方体贴图上
    •     Sphere Mapped 球面映射
      Maps the texture to a "sphere like" cubemap.
      纹理映射到一个"球状" 立方体贴图上
    •     Cylindrical 圆柱
      Maps the texture to a cilinder, use this when you want to use reflections on objects that are like cilinders. 
      纹理映射到一个圆柱体,当你要使用类似圆柱对象的反射时,使用该项。
    •     Simple Sphere 简单球形
      Maps the texture to a simple sphere, deforming the reflection when you rotate it.
      纹理映射到一个简单的球形,当你旋转它时变形反射
    •     Nice Sphere 精细球形
      Maps the texture to a sphere, deforming it when you rotate but you still can see the texture's wrap
      纹理映射到一个球形,当你旋转它时变形,但你仍然可以看到纹理的外观

    An interesting way to add a lot of visual detail to your scenes is to use Cookies - greyscale textures you use to control the precise look of in-game lighting. This is fantastic for making moving clouds and giving an impression of dense foliage. The Light page has more info on all this, but the main thing is that for textures to be usable for cookies you just need to set the Texture Type to Cookie.

    为你的场景增添很多视觉细节的一种有趣方式是使用Cookies——灰阶纹理用来控制游戏中照明的精确外观。这是构建移动云层和给人茂密植物印象的一种奇妙方式。光源页面有这一切更多的信息,主要的是,纹理要为cookie可用,你只需要设置纹理类型为cookie。


    Cookie Settings in the Texture Importer 纹理导入器中的Cookie设置

    • Light Type 
      光源类型
      Type of light that the texture will be applied to. (This can be Spotlight, Point or Directional lights). For Directional Lights this texture will tile, so in the texture inspector, you must set the Edge Mode toRepeat; for SpotLights You should keep the edges of your cookie texture solid black in order to get the proper effect. In the Texture Inspector, set the Edge Mode to Clamp.
      纹理将应用的光源类型。(可以是聚光灯、点光源或方向光)。对于方向光纹理将平铺,所以在纹理检视面板中必须设置边缘模式为重复(Repeat);对于聚光灯,你应该保持你的cookie纹理的边缘为纯黑色,以获得正确的效果。在纹理检视面板中,设置边缘模式为钳制(Clamp)
    • Generate Alpha from Greyscale 
      从灰度产生Alpha
      If enabled, an alpha transparency channel will be generated by the image's existing values of light & dark.
      如果启用,将依据图像的现有明暗值产生一个alpha透明度通道。


    The Advanced Texture Importer Settings dialog 高级纹理导入器设置对话框

    • Non Power of 2 
      不是2的幂
      If texture has non-power-of-two size, this will define a scaling behavior at import time (for more info see the Texture Sizes section below):
      如果纹理大小不是2的幂,这将定义在导入时的缩放行为(更多信息请参阅下文纹理尺寸部分):
    •     None 
      Texture will be padded to the next larger power-of-two size for use with GUITexture component. 
      纹理将被填充到下一个较大的2的幂大小以便与GUI纹理组件使用。(真别扭!)
    •     To nearest 到最近的
      Texture will be scaled to the nearest power-of-two size at import time. For instance 257x511 texture will become 256x512. Note that PVRTC formats require textures to be square (width equal to height), therefore final size will be upscaled to 512x512. 
      纹理在导入时将被缩放到最近的幂大小。例如257x511纹理将成为256x512。请注意,PVRTC格式要求纹理是正方形(宽度与高度相等),因此最终大小将变换到512x512。 PVRTC是一种有损的纹理压缩技术,主要用于iPhone,iPod touch和iPad。
    •     To larger 到较大的
      Texture will be scaled to the next larger power-of-two size at import time. For instance 257x511 texture will become 512x512. 
      纹理在导入时将被缩放到下一个较大的幂大小。例如257x511纹理将成为512x512。
    •     To smaller 到较小的
      Texture will be scaled to the next smaller power-of-two size at import time. For instance 257x511 texture will become 256x256. 
      纹理在导入时将被缩放到下一个较小的幂大小。例如257x511纹理将成为256x256。
    • Generate Cube Map 生成立方贴图
      Generates a cubemap from the texture using different generation methods. 
      使用不同的生成方法从一个纹理生成一个立方体贴图。
    • Read/Write Enabled
      读/写 启用
      Select this to enable access to the texture data from scripts (GetPixels, SetPixels and other Texture2D functions). Note however that a copy of the texture data will be made, doubling the amount of memory required for texture asset. Use only if absolutely necessary. Disabled by default. 
      选择此项将允许从脚本(GetPixels,SetPixels和其他Texture2D函数)访问纹理数据。但是注意,一个纹理数据副本将产生,由此必将为纹理资源消耗双倍的内存量。只有在绝对必要时使用。默认情况下禁用。
    • Generate Mip Maps 
      生成Mip Maps
      Select this to enable mip-map generation. Mip maps are smaller versions of the texture that get used when the texture is very small on screen. For more info, see Mip Maps below. 
      选择此项将启用Mipmap生成。当纹理在屏幕上非常小的时候,Mipmaps是可供使用的纹理的较小版本。欲了解更多信息,请参阅下文的Mip maps。
    • Correct Gamma 校正伽马
      Select this to enable per-mip-level gamma correction. 
      选择此项,启用每Mip级别伽玛校正。
    • Border Mip Maps
      边缘Mip Maps
      Select this to avoid colors seeping out to the edge of the lower Mip levels. Used for light cookies (see below). 
      选择此项为了避免色彩渗出到mip较低层次的边缘。用于光源cookies(见下文)。
    • Mip Map Filtering 
      Mip Map过滤
      Two ways of mip map filtering are available to optimize image quality: 
      mip map过滤的两种方式可供优化图像质量:
    •     Box 
      The simplest way to fade out the mipmaps - the mip levels become smoother and smoother as they go down in size. 
      最简单的方式淡出mipmap – 随着尺寸的减小mip级别变得更平滑。
    •     Kaiser 凯撒
      A sharpening Kaiser algorithm is run on the mip maps as they go down in size. If your textures are too blurry in the distance, try this option. 
      凯撒算法是随着尺寸的减小锐化mip maps运行。如果你的纹理在远距离变模糊,试试这个选项。
    • Fade Out Mips 
      淡出Mips
      Enable this to make the mipmaps fade to gray as the mip levels progress. This is used for detail maps. The left most scroll is the first mip level to begin fading out at. The rightmost scroll defines the mip level where the texture is completely grayed out 
      启用此项将使mipmaps随着mip级别的进展褪色为灰色,这个用于细节贴图。最左边的滚动条是开始淡出的第一个mip级别。最右边的滚动条定义mip级别在哪里完全变灰。
    • Generate Normal Map 
      生成法线贴图
      Enable this to turn the color channels into a format suitable for real-time normal mapping. For more info, see Normal Maps, below. 
      启用此项将转变颜色通道成一个适合于实时法线贴图的格式。欲了解更多信息,请参阅法线贴图,如下。
    • Bumpiness 凹凸
      Control the amount of bumpiness. 控制凹凸的额度。
    • Filtering 过滤
      Determine how the bumpiness is calculated: 确定凹凸如何计算出来:
    •     Smooth 平滑
      This generates normal maps that are quite smooth. 
      这会产生比较平滑的法线贴图。
    •     Sharp 锐化
      Also known as a Sobel filter. this generates normal maps that are sharper than Standard. 
      也称为索贝尔过滤。这会产生出比标准更清晰的法线贴图。
    • Normal Map 法线贴图
      Select this if you want to see how the normal map will be applied to your texture. 
      如果你想了解法线贴图如何被应用到你的纹理,选择此项。
    • Lightmap 光照贴图
      Select this if you want to use the texture as a lightmap.
      如果你想作为光照贴图使用纹理,选择此项。

    Per-Platform Overrides 按平台覆盖

    When you are building for different platforms, you have to think on the resolution of your textures for the target platform, the size and the quality. With Unity 3 you can override these options and assign specific values depending on the platform you are deploying to. Note that if you don't select any value to override, the Editor will pick the default values when building your project.

    当你在不同的平台构建(游戏),你必须考虑为目标平台决定你的纹理,尺寸和质量。使用Unity3,你可以覆盖这些选项,并根据你要部署的平台指定具体的值。注意,当你构建项目时,如果你没有选择任何值覆盖,编辑器会选择默认值。


    Default settings for all platforms. 所有平台的默认设置

    • Max Texture Size 
      最大纹理尺寸
      The maximum imported texture size. Artists often prefer to work with huge textures - scale the texture down to a suitable size with this. 
      导入纹理的最大尺寸。美工师往往更愿意使用巨大的纹理——用这个调整纹理降到合适的大小。
    • Texture Format 纹理格式
      What internal representation is used for the texture. This is a tradeoff between size and quality. In the examples below we show the final size of a in-game texture of 256 by 256 pixels: 
      用于纹理的内部表示。这是一个大小和质量之间的权衡。在下面的例子中我们展示了一个256 x 256像素的纹理的最终尺寸:
    •     Compressed 压缩
      Compressed RGB texture. This is the most common format for diffuse textures. 4 bits per pixel (32 KB for a 256x256 texture). 
      压缩RGB纹理,这是最常见的漫反射纹理格式。每像素4位(256x256的纹理大小为32 KB)。(4位就只有16种颜色)
    •     16 bit
      Low-quality truecolor. Has 16 levels of red, green, blue and alpha. 
      低质量的真彩色。拥有16个级别的红、绿、蓝和alpha。
    •     Truecolor 真彩色
      Truecolor, this is the highest quality. At 256 KB for a 256x256 texture. 
      真彩色,这是最高的质量。256x256的纹理大小为256 KB。(32位色彩)

    If you have set the Texture Type to Advanced then the Texture Format has different values.

    如果你已设置了纹理类型为高级,则纹理格式会有不同的值。

    Desktop
    • Texture Format纹理格式
      What internal representation is used for the texture. This is a tradeoff between size and quality. In the examples below we show the final size of an in-game texture of 256 by 256 pixels:
      用于纹理的内部格式。在大小和质量之间权衡。在下列的例子中,我们使用了在游戏中纹理的最终大小为256x256像素。
    •     RGB Compressed DXT1
      Compressed RGB texture. This is the most common format for diffuse textures. 4 bits per pixel (32 KB for a 256x256 texture).
      压缩的RGB纹理。这是最常见的漫反射纹理格式。4位/像素(32 KB 256x256)
    •     RGBA Compressed DXT5
      Compressed RGBA texture. This is the main format used for diffuse & specular control textures. 1 byte/pixel (64 KB for a 256x256 texture).
      压缩的RGBA纹理。这是漫反射和高光控制纹理的主要格式。1 字节/像素(64 KB 256x256)
    •     RGB 16 bit
      65 thousand colors with no alpha. Compressed DXT formats use less memory and usually look better. 128 KB for a 256x256 texture.
      65万颜色不带alpha。压缩的DXT格式使用较少的内存,通常会更好看。(128 KB 256x256)
    •     RGB 24 bit
      Truecolor but without alpha. 192 KB for a 256x256 texture.
      真彩色不带alpha。(192 KB 256x256)
    •     Alpha 8 bit
      High quality alpha channel but without any color. 64 KB for a 256x256 texture.
      高质量alpha通道,不带颜色。(64 KB 256x256)
    •     RGBA 16 bit
      Low-quality truecolor. Has 16 levels of red, green, blue and alpha. Compressed DXT5 format uses less memory and usually looks better. 128 KB for a 256x256 texture.
      低质量真彩色。有16级红,绿,蓝和alpha。压缩的DXT5格式使用较少的内存,通常会更好看。(128 KB 256x256)
    •     RGBA 32 bit
      Truecolor with alpha - this is the highest quality. At 256 KB for a 256x256 texture, this one is expensive. Most of the time, DXT5 offers sufficient quality at a much smaller size. The main way this is used is for normal maps, as DXT compression there often carries a visible quality loss.
      高质量真彩色带alpha(256 KB 256x256),这个文件很大。大多数情况下,DXT5提供足够的质量,文件大小要小得多。这个主要用于法线贴图,DXT压缩往往带有一个可见的质量损失。
    iOS
    • Texture Format
      What internal representation is used for the texture. This is a tradeoff between size and quality. In the examples below we show the final size of a in-game texture of 256 by 256 pixels:
      用于纹理的内部格式。在大小和质量之间权衡。在下列的例子中,我们使用了在游戏中纹理的最终大小为256x256像素。
    •     RGB Compressed
      PVRTC 4 bits Compressed RGB texture. This is the most common format for diffuse textures. 4 bits per pixel (32 KB for a 256x256 texture)
      PVRTC 4位,压缩的RGB纹理。这是最常见的漫反射纹理格式。4位/像素(32 KB 256x256)
    •     RGBA Compressed PVRTC 4 bits
      Compressed RGBA texture. This is the main format used for diffuse & specular control textures or diffuse textures with transparency. 4 bits per pixel (32 KB for a 256x256 texture)
      压缩的RGBA纹理。这是漫反射和高光控制纹理的主要格式。4 位/像素(32 KB 256x256)
    •     RGB Compressed PVRTC 2 bits
      Compressed RGB texture. Lower quality format suitable for diffuse textures. 2 bits per pixel (16 KB for a 256x256 texture)
      压缩的RGB纹理。 低质量格式,适用于漫反射纹理。2 位/像素(16 KB 256x256)
    •     RGBA Compressed PVRTC 2 bits
      Compressed RGBA texture. Lower quality format suitable for diffuse & specular control textures. 2 bits per pixel (16 KB for a 256x256 texture)
      压缩的RGBA纹理。 低质量格式,适用于漫反射纹理和高光控制纹理。2 位/像素(16 KB 256x256)
    •     RGB Compressed DXT1
      Compressed RGB texture. This format is not supported on iOS, but kept for backwards compatibility with desktop projects.
      压缩的RGB纹理。 在iOS不支持此格式,但为桌面项目保持向后兼容性。
    •     RGBA Compressed DXT5
      Compressed RGBA texture. This format is not supported on iOS, but kept for backwards compatibility with desktop projects.
      压缩的RGBA纹理。在iOS不支持此格式,但为桌面项目保持向后兼容性。
    •     RGB 16 bit
      65 thousand colors with no alpha. Uses more memory than PVRTC formats, but could be more suitable for UI or crisp textures without gradients. 128 KB for a 256x256 texture.
      65万颜色不带alpha。比PVRTC格式使用更多的内存,但更适用于UI或不带渐变的明快的纹理。128 KB 256x256
    •     RGB 24 bit
      Truecolor but without alpha. 192 KB for a 256x256 texture.
      真彩色不带alpha。(192 KB 256x256)
    •     Alpha 8 bit
      High quality alpha channel but without any color. 64 KB for a 256x256 texture.
      高质量alpha通道,不带颜色。(64 KB 256x256)
    •     RGBA 16 bit
      Low-quality truecolor. Has 16 levels of red, green, blue and alpha. Uses more memory than PVRTC formats, but can be handy if you need exact alpha channel. 128 KB for a 256x256 texture.
      低质量真彩色。具有16级的红、绿、蓝和alpha。比PVRTC格式使用更多的内存,但如果需要精确的alpha通道,会更方便。(128 KB 256x256)
    •     RGBA 32 bit
      Truecolor with alpha - this is the highest quality. At 256 KB for a 256x256 texture, this one is expensive. Most of the time, PVRTC formats offers sufficient quality at a much smaller size.
      真彩色带alpha - 这是最高质量。256KB 256x256,这个是很消耗性能的。大多数情况下,PVRTC格式提供足够的质量,但有更小的文件大小。
    Android
    • Texture Format
      What internal representation is used for the texture. This is a tradeoff between size and quality. In the examples below we show the final size of a in-game texture of 256 by 256 pixels:
      用于纹理的内部格式。在大小和质量之间权衡。在下列的例子中,我们使用了在游戏中纹理的最终大小为256x256像素。
    •     RGB Compressed DXT1
      Compressed RGB texture. Supported by Nvidia Tegra. 4 bits per pixel (32 KB for a 256x256 texture). 
      压缩的RGB纹理。支持Nvidia Tegra。4位/像素(32 KB 256x256) ;
    •     RGBA Compressed DXT5
      Compressed RGBA texture. Supported by Nvidia Tegra. 6 bits per pixel (64 KB for a 256x256 texture).
      压缩的RGBA纹理。支持Nvidia Tegra。6位/像素(64 KB 256x256) ;
    •     RGB Compressed ETC 4 bits
      Compressed RGB texture. This is the default texture format for Android projects. ETC1 is part of OpenGL ES 2.0 and is supported by all OpenGL ES 2.0 GPUs. It does not support alpha. 4 bits per pixel (32 KB for a 256x256 texture)
      压缩的RGB纹理。这是Android工程默认的纹理格式。ETC1是OpenGL ES 2.0标准的一部分,并且支持所有的OpenGL ES 2.0 GPU,但它不支持Alpha。4位/像素(32 KB 256x256)
    •     RGB Compressed PVRTC 2 bits
      Compressed RGB texture. Supported by Imagination PowerVR GPUs. 2 bits per pixel (16 KB for a 256x256 texture)
      压缩的RGB纹理。 支持Imagination PowerVR GPU。2位/像素(16 KB 256x256)
    •     RGBA Compressed PVRTC 2 bits
      Compressed RGBA texture. Supported by Imagination PowerVR GPUs. 2 bits per pixel (16 KB for a 256x256 texture)
      压缩的RGBA纹理。支持Imagination PowerVR GPU。2位/像素(16 KB 256x256)
    •     RGB Compressed PVRTC 4 bits
      Compressed RGB texture. Supported by Imagination PowerVR GPUs. 4 bits per pixel (32 KB for a 256x256 texture)
      压缩的RGB纹理。 支持Imagination PowerVR GPU。4位/像素(32 KB 256x256)
    •     RGBA Compressed PVRTC 4 bits
      Compressed RGBA texture. Supported by Imagination PowerVR GPUs. 4 bits per pixel (32 KB for a 256x256 texture)
      压缩的RGBA纹理。 支持Imagination PowerVR GPU。4位/像素(32 KB 256x256)
    •     RGB Compressed ATC 4 bits
      Compressed RGB texture. Supported by Qualcomm Snapdragon. 4 bits per pixel (32 KB for a 256x256 texture).
      压缩的RGB纹理。 支持Qualcomm Snapdragon。4位/像素(32 KB 256x256)
    •     RGBA Compressed ATC 8 bits
      Compressed RGBA texture. Supported by Qualcomm Snapdragon. 6 bits per pixel (64 KB for a 256x256 texture).
      压缩的RGB纹理。 支持Qualcomm Snapdragon。6位/像素(64 KB 256x256)
    •     RGB 16 bit
      65 thousand colors with no alpha. Uses more memory than the compressed formats, but could be more suitable for UI or crisp textures without gradients. 128 KB for a 256x256 texture.
      65万颜色不带alpha。比压缩的格式使用更多的内存,但更适用于UI或不带渐变的明快的纹理。128 KB 256x256
    •     RGB 24 bit
      Truecolor but without alpha. 192 KB for a 256x256 texture.
      真彩色不带alpha。(192 KB 256x256)
    •     Alpha 8 bit
      High quality alpha channel but without any color. 64 KB for a 256x256 texture.
      高质量alpha通道,不带颜色。(64 KB 256x256)
    •     RGBA 16 bit
      Low-quality truecolor. The default compression for the textures with alpha channel. 128 KB for a 256x256 texture.
      低质量真彩色。默认压缩的纹理带有alpha通道(128 KB 256x256)
    •     RGBA 32 bit
      Truecolor with alpha - this is the highest quality compression for the textures with alpha. 256 KB for a 256x256 texture.
      真彩色带alpha - 这是高质量压缩的纹理带有alpha通道。(256 KB 256x256)

    Unless you're targeting a specific hardware, like Tegra, we'd recommend using ETC1 compression. If needed you could store an external alpha channel and still benefit from lower texture footprint. If you absolutely want to store an alpha channel in a texture, RGBA16 bit is the compression supported by all hardware vendors.

    除非你是针对一个特定的硬件,像Tegra,我们建议你使用ETC1压缩。如果需要可以储存额外的alpha通道并仍能得到较低的纹理占用空间。如果你一定要储存alpha通道在纹理中,RGBA16位是所有的硬件​​厂商所支持的压缩。

    If your app utilizes an unsupported texture compression, the textures will be uncompressed to RGBA 32 and stored in memory along with the compressed ones. So in this case you lose time decompressing textures and lose memory storing them twice. It may also have a very negative impact on rendering performance.

    如果您的应用程序采用一个不支持的纹理压缩,纹理将解压到RGBA32并连同压缩的那些储存在内存中。因此,这种情况下将失去解压纹理时间并消耗内存储存它们两次,也有可能非常影响渲染性能。

    Details 细节

    Supported Formats 支持的格式

    Unity can read the following file formats: PSD, TIFF, JPG, TGA, PNG, GIF, BMP, IFF, PICT. It should be noted that Unity can import multi-layer PSD & TIFF files just fine. They are flattened automatically on import but the layers are maintained in the assets themselves, so you don't lose any of your work when using these file types natively. This is important as it allows you to just have one copy of your textures that you can use from Photoshop, through your 3D modelling app and into Unity.

    Unity支持下面的文件格式:PSD, TIFF, JPG, TGA, PNG, GIF, BMP, IFF, PICT。应注意,Unity可以导入多层PSD和TIFF文件,在导入时,层将自动被塌陷,因此你不必浪费时间,直接使用源文件类型。这点很重要,允许只有一个纹理拷贝,使用从Photoshop,三维建模程序导入到Unity。

    Texture Sizes 纹理大小

    These sizes are as follows: 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 or 2048 pixels. The textures do not have to be square, i.e. width can be different from height.

    这些尺寸如下:2, 4, 8, 16, 32, 64, 128, 256, 512, 1024 或 2048像素。纹理可不必是正方形,即宽度和高度可以不同。

    It is possible to use other (non power of two) texture sizes with Unity. Non power of two texture sizes work best when used on GUI Textures, however if used on anything else they will be converted to an uncompressed RGBA 32 bit format. That means they will take up more video memory (compared to PVRT(iOS)/DXT(Desktop) compressed textures), will be slower to load and slower to render (if you are on iOS mode). In general you'll use non power of two sizes only for GUI purposes.

    可以使用其他非二次方纹理尺寸,当用于GUI纹理时,非二次方纹理最好,但是,如果在别的使用,它们将被转换为未压缩的RGBA32位格式。这意味着它们将使用更多的内存(相比PVRT(iOS)/DXT(Desktop)压缩的纹理),将使较慢加载和和较慢渲染(如果是iOS模式)。一般来说,非二次方的纹理仅用于GUI。

    Non power of two texture assets can be scaled up at import time using the Non Power of 2 option in the advanced texture type in the import settings. Unity will scale texture contents as requested, and in the game they will behave just like any other texture, so they can still be compressed and very fast to load.

    非二次方纹理资源可以在导入时在导入设置中高级纹理类型使用Non Power of 2(非二次方)选项设置缩放。Unity将按需缩放纹理,并在游戏中,它们的行为就像其他纹理一样,因此他们仍然可以被压缩,加载非常快。

    UV Mapping(UV贴图)

    When mapping a 2D texture onto a 3D model, some sort of wrapping is done. This is called UV mapping and is done in your 3D modelling app. Inside Unity, you can scale and move the texture using Materials. Scaling normal & detail maps is especially useful.

    当映射一个2D纹理到一个3D模型上,要设定循环模式(平铺方式)。这就是三维建模程序中,被称为UV贴图。在Unity,可以使用Materials缩放移动纹理。缩放法线和地形细节贴图尤其有用。

    Mip Maps 多级纹理

    Mip Maps are a list of progressively smaller versions of an image, used to optimise performance on real-time 3D engines. Objects that are far away from the camera use the smaller texture versions. Using mip maps uses 33% more memory, but not using them can be a huge performance loss. You should always use mipmaps for in-game textures; the only exceptions are textures that will never be minified (e.g. GUI textures).

    多级纹理是逐步缩小图像版本的一个列表,用来优化实时3D引擎的性能。远离相机的物体使用较小的纹理版本。使用多级纹理,将多使用33%以上的内存,但不使用它们将有巨大的的性能损失。应该为游戏总是使用多级纹理,唯一例外的是,用于不会缩小的纹理(例如GUI纹理)。

    Normal Maps 法线贴图

    Normal maps are used by normal map shaders to make low-polygon models look as if they contain more detail. Unity uses normal maps encoded as RGB images. You also have the option to generate a normal map from a grayscale height map image.

    法线贴图用于法线贴图着色器,使低多边形模型看起来有更多的细节。Unity使用的法线贴图作为RGB图像编码,还可以选择从一个灰度高度图来生成一个法线贴图。

    Detail Maps 细节贴图

    If you want to make a terrain, you normally use your main texture to show where there are areas of grass, rocks sand, etc... If your terrain has a decent size, it will end up very blurry. Detail textures hide this fact by fading in small details as your main texture gets up close.

    如果想创建一个地形,通常使用主纹理来显示那些草、岩砂区域,等等。如果地形非常大,它最终会非常模糊。细节纹理隐藏实际的淡出,小细节作为更接近的主纹理。

    When drawing detail textures, a neutral gray is invisible, white makes the main texture twice as bright and black makes the main texture completely black.

    但绘制细节纹理,中性灰是不可见的,白色是主纹理两倍亮,黑色是主纹理完全变黑。

    Reflections (Cube Maps) 反射(立方体贴图)

    If you want to use texture for reflection maps (e.g. use the Reflective builtin shaders), you need to use Cubemap Textures.

    如果你想使用纹理用于反射贴图(例如使用内置的反射着色器),必须使用立方图纹理。

    Anisotropic filtering 各项异性过滤

    Anisotropic filtering increases texture quality when viewed from a grazing angle, at some expense of rendering cost (the cost is entirely on the graphics card). Increasing anisotropy level is usually a good idea for ground and floor textures. In Quality Settings anisotropic filtering can be forced for all textures or disabled completely.

    当从掠角(grazing angle)观看,各向异性过滤提高纹理质量,有一些渲染成本消耗(完全是显卡成本)。为地面和地板纹理,增加各向异性等级通常是一个好主意。在质量设置中各向异性过滤,可以强制用于所有纹理或完全禁用。

     
    No anisotropy (left) / Maximum anisotropy (right) used on the ground texture
    无各向异性(左)/(右)最大各向异性应用于地面纹理。

    展开全文
  • [Texture]详解Texture2D

    万次阅读 2017-06-27 11:54:01
    详解Unity中的Texture2D,实现绘制贴图的功能

    什么是Texture2D


    如上图,Texture2D是一张二维图片
    是由一颗一颗像素组成的。
    通常是由低到高,由左到右排列的。
    如果想要通过代码操作像素,我们必须要知道像素的坐标位置,现在我们来验证下是否真的如此排列。

    我们通过简短的代码,NEW一个图片,并且根据X,Y轴对应R,G通道,逐像素赋值。我们将得到一张红绿渐变图,如下。

    根据图片的颜色渐变过程,我们可以确信,像素排列顺序是和我们预测的一样。

    TextureFormat是什么

    TextureFormat为贴图的类型,ARGB32位,代表有ARGB4个通道,每个通道的颜色有8位,对应的还有A8,RGB24等。任何图片从本质上就是这样的。
    而常见的JPG,PNG等是操作系统采用的压缩/非压缩读取格式,ETC/DDS为图形接口读取的压缩格式。

    赋值完后为什么要Apply

    因为在贴图更改像素时并不是直接对显存进行更改,而是在另外一个内存空间中更改,这时候GPU还会实时读取旧的贴图位置。
    当Apply后,CPU会告诉GPU你要换个地方读贴图了。

    所有的图片的像素排列顺序都一样吗?

    事实上OpenGL和DX在UV方向和取值上是不同的,在此我们应该感谢Unity3D为我们做的那些事,让一切变得简单。

    制作一个简单的笔刷

    最终效果


    实现轮廓


    我们对上面的代码稍作修改。
    我们在第一个红线引入一张贴图,第二个红线,将像素乘以这张贴图对应位置的alpha通道。
    在色阶上每个通道是8位,0-255,但在计算时为浮点数。0~1。
    所以如果alpha为0,任何颜色乘以他,结果都为0。
    通过以上代码,我们实现如下效果:

    这张贴图是张Alpha通道为0和1的通道,1为有颜色,0自然就没有颜色。也可以通过0-1之间的值实现渐变。
    同样的,因为只用到一个通道,我们可以将它压缩为一张Alpha8的单通道8位贴图,来节省空间。

    实现纹理


    我们再次对上述代码进行更改,同样引入一张贴图来做纹理。
    这次我们进行颜色相乘,因为颜色为浮点值,所以他们乘后的结果不会大于1,也不会小于0。
    而重载运算符,在*的过程中,帮我们把RGBA通道一一对应的运算。
    这里我们用到了相乘,很多人在用图像软件时,会遇到,相乘,相加,相除,相减等词汇。
    一开始会很纳闷,为什么要这样命名。现在我们知道了,他们是在像素之间的数学运算关系。

    通过以上简短的代码,我们就实现了一个比较复杂且完整的功能。
    展开全文
  • GLSL的texture2D函数

    万次阅读 2013-12-11 22:44:58
    最近在学习GLSL着色语言,对于texture2D这个函数始终有点搞不明白,今天终于搞清楚了 texture2D的第一个参数是采样器(可以是sampler1D sampler2D sampler3D samplerCube sampler1DShadow sampler2DShadow) 由于...

    最近在学习GLSL着色语言,对于texture2D这个函数始终有点搞不明白,今天终于搞清楚了

    texture2D的第一个参数是采样器(可以是sampler1D sampler2D sampler3D samplerCube sampler1DShadow sampler2DShadow)

    由于OPenGL是支持多重纹理的,有如下可选值

    #define GL_TEXTURE0 0x84C0
    #define GL_TEXTURE1 0x84C1
    #define GL_TEXTURE2 0x84C2
    #define GL_TEXTURE3 0x84C3
    #define GL_TEXTURE4 0x84C4
    #define GL_TEXTURE5 0x84C5
    #define GL_TEXTURE6 0x84C6
    #define GL_TEXTURE7 0x84C7
    #define GL_TEXTURE8 0x84C8
    #define GL_TEXTURE9 0x84C9
    #define GL_TEXTURE10 0x84CA
    #define GL_TEXTURE11 0x84CB
    #define GL_TEXTURE12 0x84CC
    #define GL_TEXTURE13 0x84CD
    #define GL_TEXTURE14 0x84CE
    #define GL_TEXTURE15 0x84CF
    #define GL_TEXTURE16 0x84D0
    #define GL_TEXTURE17 0x84D1
    #define GL_TEXTURE18 0x84D2
    #define GL_TEXTURE19 0x84D3
    #define GL_TEXTURE20 0x84D4
    #define GL_TEXTURE21 0x84D5
    #define GL_TEXTURE22 0x84D6
    #define GL_TEXTURE23 0x84D7
    #define GL_TEXTURE24 0x84D8
    #define GL_TEXTURE25 0x84D9
    #define GL_TEXTURE26 0x84DA
    #define GL_TEXTURE27 0x84DB
    #define GL_TEXTURE28 0x84DC
    #define GL_TEXTURE29 0x84DD
    #define GL_TEXTURE30 0x84DE

    一般咱们在使用纹理的时候,默认启动的是GL_TEXTURE0,也就是glActiveTexture(GL_TEXTURE0),所以,如果咱们用到了多重渲染的话,可以考虑使用这个,根据枚举的取值sampler2D的值可以是0~最大纹理数目





    展开全文
  • Texture2D

    2019-08-12 14:32:57
    一、2D纹理类属性及函数 首先提供官方参考文档:API-Reference-Texture2D 概述:2D纹理类继承自Texture类; 属性 方法 二、案例使用

    一、2D纹理类属性及函数

    首先提供官方参考文档:API-Reference-Texture2D

    概述: 2D纹理类继承自Texture类;

    属性

    •  

    方法

    •  

    二、案例使用

    展开全文
  • 在网络小游戏中有时候会有这样的需求的就是Texture和Texture2D类型的转换,例如:本地选择头像更换,背包图片的更新等.当然这方法只适用于小量级的小需求,大的需求会使用专门的处理类完成处理. 小游戏一般会使用更省...
  • Unity中Texture和Texture2D格式互相转换

    千次阅读 2019-01-07 20:14:15
    在网络小游戏中有时候会有这样的需求的就是Texture和Texture2D类型的转换,例如:本地选择头像更换,背包图片的更新等.当然这方法只适用于小量级的小需求,大的需求会使用专门的处理类完成处理. 小游戏一般会使用更省...
  • Unity 之 Texture和Texture2D部分使用相关

    千次阅读 2019-03-05 21:24:11
    Unity 之 Texture和Texture2D 分享几个实用的方法,,, Unity Texture转换成Texture2D: 使用Texture2D 的形式截图 将Texture保存到本地 将本地图片转换为Byte[]数组
  • Unity Texture转Texture2D

    千次阅读 2019-09-12 17:56:07
    图片的动态转换 分为两种模式: 编辑器时,可以直接as后,然后保存; 运行时,需要拿RenderTexture来进行一次像素的转化 (编辑器模式下 ) /// 编辑器模式下Texture转换成... Texture2D texture2d = texture as...
  • 二、简介 Texture2D类简介 Texture2D类允许开发者用图像、文本信息和简单的数据来创建OpenGL2D纹理。被创建的纹理拥有两个维度。根据开发者创建Texture2D对象方式的不同,实际图像的尺寸可能比生成的纹理的尺寸要小...
  • 文章目录一、加载Texture2D显示图片二、案例三、内存分析四、如何释放内存1、错误示范2、正确示范 一、加载Texture2D显示图片 游戏项目中,我们经常需要通过网络加载图片,比如用户头像、背景图,也可能是加载本地的...
  • Unity Texture Texture2D RenderTexture

    万次阅读 2020-04-21 23:09:54
    http://fargesportfolio.com/unity-texture-texture2d-rendertexture/ (1) Texture 基于GPU ...(3)Texture2D基于CPU Texture2D.Apply将CPU数据传递给GPU /// Pass a GPU RenderTexture to CPU...
  • Texture转Texture2D

    2019-07-02 15:46:27
    private Texture2D TextureToTexture2D(Texture texture) { Texture2D texture2D = new Texture2D(texture.width, texture.height, TextureFormat.RGBA32, false); RenderTexture curren...
  • Unity中Texture转Texture2D

    千次阅读 2018-09-18 09:19:42
    Texture2D Texture2Texture2D(Texture texture) { Texture2D texture2D = new Texture2D(texture.width, texture.height, TextureFormat.RGBA32, false); RenderTexture currentRT = RenderTe...
  • public static void textureToTexture2D (Texture texture, Texture2D texture2D) { if (texture == null) throw new ArgumentNullException ("texture"); if (te...
  • Unity 重新设置Texture2D的大小
  • unity Texture2D 像素访问

    千次阅读 2019-04-17 16:29:50
    unity Texture2D 像素访问 public Texture2D getTexture(float[] rgb) { Texture2D texture; int cnt = 0; for (int y = height - 1; y >= 0; y--) { for (int x = ...
  • Unity3D中texture2D函数使用详解

    万次阅读 2014-02-11 17:56:57
    在Unity3D中可以使用脚本创建texture2D贴图,并对像素进行操作。 构造函数: Texture2D(int width, int height); Texture2D(int width, int height, TextureFormat format, bool mipmap); Texture2D(int...
  • 第二种:使用C#获取图片文件信息,然后利用Texture2D.LoadImage,大多数人研究第二种都是浅尝辄止,他们认为第二种方法有个前提是已经知道了图片的分辨率,即Texture2D的大小你必须在读之前就知道,那么问题就来了,...
  • Unity Texture2D缩放

    千次阅读 2015-05-14 09:14:45
    Texture2D ScaleTexture(Texture2D source, int targetWidth, int targetHeight) { Texture2D result = new Texture2D(targetWidth, targetHeight, source.format, false); float incX = (1.0f /
  • Unity 3D : Texture2D 縮放大小

    千次阅读 2018-11-07 00:00:25
    Texture2D ScaleTexture(Texture2D source, float targetWidth, float targetHeight) { Texture2D result = new Texture2D((int)targetWidth, (int)targetHeight, source.format, false); floa...
1 2 3 4 5 ... 20
收藏数 42,282
精华内容 16,912
关键字:

texture2d