Textures
Unity 将3D工程目录下的Asset文件夹下的任何图片和 image or movie file 识别为Texture (2D projects工程中,它们被当作 Sprites). 只要图像符合下列尺寸要求, ).
Properties
Texture Type
Property: | Function: |
---|---|
Texture Type | 使用这个来定义你的纹理是用来做什么的。纹理导入器中的其他属性根据您的选择而改变。 |
Default | 这是所有纹理最常用的设置. |
Normal Map | 选择此选项可将颜色通道转换为适合实时法线贴图的格式 |
Editor GUI | 把Texture 用在 HUD or GUI controls.上 |
Sprite (2D and UI) | 精灵贴图 . |
Cursor | 如果您使用纹理作为自定义光标,请选择此选项。 |
Cookie | 作为灯光的 Cookies Lights. |
Lightmap | 作为 Lightmap 此选项允许将编码转换为特定格式(RGBM或dLDR,取决于平台) |
Single Channel | 如果你只需要纹理中的一个通道,选择这个。 |
Texture Shape
Property: | Function: |
---|---|
Texture Shape | 使用这个来定义纹理的形状。默认设置为2D。 |
2D | 这是所有纹理最常见的设置;它将图像文件定义为2D纹理. 这些用于将纹理映射到3D网格和GUI元素,以及其他项目元素。 |
Cube | 这将纹理定义为 cubemap,你可以用这个 Skyboxes or Reflection Probes |
Mapping | 只有 Cube时才可用, 使用Mapping来指定纹理如何投射到GameObject(游戏物体)上。这是默认设置Auto |
Auto | Unity试图根据纹理信息自动做出布局。 |
6 Frames Layout (Cubic Environment) | The Texture contains six images arranged in one of the standard cubemap layouts: cross, or sequence (+x -x +y -y +z -z). The images can be orientated either horizontally or vertically. |
Latitude Longitude (Cylindrical) | Maps the Texture to a 2D Latitude-Longitude representation. |
Mirrored Ball (Sphere Mapped) | Maps the Texture to a sphere-like cubemap. |
Convolution Type | Choose the type of pre-convolution (that is, filtering) that you want to use for this texture. The result of pre-convolution is stored in mips. This is set to None by default. |
None | The Texture has no pre-convolution (no filtering). |
Specular (Glossy Reflection) | Select this to use cubemaps as Reflection Probes. The Texture mip maps are pre-convoluted (filtered) with the engine BRDF. (See Wikipedia’s page on Bidirectional reflectance distribution function for more information.) |
Diffuse (Irradiance) | The Texture is convoluted (filtered) to represent irradiance. This is useful if you use the cubemap as a Light Probe . |
Fixup Edge Seams | This option is only available with the None or Diffuse convolution (filter). Use this on low-end platforms as a work-around for filtering limitations, such as cubemaps incorrectly filtered between faces. |
Advanced settings
Property: | Description: |
---|---|
Non Power of 2 | :如果纹理的非幂次尺寸为2 (NPOT),这定义了导入时的缩放行为. None by default. |
None | Texture 尺寸保持不变 |
To nearest | 纹理在导入时缩放到最接近的二维幂次大小. F 257x511 缩放为 256x512 px. 请注意,PVRTC格式要求纹理为正方形 (即宽度等于高度),因此最后的维度大小被放大到512x512像素。 |
To larger | 纹理在导入时缩放到最大尺寸值的二维幂次大小。例如,一个257x511像素的纹理被缩放到512x512像素。 |
To smaller | 纹理在导入时缩放到最小尺寸值的二维幂次大小。例如,一个257x511像素的纹理被缩放到256x256像素。 |
Read/Write Enabled | 选中此框可从脚本函数访问纹理数据 (such as Texture2D.SetPixels, Texture2D.GetPixels and other Texture2D functions). 这个修改的时材质的副本, 所以需要两倍的内存, 所以只有在绝对必要时才使用这个属性。这只适用于未压缩和DXT压缩纹理; 其他类型的压缩纹理无法读取。默认情况下禁用此属性。. |
Streaming Mip Maps | 启用此复选框使用Texture Streaming . Diffuse Textures, normal maps and light maps are all valid for Texture Streaming. |
Mip Map Priority | 使用它来设置mipmap的优先级. 配资源时,Unity使用它来确定哪个mipmap优先级. Higher values represent a higher 更高的值表示更高的优先级(例如,3的优先级高于1). Streaming Mip Maps勾选是这个才可用 Mip Map Priority是Memory Budget中的 的mipmap偏移量 Memory Budget (set in the Quality Settings when Texture Streaming is enabled). 例如,优先级为2时,Texture Streaming system尝试使用比优先级为0的纹理高两个mip级别的mipmap. 每个轴上高一级是2x,每个轴上高两级是4x,所以高两级的mip会导致纹理大16倍. 如果不能做到这一点,则使用较低的mip级别来满足内存预算。负值也是有效的. See Texture Streaming API for more details. |
Generate Mip Maps | 选中此复选框以启用mipmap生成.Mipmaps是屏幕上纹理非常小时使用的纹理的小版本. See documentation on Importing Textures for more information on mipmaps. |
Border Mip Maps | 选中此复选框以避免颜色溢出到较低的MIP级别边缘. Used for light cookies (see below). This box is unchecked by default. |
Mip Map Filtering | 为了优化图像质量,有两种可用的mipmap滤波方法. The default option is Box. |
Box | 这是使mipmaps淡出最简单的方法. The MIP levels become smoother as they go down in dimension size. |
Kaiser | A sharpening algorithm runs on the mipmaps as they go down in dimension size. Try this option if your Textures are too blurry in the distance. (The algorothm is of a Kaiser Window type - see Wikipedia for further information.) |
Mip Maps Preserve Coverage | :如果您想要生成的mipmaps的alpha通道在alpha测试期间保持覆盖率,请启用此复选框。 See TextureImporterSettings.mipMapsPreserveCoverage for more information. |
Fadeout Mip Maps | 使之能够使mipmaps随着MIP级别的进展而淡入灰色。这是用于详细地图。最左边的滚动条是开始淡出的第一个MIP级别。最右边的滚动条定义了MIP级别,其中纹理完全变灰。. |
Wrap Mode | 选择纹理在平铺时的行为方式。 The default option is Clamp. |
Repeat | Repeats the Texture in tiles. |
Clamp | Stretches the Texture’s edges. |
Mirror | Mirrors the Texture at every integer boundary to create a repeating pattern. |
Mirror Once | Mirrors The texture once, then clamps it to edge pixels . |
Per-axis | Choose this to individually control how Unity wraps Textures at the U axis and V axis. |
Filter Mode | 选择如何过滤纹理时,它被拉伸的3D变换. The default option is Point (no filter). |
Point (no filter) | 近距离看,纹理呈块状 |
Bilinear | 纹理近距离看起来很模糊 |
Trilinear | Like Bilinear, but the Texture also blurs between the different MIP levels. |
Aniso Level | Increases Texture quality when viewing the Texture at a steep angle. Good for floor and ground Textures. See documentation on Importing Textures for more information on Anisotropic filtering. |
Platform-specific overrides
The Texture Inspector window has a Platform-specific overrides panel.
Property: | Function: |
---|---|
Max Size | The maximum imported Texture dimensions in pixels. Artists often prefer to work with huge dimension-size Textures; use Max Size to scale the Texture down to a suitable dimension-size. |
Compression | Choose the compression type for the Texture. This parameter helps the system choose the right compression format for a Texture. Depending on the platform and the availability of compression formats, different settings might end up with the same internal format (for example, Low Quality Compression has an effect on mobile platforms, but not on desktop platforms). |
None | The Texture is not compressed. |
Low Quality | The Texture is compressed in a low-quality format. This results in a lower memory usage compared with Normal Quality. |
Normal Quality | The Texture is compressed with a standard format. |
High Quality | The Texture is compressed in a high-quality format. This results in a higher memory usage compared with Normal Quality. |
Format | This bypasses the automatic system to specify what internal representation is used for the Texture. The list of available formats depends on the platform and Texture type. See documentation on Texture formats for platform-specific overrides for more information. Note: Even when a platform is not overridden, this option shows the format chosen by the automatic system. The Format property is only available when overriding for a specific platform, and not as a default setting. |
Use crunch compression | Use crunch compression, if applicable. Crunch is a lossy compression format on top of DXT or ETC Texture compression . Textures are decompressed to DXT or ETC on the CPU and then uploaded on the GPU at runtime. Crunch compression helps the Texture use the lowest possible amount of space on disk and for downloads. Crunch Textures can take a long time to compress, but decompression at runtime is very fast. |
Compressor Quality | When using Crunch Texture compression, use the slider to adjust the quality. A higher compression quality means larger Textures and longer compression times. |
Render Texture
Render Textures 是一个特殊的材质,它可以在运行时实时更新,你把它赋给一个材质球,或者直接赋给摄像机,能够实时更新它们的变化. The Water prefabs的折射和反射就是运用 Render Textures来实现的
Properties
Property: | Function: | |
---|---|---|
Dimension | The dimensionality (type) of the render texture. | |
2D | The render texture is two-dimensional. | |
Cube | The render texture is a cube map. | |
3D | The render texture is three-dimensional. | |
Size | Trender texture 的像素大小 . 必须是2的幂次方 such as 128 and 256. |
|
Anti-Aliasing | 抗锯齿采样. You can select None, 2 samples, 4 samples, or 8 samples. If you select None, Unity does not apply anti-aliasing. | |
Enable Compatible Color Format | 勾选上Unity 会应用一个复杂的模式给render texture 如果平台不支持 Color Format | |
Color Format | The color format of the render texture. | |
Depth Buffer | 深度缓冲区的格式. You can select No depth buffer, At least 16 bits depth (no stencil), or At least 24 bits depth (with stencil). T模板缓冲区是一个通用缓冲区,它允许您为绘制到屏幕上的每个像素存储一个额外的无符号8位整数(0-255)。 | |
Enable Mip Maps | Check this box to make the render texture generate mipmaps. | |
Auto generate Mip Maps | Check this box to automatically fill the generated mipmaps with relevant data. If you don’t enable this, you’ll have to use the GenerateMips function to fill those mipmaps manually. Alternatively, choose which mip to render into when you call the various SetRenderTarget functions. For more information about the SetRenderTarget functions, see Graphics.SetRenderTarget and Rendering.CommandBuffer.SetRenderTarget . |
|
Dynamic Scaling | 选中此框可让动态分辨率缩放调整渲染纹理的大小。如果你不启用这个,渲染纹理保持相同的大小,不管动态分辨率设置。 | |
Wrap Mode | Controls how the texture is wrapped: | |
Repeat | Tiles the texture to create a repeating pattern. | |
Clamp | Stretches the edges of the texture. This is useful for preventing wrapping artifacts when you map an image onto an object and you don’t want the texture to tile. | |
Mirror | 将纹理平铺以创建一个重复的图案,该图案在每个整数边界上镜像纹理。 | |
Mirror Once | Mirrors the texture once, and then falls back to clamping. | |
Per-axis | Lets you set different wrap modes for the U axis and the V axis. The available options are also Repeat, Clamp, Mirror and Mirror Once. For example, when you use latitude-longitude environment maps for reflection probes , it is useful to have Clamp on the vertical coordinate (V axis), but Repeat on the horizontal coordinate (U axis). |
|
Filter Mode | Controls how the sampling of the texture uses nearby pixels. The options are: | |
Point | Uses the nearest pixel. This makes the texture appear pixelated. | |
Bilinear | Uses a weighted average of the four nearest texels. This makes the texture appear blurry when you magnify it. | |
Trilinear | Uses a weighted average of the two nearest mips, which are bilinearly filtered. This creates a soft transition between mips, at the cost of a slightly more blurry appearance. | |
Aniso Level | 纹理的各向异性滤波水平。这增加了纹理质量,当你在一个陡峭的角度看纹理。适用于地板、地面或路面纹理。 |
Custom Render Textures
Custom Render Textures是 Render Textures 的扩展,这使得用户可以很容易地用着色器更新纹理. 这对于实现各种复杂的模拟非常有用,比如焦散模拟、雨的波纹模拟、液体溅到墙上等等.它还提供了一个脚本和着色框架,以帮助更复杂的配置,如部分或多通道更新,变化的更新频率等
Properties
Custom Texture:
Custom Texture 的参数分为三种:
-
Material: 定义使用什么着色器来更新纹理。
-
Initialization: 控制在着色器进行任何更新之前如何初始化纹理
-
Update: 控制材质如何被着色器更新。
Property: | Function: |
---|---|
Material | 用于更新自定义渲染纹理的材质 |
Shader Pass | Shader Pass 用于更新 Custom Texture. 组合框将显示您的素材中所有可用的通道。 |
Initialization Mode | 纹理更新的频率。 |
OnLoad | 纹理在创建时初始化一次。 |
Realtime | 每帧都初始化纹理。 |
OnDemand | 通过脚本命令更新 |
Source | 更新的方式 |
Texture and Color | 通过材质和颜色 |
Initialization Color | 初始化自定义纹理的颜色。如果还提供了初始化纹理,则和第一项一样 |
Initialization Texture | Texture with which the custom texture is initialized. If an initialization color is provided as well, the custom texture will be initialized by the multiplication of the color and the texture. |
Material | 通过材质球更新 |
Initialization Material | Material with which the custom texture is initialized. |
Update Mode | 更新的频率 |
OnLoad | The texture is updated once upon creation. |
Realtime | The texture is updated every frame. |
OnDemand | The texture is updated on demand from script. |
Period | 更新的时间(Realtime only) Period in seconds at which real-time texture is updated (0.0 will update every frame). |
Double Buffered | 双度缓存 |
Wrap Update Zones | 允许部分更新区域环绕纹理的边界。 |
Cubemap Faces | (Cubemap only) Series of toggle allowing user to enable/disable update on each of the cubemap faces. |
Update Zone Space | 定义更新区域的坐标系统。 |
Normalized | 所有坐标和大小都在0和1之间,左上角从(0,0)开始 |
Pixel | All coordinates and sizes are expressed in pixels limited by the width and height of the texture. Top-left corner starting at (0, 0) |
Update Zone List | List of update zones for the texture (see below for more details) |
Exporting Custom Render Texture to a file:
Custom Render Textures可以被导出成PNG or EXR file
Cubemap
Cubemap 它是六种方形纹理的集合,代表了环境的反射. 六个正方形组成了一个围绕着一个物体的假想立方体的面;每个面代表沿世界轴方向的视图 (up, down, left, right, forward and back).
Cubemaps通常用于捕获物体的反射或“环境”; for example skyboxes and environment reflections often use cubemaps.
Creating Cubemaps from Textures
创建cubemaps的最快方法是从特殊布局的纹理中导入它们 Textures
. Select the Texture in the Project window, to see the Import Settings in the Inspector
Texture Shape设置为Cube. Unity会把texture自动转换成 Cubemap.
cubemap有几种布局
垂直和水平交叉布局,以及cubemap面列和行的支持:
另一种常见的布局是 LatLong
(经纬度,有时称为圆柱形). Panorama images are often in this layout:
SphereMap
(spherical environment map) images can also be found:
默认情况下,Unity会查看导入纹理的长宽比来决定最合适的布局。当导入时,生成的cubemap可用于天空盒和反射:
选择Glossy Reflection
选项对于将被使用的cubemap纹理非常有用 Reflection Probes
. 它以一种特殊的方式处理cubemap mip级别(specular convolution),可以用来模拟来自不同平滑度表面的反射:
Legacy Cubemap Assets
Assets > Create > Legacy > Cubemap
Legacy Cubemap Inspector
Property: | Function: |
---|---|
Right..Back Slots | Textures for the corresponding cubemap face. |
Face Size | 每个Cubemap面的宽度和高度(以像素为单位) 。纹理将自动缩放,以适应这个大小。 |
Mipmap | Should mipmaps be created? |
Linear | cubemap应该使用线性颜色吗? |
Readable | Should the cubemap allow scripts to access the pixel data? |
注意在导入图片时,使用cube类型创建cubemap是首选的-这种方式 cubemap 可以被 compressed; 边缘修正 and 光反射; and HDR cubemaps are supported.
Other Techniques
通过脚本也能生成cubemap, Camera.RenderToCubemap function可以从任何想要的位置记录六个面部图像;函数的脚本参考页面上的代码示例添加了一个菜单命令,以简化此任务。
Occlusion Area
要将遮挡剔除应用于移动对象,您必须创建一个遮挡区域,然后修改其大小以适应移动对象所在的空间 ( 移动物体不能是static). 你可以通过在空物体上添加 Occlusion Area组件来创建遮挡区域(Component -> Rendering -> Occlusion Area in the menus).
添加完Occlusion Area组件之后, 勾选上 Is View Volume
Property: | Function: |
---|---|
Size | Defines the size of the Occlusion Area. |
Center | Sets the center of the Occlusion Area. By default this is 0,0,0 and is located in the center of the box. |
Is View Volume | Defines where the camera can be. Check this in order to occlude static objects that are inside this Occlusion Area. |
添加完之后 Occlusion Area, 你需要看看它是如何把盒子分成单元格的,选择 Edit 在 Occlusion Culling Preview Panel的volume上打上勾
Occlusion Portals
和Occlusion Area一样,只不过这个可以在运行时打开或关闭遮挡区域