返回介绍

RenderTexture.GetTemporary 获取临时渲染纹理

发布于 2019-12-18 15:38:27 字数 3127 浏览 4534 评论 0 收藏 0

JavaScript => public static function GetTemporary(width: int, height: int, depthBuffer: int = 0, format: RenderTextureFormat = RenderTextureFormat.Default, readWrite: RenderTextureReadWrite = RenderTextureReadWrite.Default, antiAliasing: int = 1): RenderTexture;
C# => public static RenderTexture GetTemporary(int width, int height, int depthBuffer = 0, RenderTextureFormat format = RenderTextureFormat.Default, RenderTextureReadWrite readWrite = RenderTextureReadWrite.Default, int antiAliasing = 1);

Parameters 参数

widthWidth in pixels.
heightHeight in pixels.
depthBufferDepth buffer bits (0, 16 or 24). Note that only 24 bit depth has stencil buffer.
format Rendertexture format.
readWriteColor space conversion mode.
antiAliasingAnti-aliasing (1,2,4,8).

Description 描述

Allocate a temporary render texture.

分配一个临时的渲染纹理。

This function is optimized for when you need a quick RenderTexture to do some temporary calculations. Release it using ReleaseTemporary as soon as you're done with it, so another call can start reusing it if needed.

此函数进行了优化,用于当你需要一个快速RenderTexture来做一些临时计算时,一旦完成,ReleaseTemporary释放它,这样,如果需要,另一个调用能够开始重用它。

Internally Unity keeps a pool of temporary render textures, so a call to GetTemporary most often just returns an already created one (if the size and format matches). These temporary render textures are actually destroyed when they aren't used for a couple of frames.

Unity内部保持的临时渲染纹理,因此调用GetTemporary 最可能经常返回已经创建的渲染纹理(如果尺寸和格式匹配)。当它们不用于几帧时这些临时渲染贴图实际上已经销毁。

If you are doing a series of post-processing “blits”, it's best for performance to get and release a temporary render texture for each blit, instead of getting one or two render textures upfront and reusing them. This is mostly beneficial for mobile (tile-based) and multi-GPU systems: GetTemporary will internally do a DiscardContents call which helps to avoid costly restore operations on the previous render texture contents.

如果你在做一系列的后处理“位块”,释放每个blit的临时渲染纹理可获取最佳的性能。而不是获取一个或者两个渲染纹理提前或再利用它们。这有益于移动(基于平铺)和多GPU系统:GetTemporary 将会在之前渲染纹理内容内部调用DiscardContents 帮助避免高昂代价的还原操作。

You can not depend on any particular contents of the RenderTexture you get from GetTemporary function. It might be garbage, or it might be cleared to some color, depending on the platform.

你不能依赖从GetTemporary 函数获取的任何特定内容渲染纹理,或者它可能被清除某些颜色,这取决于所用的平台。

rendertexture

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文