特定于平台的覆盖的纹理压缩格式
自定义渲染纹理

渲染纹理

Render Textures are special types of Textures that are created and updated at run time. To use them, you first create a new Render Texture and designate one of your Cameras to render into it. Then you can use the Render Texture in a Material just like a regular Texture. The Water prefabs in Unity Standard Assets are an example of real-world use of Render Textures for making real-time reflections and refractions.

属性

渲染纹理检视面板 (Render Texture Inspector) 与大多数检视面板不同,但与纹理检视面板 (Texture Inspector) 非常相似。

渲染纹理检视面板 (Render Texture Inspector) 与纹理检视面板 (Texture Inspector) 几乎相同
渲染纹理检视面板 (Render Texture Inspector) 与纹理检视面板 (Texture Inspector) 几乎相同

渲染纹理检视面板可实时显示渲染纹理的当前内容,对于使用渲染纹理的效果而言,此面板是非常有用的调试工具。

属性: 功能:
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 The size of the render texture in pixels. You can only enter power-of-two values, such as 128 and 256.
Anti-Aliasing The number of anti-aliasing samples. 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 Enable this checkbox to make Unity apply a compatible format to the render texture if the defined Color Format is not supported by the platform.
Color Format The color format of the render texture.
Depth Buffer The format of the depth buffer. You can select No depth buffer, At least 16 bits depth (no stencil), or At least 24 bits depth (with stencil). The stencil buffer is a general purpose buffer that allows you to store an additional unsigned 8-bit integer (0–255) for each pixel drawn to the screen.
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 Check this box to let dynamic resolution scaling resize the render texture. If you don’t enable this, the render texture maintains the same size regardless of the Dynamic Resolution setting.
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 Tiles the texture to create a repeating pattern that mirrors the texture at every integer boundary.
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 Anisotropic filtering level of the texture. This increases texture quality when you view the texture at a steep angle. Good for floor, ground, or road textures.

示例

在游戏中制作现场竞技场摄像机的快速方法:

1.使用 Assets > Create > Render Texture 创建新的渲染纹理资源。 1.使用 GameObject > Camera 创建新的摄像机。 1.将渲染纹理分配给新摄像机的 Target Texture。 1.创建一个宽、高、薄的盒体 1.将渲染纹理拖动到其上以创建使用渲染纹理的材质。 1.进入播放模式,观察盒体的纹理是否会根据新摄像机的输出情况实时更新。

Render Textures are set up as demonstrated above
Render Textures are set up as demonstrated above

  • 2019–04–11 Page amended with editorial review

  • Render Texture inspector changed in Unity 2017.2

  • Ability to apply any GPU format to Render Textures added in Unity 2019.1

特定于平台的覆盖的纹理压缩格式
自定义渲染纹理