搜索
您的当前位置:首页正文

贴图设置

来源:榕意旅游网
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 have a lot of properties. If 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.

Properties

The Texture Inspector looks a bit different from most others:

The top section contains a few settings, and the bottom part contains import settings and a 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 No Filtering Bilinear Trilinear Wrap Mode Repeat Clamp

Selects how the Texture is filtered when it gets stretched by 3D transformations: The Texture becomes blocky up close The Texture becomes blurry up close

Like Bilinear, but the Texture also blurs between the different mip levels Selects how the Texture behaves when tiled: The Texture repeats (tiles) itself The Texture's edges get stretched

Import Settings

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

The Texture Import Settings dialog

Max Texture Size The maximum imported texture size. A lot of artists 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:

RGB Compressed Compressed RGB texture. This is the most common format for diffuse textures. 4 DXT1 RGBA

bits per pixel (32 KB for a 256x256 texture).

Compressed RGBA texture. This is the main format used for diffuse & specular

Compressed DXT5 control textures. 1 byte/pixel (64 KB for a 256x256 texture). 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.

RGB 24 bit Alpha 8 bit RGBA 16 bit

Truecolor but without alpha. 192 KB for a 256x256 texture.

High quality alpha channel but without any color. 64 KB for a 256x256 texture. Low-quality truecolor. Has 16 levels of red, green, blue and alpha. Compressed DXT5 format use less memory and usually look better. 128 KB for a 256x256 texture.

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 place this is used is for bump maps, as DXT compression there often carries a visible quality loss.

Build Alpha From If enabled, an alpha transparency channel will be generated by the image's existing Grayscale Non Power of 2 sizes Keep original

values of light & dark.

If texture has non-power-of-two size, this will define a scaling behavior at import time (for more info see Texture Sizes section below):

Texture will be padded to the larger power-of-two size for use with GUITexture component.

Scale 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.

Scale to larger

Texture will be scaled to the larger power-of-two size at import time. For instance 257x511 texture will become 512x512.

Scale to smaller

Texture will be scaled to the smaller power-of-two size at import time. For instance 257x511 texture will become 256x256.

Generate Cube Map Is Readable

Select this to enable access to the texture data from the 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.

Generate Mip Maps Select this to enable mip-map generation. Mip maps are smaller versions of the

texture that gets used when the texture is very small on screen. For more info, see Mip Maps below.

Generates a cubemap from the texture using different generation methods.

Correct Gamma Select this to enable per-mip-level gamma correction.

Border Mip Maps Select this to avoid colors seeping out to the edge of the lower Mip levels. Used for

light cookies (see below).

Mip Map Filtering Two ways of mip map filtering is available to optimize image quality: Box

The simplest way to fade out the mipmaps - the mip levels become smoother and smoother as they go down in size.

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.

Fade Out Mips

Enable this to make the mipmaps fade to gray the mip levels progress. This is used for detail maps.

Fade Out start Fade Out End Generate Bump Map Bumpiness Filtering Standard Sobel

The first mip level to begin fading out at.

The mip level where the texture is completely grayed out.

Enable this to turn the color channels into a format suitable for real-time bumpmapping. For more info, see Bump Maps, below. Control the amount of bumpiness.

Determine how the bumpiness is calculated: This generates normal maps that are quite smooth.

The Sobel filter generates normal maps that are sharper than Standard.

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.

Texture Sizes

Ideally texture sizes should be powers of two on the sides. 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.

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 DXT compressed textures) and will be slightly slower to load. In general you'll use non power of two sizes only for making GUI.

Non power of two texture assets can be scaled up at import time using Non Power of 2 sizes option in the import settings. Then 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.

UV Mapping

When mapping a 2D texture on to 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 bump & detail maps is especially useful.

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 you mipmaps for in-game textures; the only exceptions are textures that will never be minified (e.g. GUI textures).

Bump Maps

Bump maps are used by bump 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.

Detail Maps

If you want to do a terrain, you normally use your main texture to show where there are grass, rocks sand, etc... If your terrain has a decent size, you will end up with a very blurry terrain. Detail textures hide this fact by fading in small details as your main texture get 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.

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.

No anisotropy used on the ground texture

Maximum anisotropy used on the ground texture Light Cookies

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 foilage. The Light page has more info on all this, but the main thing is that for textures to be usable for cookies, the following properties need to be set:

For Spotlight Cookies, use the following settings:

Texture Format Any setting that has an alpha channel: Alpha 8 bit (recommended), ` DXT5 RGBA,

RGBA 16 bit or RGBA 32 bit.

Build Alpha from RGB Grayscale

Generate Mip Maps Enabled Border Mip Maps Enabled

You should keep the edges of you cookie texture solid black in order to get the proper effect. In the Texture Inspector, set the Edge Mode to Clamp.

Enabled

For Directional Lights, use the following settings:

Texture Format Any setting that has an alpha channel: Alpha 8 bit (recommended), DXT5 RGBA, RGBA 16 bit or RGBA 32 bit.

Build Alpha from RGB Grayscale

Enabled

Generate Mip Maps Enabled Border Mip Maps Disabled

This texture will tile, so in the texture inspector, you must set the Edge Mode to Repeat.

For Point Lights, you need to use Cube Maps. To generate one, either make six textures and assign them as described in Cubemap Textures or generate one with the following settings:

Texture Format Any setting that has an alpha channel: Alpha 8 bit (recommended), DXT5 RGBA, RGBA 16 bit or RGBA 32 bit.

Generate Cube Map

Build Alpha from RGB Grayscale

Any other setting than None.

Enabled

Generate Mip Maps Enabled Border Mip Maps Disabled

因篇幅问题不能全部显示,请点此查看更多更全内容

Top