Version: 2022.1

CustomRenderTexture

class in UnityEngine

/

继承自:RenderTexture

切换到手册

描述

Custom Render Textures are an extension to Render Textures that allow you to render directly to the Texture using a Shader.

Custom Render Textures are an extension to Render Textures that allow you to update a texture with a Shader, and then use it in a regular Material. This is useful for implementing all kinds of complex simulations, for instance: water caustics, ripple simulations for rain effects, or splatting liquids against a wall. Also provided is a scripting and Shader framework to help with more complicated configurations like partial or multi-pass updates, and varying update frequency.

变量

cubemapFaceMaskThe bit field that you can use to enable or disable update on each of the cubemap faces. The bit order from least to most significant bit is as follows: +X, -X, +Y, -Y, +Z, -Z.
doubleBufferedWhen this parameter is set to true, Unity double-buffers the Custom Render Texture so that you can access it during its own update.
initializationColorThe color that Unity uses to initialize a Custom Render Texture. Unity ignores this parameter if an initializationMaterial is set.
initializationMaterialThe Material that Unity uses to initialize a Custom Render Texture. Initialization texture and color are ignored if you have set this parameter.
initializationModeDetermine how Unity initializes a texture.
initializationSourceDetermine if Unity initializes the Custom Render Texture with a Texture and a Color or a Material.
initializationTextureThe Texture that Unity uses to initialize a Custom Render Texture, multiplied by the initialization color. Unity ignores this parameter if an initializationMaterial is set.
materialThe Material that Unity uses to initialize the content of a Custom Render Texture.
shaderPassThe Shader Pass Unity uses to update the Custom Render Texture.
updateModeDetermine how Unity updates the Custom Render Texture.
updatePeriodThe period in seconds that Unity updates real-time Custom Render Textures. A value of 0.0 means Unity updates real-time Custom Render Textures every frame.
updateZoneSpaceThe space in which Unity expresses update zones. You can set this to Normalized or Pixel space.
wrapUpdateZonesWhen this parameter is set to true, Unity wraps Update zones around the border of the Custom Render Texture. Otherwise, Unity clamps Update zones at the border of the Custom Render Texture.

构造函数

CustomRenderTexture创建一个新的自定义渲染纹理。

公共函数

ClearUpdateZones清除所有更新区域。
EnsureDoubleBufferConsistencyUpdates the internal Render Texture that a Custom Render Texture uses for double buffering, so that it matches the size and format of the Custom Render Texture.
GetDoubleBufferRenderTextureGets the Render Texture that this Custom Render Texture uses for double buffering.
GetUpdateZones返回更新区域列表。
InitializeInitializes the Custom Render Texture at the start of the next frame. Unity calls /Initialise()/ before /CustomRenderTexture.Update/.
SetUpdateZones为自定义渲染纹理设置更新区域列表。
UpdateTriggers an update of the Custom Render Texture.

继承的成员

静态变量

active当前处于活动状态的渲染纹理。
allowThreadedTextureCreationAllow Unity internals to perform Texture creation on any thread (rather than the dedicated render thread).
currentTextureMemoryThe amount of memory that all Textures in the scene use.
desiredTextureMemoryThe 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 `targetTextureMemory` value.
GenerateAllMipsCan 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.
nonStreamingTextureCountThe 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.
nonStreamingTextureMemoryThe 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.
streamingMipmapUploadCountHow many times has a Texture been uploaded due to Texture mipmap streaming.
streamingRendererCountNumber of renderers registered with the Texture streaming system.
streamingTextureCountNumber of streaming Textures.
streamingTextureDiscardUnusedMipsThis 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.
streamingTextureForceLoadAllForce streaming Textures to load all mipmap levels.
streamingTextureLoadingCountNumber of streaming Textures with mipmaps currently loading.
streamingTexturePendingLoadCountNumber of streaming Textures with outstanding mipmaps to be loaded.
targetTextureMemoryThe 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.
totalTextureMemoryThe 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对象的名称。
antiAliasingRenderTexture 的抗锯齿级别。
autoGenerateMips如果设置了该标志,则自动生成多级渐进纹理级别。
bindTextureMS如果为 true 且 antiAliasing 大于 1,则默认不解析渲染纹理。如果需要在着色器中将渲染纹理绑定为多重采样纹理,请使用该属性。
colorBuffer渲染纹理的颜色缓冲区(只读)。
depthThe precision of the render texture's depth buffer in bits (0, 16, 24 and 32 are supported).
depthBuffer渲染纹理的深度/模板缓冲区(只读)。
depthStencilFormatThe format of the depth/stencil buffer.
descriptor此结构包含创建 RenderTexture 需要的所有信息。可以复制、缓存和重用来轻松创建全部共享相同属性的 RenderTexture。
dimension渲染纹理的维度(类型)。
enableRandomWrite在 Shader Model 5.0 级别着色器上启用随机访问写入该渲染纹理。
graphicsFormatThe color format of the render texture. You can set the color format to None to achieve depth-only rendering.
height渲染纹理的高度(以像素为单位)。
memorylessMode渲染纹理无记忆模式属性。
sRGB该渲染纹理是否使用 sRGB 读/写转换?(只读)
stencilFormatThe 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.
useDynamicScaleIs the render texture marked to be scaled by the Dynamic Resolution system.
useMipMap如果设置该标志,则渲染纹理具有多级渐进纹理。
volumeDepth3D 渲染纹理的体积范围或数组纹理的切片数。
vrUsage如果该 RenderTexture 是在立体渲染中使用的 VR 眼睛纹理,则该属性决定将进行哪些特殊渲染(如果有)。
width渲染纹理的宽度(以像素为单位)。
anisoLevelDefines the anisotropic filtering level of the Texture.
dimensionDimensionality (type) of the Texture (Read Only).
filterModeFiltering mode of the Texture.
graphicsFormatReturns the GraphicsFormat format or color format of a Texture object.
heightHeight of the Texture in pixels (Read Only).
imageContentsHash纹理的哈希值。
isReadableWhether Unity stores an additional copy of this texture's pixel data in CPU-addressable memory.
mipMapBiasThe mipmap bias of the Texture.
mipmapCountHow many mipmap levels are in this Texture (Read Only).
updateCountThis counter is incremented when the Texture is updated.
widthWidth of the Texture in pixels (Read Only).
wrapMode纹理坐标换行模式。
wrapModeU纹理 U 坐标换行模式。
wrapModeV纹理 V 坐标换行模式。
wrapModeW Texture3D 的纹理 W 坐标换行模式。

公共函数

GetInstanceIDGets the instance ID of the object.
ToString返回对象的名称。
ConvertToEquirect将渲染纹理转换为等距圆柱投影格式(都为立体或单视场等距圆柱投影)。 左眼占据上半部分,右眼占据底部。单视场版本将占据整个纹理。 纹理尺寸必须为 TextureDimension.Cube 类型。
Create实际创建 RenderTexture。
DiscardContents提示 GPU 驱动程序将不使用 RenderTexture 的内容。
GenerateMips生成渲染纹理的多级渐进纹理级别。
GetNativeDepthBufferPtr获取指向该深度缓冲区资源的原生(底层图形 API)指针。
IsCreated是否实际创建了该渲染纹理?
Release释放 RenderTexture。
ResolveAntiAliasedSurface强制解析抗锯齿渲染纹理。
SetGlobalShaderProperty将该 RenderTexture 指定为名为 propertyName 的全局着色器属性。
GetNativeTexturePtrRetrieve a native (underlying graphics API) pointer to the Texture resource.
IncrementUpdateCount递增更新计数器。

静态函数

Destroy移除 GameObject、组件或资源。
DestroyImmediate立即销毁对象 /obj/。强烈建议您改用 Destroy。
DontDestroyOnLoad在加载新的 Scene 时,请勿销毁 Object。
FindObjectOfType返回第一个类型为 type 的已加载的激活对象。
FindObjectsOfTypeGets a list of all loaded objects of Type type.
Instantiate克隆 original 对象并返回克隆对象。
GetTemporary分配临时渲染纹理。
ReleaseTemporary释放使用 GetTemporary 分配的临时纹理。
SupportsStencilRenderTexture 是否具有模板缓冲区?
SetGlobalAnisotropicFilteringLimits设置各向异性限制。
SetStreamingTextureMaterialDebugPropertiesThis function sets mipmap streaming debug properties on any materials that use this Texture through the mipmap streaming system.

运算符

bool该对象是否存在?
operator !=比较两个对象是否引用不同的对象。
operator ==比较两个对象引用,判断它们是否引用同一个对象。