Render Textures are special types of Textures that are created and updated at runtime. 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.
渲染紋理是一種特殊的紋理類型在運(yùn)行時(shí)產(chǎn)生和更新。要使用他們,你首先要?jiǎng)?chuàng)建一個(gè)新的渲染紋理并且要指定一個(gè)攝像機(jī)進(jìn)行渲染。然后你可以在材質(zhì)中使用渲染紋理就像常規(guī)的紋理一樣。在Unity Standard Assets中的Water的預(yù)置體就是一個(gè)真實(shí)的世界使用渲染紋理來(lái)實(shí)時(shí)進(jìn)行反射和折射的例子。
Render Textures are a Unity Pro feature.
渲染紋理是Unity Pro版本的功能。
Properties 屬性
The Render Texture Inspector is different from most Inspectors, but very similar to the Texture Inspector.
渲染紋理的監(jiān)視面板和大多數(shù)監(jiān)視面板不同,但是和紋理監(jiān)視面板非常相似。

The Render Texture Inspector is almost identical to the Texture Inspector
渲染紋理的監(jiān)視面板和紋理的監(jiān)視面板幾乎相同。
The Render Texture inspector displays the current contents of Render Texture in realtime and can be an invaluable debugging tool for effects that use render textures.
渲染紋理的監(jiān)視面板展示了實(shí)時(shí)渲染紋理的當(dāng)前內(nèi)容,并且有一個(gè)可貴的調(diào)試工具來(lái)調(diào)試渲染紋理的效果。
-
Size 大小
The size of the Render Texture in pixels. Observe that only power-of-two values sizes can be chosen.
渲染紋理的像素大小。觀看下只有power-of-two的值大小能被選擇。
-
Aniso Level 各向異性等級(jí)
Increases Texture quality when viewing the texture at a steep angle. Good for floor and ground textures
在一個(gè)很陡的角度觀看紋理時(shí),紋理的質(zhì)量會(huì)提高。這對(duì)于地板和地面紋理不錯(cuò)。
Filter Mode 過(guò)濾模式
Selects how the Texture is filtered when it gets stretched by 3D transformations:
當(dāng)進(jìn)行3D變換時(shí)選擇什么樣的紋理過(guò)濾器。
-
No Filtering 無(wú)過(guò)濾
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
和雙線一樣,但是紋理在不同的紋理層級(jí)貼圖之間模糊。
Wrap Mode 循環(huán)模式
Selects how the Texture behaves when tiled:
選擇紋理如果平鋪:
-
Repeat 重復(fù)
The Texture repeats (tiles) itself
紋理自身重復(fù)。
Clamp 鉗制
The Texture's edges get stretched
紋理的邊緣得到伸展。
Example 例子
A very quick way to make a live arena-camera in your game:
在你的游戲中創(chuàng)建一個(gè)實(shí)時(shí)的舞臺(tái)攝像機(jī)有一個(gè)非常快速的方式:
- Create a new Render Texture asset using Assets->Create->Render Texture.
通過(guò) Assets->Create->Render Texture.創(chuàng)建一個(gè)渲染紋理資源。 - Create a new Camera using GameObject->Create Other->Camera.
通過(guò)GameObject->Create Other->Camera.創(chuàng)建一個(gè)新的攝像機(jī)。 - Assign the Render Texture to the Target Texture of the new Camera.
給新的攝像機(jī)的Target Texture指定渲染紋理。 - Create a wide, tall and thin box
創(chuàng)建一個(gè)寬的,高的和瘦的框。 - Drag the Render Texture onto it to create a Material that uses the render texture.
把渲染紋理拖放給一個(gè)新建的材質(zhì)球,然后使用渲染紋理。 - Enter Play Mode, and observe that the box's texture is updated in real-time based on the new Camera's output.
進(jìn)入播放模式,并觀察到框的紋理是實(shí)時(shí)更新基于相機(jī)的輸出。

Render Textures are set up as demonstrated above
渲染紋理的設(shè)置如上所述
Hints 提示
- Unity renders everything in the texture assigned to RenderTexture.active.
Unity渲染任何指定了RenderTexture.active的紋理