渲染纹理是可对其进行渲染的纹理。
它们可用于实现基于图像的渲染特效、动态阴影、
投影器、反射或监视摄像机。
渲染纹理的一个典型用法是将其设置为
摄像机的“目标纹理”属性 (Camera.targetTexture),这将使摄像机渲染到纹理,
而不是渲染到屏幕。
请记住,渲染纹理内容在某些情况下会“丢失”,例如加载新关卡、系统进入屏幕保护模式、进入和退出全屏模式等。
当发生这些情况时,您现有的渲染纹理将再度变为“尚未创建”的状态,您可以使用 IsCreated 函数对此进行检查。
与其他“本机引擎对象”类型一样,必须时刻注意任何渲染纹理的生命周期,
并牢记在使用完渲染纹理后使用 Release 函数释放它们,
因为系统不会像对待常规托管类型那样对它们进行垃圾回收。
A render texture only has a data representation on the GPU and you need to use Texture2D.ReadPixels to transfer its contents to CPU memory.
The initial contents of a newly created render texture are undefined. On some platforms and APIs the contents will default to black, but you shouldn't depend on this. You can use LoadStoreActionDebugModeSettings to highlight undefined areas of the display, to help you debug rendering problems in your built application.
另请参阅:Camera.targetTexture。
active | 当前处于活动状态的渲染纹理。 |
antiAliasing | RenderTexture 的抗锯齿级别。 |
autoGenerateMips | 如果设置了该标志,则自动生成多级渐进纹理级别。 |
bindTextureMS | 如果为 true 且 antiAliasing 大于 1,则默认不解析渲染纹理。如果需要在着色器中将渲染纹理绑定为多重采样纹理,请使用该属性。 |
colorBuffer | 渲染纹理的颜色缓冲区(只读)。 |
depth | The precision of the render texture's depth buffer in bits (0, 16, 24 and 32 are supported). |
depthBuffer | 渲染纹理的深度/模板缓冲区(只读)。 |
depthStencilFormat | The format of the depth/stencil buffer. |
descriptor | 此结构包含创建 RenderTexture 需要的所有信息。可以复制、缓存和重用来轻松创建全部共享相同属性的 RenderTexture。 |
dimension | 渲染纹理的维度(类型)。 |
enableRandomWrite | 在 Shader Model 5.0 级别着色器上启用随机访问写入该渲染纹理。 |
graphicsFormat | The color format of the render texture. You can set the color format to None to achieve depth-only rendering. |
height | 渲染纹理的高度(以像素为单位)。 |
memorylessMode | 渲染纹理无记忆模式属性。 |
sRGB | 该渲染纹理是否使用 sRGB 读/写转换?(只读) |
stencilFormat | The format of the stencil data that you can encapsulate within a RenderTexture.Specifying this property creates a stencil element for the RenderTexture and sets its format. This allows for stencil data to be bound as a Texture to all shader types for the platforms that support it. This property does not specify the format of the stencil buffer, which is constrained by the depth buffer format specified in RenderTexture.depth.Currently, most platforms only support R8_UInt (DirectX11, DirectX12), while PS4 also supports R8_UNorm. |
useDynamicScale | Is the render texture marked to be scaled by the Dynamic Resolution system. |
useMipMap | 如果设置该标志,则渲染纹理具有多级渐进纹理。 |
volumeDepth | 3D 渲染纹理的体积范围或数组纹理的切片数。 |
vrUsage | 如果该 RenderTexture 是在立体渲染中使用的 VR 眼睛纹理,则该属性决定将进行哪些特殊渲染(如果有)。 |
width | 渲染纹理的宽度(以像素为单位)。 |
RenderTexture | 创建一个新的 RenderTexture 对象。 |
ConvertToEquirect | 将渲染纹理转换为等距圆柱投影格式(都为立体或单视场等距圆柱投影)。 左眼占据上半部分,右眼占据底部。单视场版本将占据整个纹理。 纹理尺寸必须为 TextureDimension.Cube 类型。 |
Create | 实际创建 RenderTexture。 |
DiscardContents | 提示 GPU 驱动程序将不使用 RenderTexture 的内容。 |
GenerateMips | 生成渲染纹理的多级渐进纹理级别。 |
GetNativeDepthBufferPtr | 获取指向该深度缓冲区资源的原生(底层图形 API)指针。 |
IsCreated | 是否实际创建了该渲染纹理? |
Release | 释放 RenderTexture。 |
ResolveAntiAliasedSurface | 强制解析抗锯齿渲染纹理。 |
SetGlobalShaderProperty | 将该 RenderTexture 指定为名为 propertyName 的全局着色器属性。 |
GetTemporary | 分配临时渲染纹理。 |
ReleaseTemporary | 释放使用 GetTemporary 分配的临时纹理。 |
SupportsStencil | RenderTexture 是否具有模板缓冲区? |
allowThreadedTextureCreation | Allow Unity internals to perform Texture creation on any thread (rather than the dedicated render thread). |
currentTextureMemory | The amount of memory that all Textures in the scene use. |
desiredTextureMemory | The total size of the Textures, in bytes, that Unity loads if there were no other constraints. Before Unity loads any Textures, it applies the memory budget which reduces the loaded Texture resolution if the Texture sizes exceed its value. The desiredTextureMemory value takes into account the mipmap levels that Unity has requested or that you have set manually.For example, if Unity does not load a Texture at full resolution because it is far away or its requested mipmap level is greater than 0, Unity reduces the desiredTextureMemory value to match the total memory needed.The desiredTextureMemory value can be greater than the Texture.targetTextureMemory value. |
GenerateAllMips | Can be used with Texture constructors that take a mip count to indicate that all mips should be generated. The value of this field is -1. |
nonStreamingTextureCount | The number of non-streaming Textures in the scene. This includes instances of Texture2D and CubeMap Textures. This does not include any other Texture types, or 2D and CubeMap Textures that Unity creates internally. |
nonStreamingTextureMemory | The amount of memory Unity allocates for non-streaming Textures in the scene. This only includes instances of Texture2D and CubeMap Textures. This does not include any other Texture types, or 2D and CubeMap Textures that Unity creates internally. |
streamingMipmapUploadCount | How many times has a Texture been uploaded due to Texture mipmap streaming. |
streamingRendererCount | Number of renderers registered with the Texture streaming system. |
streamingTextureCount | Number of streaming Textures. |
streamingTextureDiscardUnusedMips | This property forces the streaming Texture system to discard all unused mipmaps instead of caching them until the Texture memory budget is exceeded. This is useful when you profile or write tests to keep a predictable set of Textures in memory. |
streamingTextureForceLoadAll | Force streaming Textures to load all mipmap levels. |
streamingTextureLoadingCount | Number of streaming Textures with mipmaps currently loading. |
streamingTexturePendingLoadCount | Number of streaming Textures with outstanding mipmaps to be loaded. |
targetTextureMemory | The total amount of Texture memory that Unity allocates to the Textures in the scene after it applies the memory budget and finishes loading Textures. `targetTextureMemory`also takes mipmap streaming settings into account. This value only includes instances of Texture2D and CubeMap Textures. This value does not include any other Texture types, or 2D and CubeMap Textures that Unity creates internally. |
totalTextureMemory | The total amount of Texture memory that Unity would use if it loads all Textures at mipmap level 0. This is a theoretical value that does not take into account any input from the streaming system or any other input, for example when you set the`Texture2D.requestedMipmapLevel` manually. To see a Texture memory value that takes inputs into account, use `desiredTextureMemory`. `totalTextureMemory` only includes instances of Texture2D and CubeMap Textures. This value does not include any other Texture types, or 2D and CubeMap Textures that Unity creates internally. |
hideFlags | 该对象应该隐藏、随场景一起保存还是由用户修改? |
name | 对象的名称。 |
anisoLevel | Defines the anisotropic filtering level of the Texture. |
dimension | Dimensionality (type) of the Texture (Read Only). |
filterMode | Filtering mode of the Texture. |
graphicsFormat | Returns the GraphicsFormat format or color format of a Texture object. |
height | Height of the Texture in pixels (Read Only). |
imageContentsHash | 纹理的哈希值。 |
isDataSRGB | Returns true if the texture pixel data is in sRGB color space (Read Only). |
isReadable | Whether Unity stores an additional copy of this texture's pixel data in CPU-addressable memory. |
mipMapBias | The mipmap bias of the Texture. |
mipmapCount | How many mipmap levels are in this Texture (Read Only). |
updateCount | This counter is incremented when the Texture is updated. |
width | Width of the Texture in pixels (Read Only). |
wrapMode | 纹理坐标换行模式。 |
wrapModeU | 纹理 U 坐标换行模式。 |
wrapModeV | 纹理 V 坐标换行模式。 |
wrapModeW | Texture3D 的纹理 W 坐标换行模式。 |
GetInstanceID | Gets the instance ID of the object. |
ToString | 返回对象的名称。 |
GetNativeTexturePtr | Retrieve a native (underlying graphics API) pointer to the Texture resource. |
IncrementUpdateCount | 递增更新计数器。 |
Destroy | 移除 GameObject、组件或资源。 |
DestroyImmediate | 立即销毁对象 /obj/。强烈建议您改用 Destroy。 |
DontDestroyOnLoad | 在加载新的 Scene 时,请勿销毁 Object。 |
FindAnyObjectByType | Retrieves any active loaded object of Type type. |
FindFirstObjectByType | Retrieves the first active loaded object of Type type. |
FindObjectOfType | 返回第一个类型为 type 的已加载的激活对象。 |
FindObjectsByType | Retrieves a list of all loaded objects of Type type. |
FindObjectsOfType | Gets a list of all loaded objects of Type type. |
Instantiate | 克隆 original 对象并返回克隆对象。 |
SetGlobalAnisotropicFilteringLimits | 设置各向异性限制。 |
SetStreamingTextureMaterialDebugProperties | This function sets mipmap streaming debug properties on any materials that use this Texture through the mipmap streaming system. |
bool | 该对象是否存在? |
operator != | 比较两个对象是否引用不同的对象。 |
operator == | 比较两个对象引用,判断它们是否引用同一个对象。 |