Version: 2021.1

CustomRenderTexture

class in UnityEngine

/

继承自:RenderTexture

切换到手册

描述

自定义渲染纹理是渲染纹理的扩展,可使您使用着色器直接对纹理进行渲染。

自定义渲染纹理是渲染纹理的扩展,允许您使用着色器轻松更新纹理,然后将其用于常规材质。这对于实现各种类型的复杂模拟非常有用,例如:水焦散、雨水效果的波纹模拟,或者墙上的液体喷溅。此外,它还提供脚本和着色器框架,从而协助进行更复杂的配置,如部分或多通道更新,以及改变更新频率等。

变量

cubemapFaceMask位域,用于对每个立方体贴图面启用或禁用更新。从重要性最低的位开始,顺序为 +X、-X、+Y、-Y、+Z、-Z。
doubleBuffered如果为 true,则自定义渲染纹理将接受双缓冲,以便您能够在其自身更新期间访问它。否则自定义渲染纹理将不接受双缓冲。
initializationColor用于初始化自定义渲染纹理的颜色。如果设置了 initializationMaterial,则将忽略此参数。
initializationMaterial用于初始化自定义渲染纹理的材质。如果设置了此参数,则忽略初始化纹理和颜色。
initializationMode指定应如何初始化该纹理。
initializationSource指定是否应使用纹理和颜色或材质初始化该纹理。
initializationTexture纹理,用于初始化自定义渲染纹理(叠加初始化颜色)。如果设置了 initializationMaterial,则将忽略此参数。
material材质,用于更新自定义渲染纹理的内容。
shaderPass用于更新自定义渲染纹理的着色器通道。
updateMode指定应如何更新该纹理。
updatePeriodPeriod in seconds at which real-time textures are updated (0.0 will update every frame).
updateZoneSpace表示这些更新区域所在的空间(标准化或像素空间)。
wrapUpdateZones如果为 true,则更新区域将包围自定义渲染纹理的边框。否则,更新区域将被限制在自定义渲染纹理的边框。

构造函数

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

公共函数

ClearUpdateZones清除所有更新区域。
EnsureDoubleBufferConsistencyUpdates the internal RenderTexture that a CustomRenderTexture uses for double buffering, so that it matches the size and format of the CustomRenderRexture.
GetDoubleBufferRenderTextureGets the RenderTexture that this CustomRenderTexture uses for double buffering.
GetUpdateZones返回更新区域列表。
Initialize触发自定义渲染纹理的初始化。
SetUpdateZones为自定义渲染纹理设置更新区域列表。
Update触发自定义渲染纹理的更新。

继承的成员

静态变量

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. It 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. It 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渲染纹理的颜色缓冲区(只读)。
depth渲染纹理深度缓冲区的精度(以位为单位,支持 0、16、24/32 位)。
depthBuffer渲染纹理的深度/模板缓冲区(只读)。
descriptor此结构包含创建 RenderTexture 需要的所有信息。可以复制、缓存和重用来轻松创建全部共享相同属性的 RenderTexture。
dimension渲染纹理的维度(类型)。
enableRandomWrite在 Shader Model 5.0 级别着色器上启用随机访问写入该渲染纹理。
graphicsFormat渲染纹理的颜色格式。
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.
useDynamicScale渲染纹理是否标记为由动态分辨率系统进行缩放。
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纹理的哈希值。
isReadableReturns true if the Read/Write Enabled checkbox was checked when the Texture was imported; otherwise returns false. For a dynamic Texture created from script, always returns true. For additional information, see TextureImporter.isReadable.
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 ==比较两个对象引用,判断它们是否引用同一个对象。
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961