rt | 为颜色和深度缓冲区设置的渲染目标。 |
color | 设置为颜色缓冲区的渲染目标。 |
colors | 设置为颜色缓冲区的渲染目标 (MRT)。 |
depth | 设置为深度缓冲区的渲染目标。 |
mipLevel | 渲染目标的要达到的 Mip 级别。 |
cubemapFace | 立方体贴图渲染目标要渲染到的立方体贴图面。 |
depthSlice | 要设置的 3D 或数组渲染目标的切片。 |
loadAction | 用于颜色和深度/模板缓冲区的加载操作。 |
storeAction | 用于颜色和深度/模板缓冲区的存储操作。 |
colorLoadAction | 用于颜色缓冲区的加载操作。 |
colorStoreAction | 用于颜色缓冲区的存储操作。 |
depthLoadAction | 用于深度/模板缓冲区的加载操作。 |
depthStoreAction | 用于深度/模板缓冲区的存储操作。 |
添加“设置活动的渲染目标”命令。
可通过若干种方式指示要使用的渲染纹理:RenderTexture 对象、用 GetTemporaryRT 创建的临时渲染纹理或内置的临时纹理之一 (BuiltinRenderTextureType)。上述所有形式的渲染纹理都用 RenderTargetIdentifier 结构来表示,该结构使用隐式转换运算符,实现键入时保存。
在命令缓冲区执行期间,不必显式保留活动的渲染目标(当前的渲染目标将被保存并在之后恢复)。
此方法具有变体,这些变体采用额外的参数(如 mipLevel (int) 和 cubemapFace)来确保能够渲染到 RenderTexture 的特定 Mipmap 级别,或者立方体贴图 RenderTexture 的特定立方体贴图面。
设置单个 RenderTarget 并且没有显式 mipLevel、cubemapFace 和 depthSlice 的重载将遵循在创建 RenderTargetIdentifier 时指定的 mipLevel、cubemapFace 和 depthSlice 值。
设置多个渲染目标的重载会将 mipLevel、cubemapFace 和 depthSlice 设置为 0、Unknown 和 0(除非另外指定)。如果指定,则会将指定的 mipLevel、cubemapFace 和 depthSlice 用于所有目标。
请注意,在线性颜色空间中,设置正确的 sRGB<-> 线性颜色转换
状态非常重要。受之前渲染的内容的影响,当前状态可能不是您预期的状态。
您应考虑在执行 SetRenderTarget 或任何其他手动渲染之前,将 GL.sRGBWrite 设置为
需要的值。
Rendering.RenderTargetIdentifier.Clear 目前不受支持。对 ClearRenderTarget 的后续调用具有相同的效果,并在支持/清除/加载操作的图形 API 上进行了优化。
另请参阅:GetTemporaryRT、ClearRenderTarget、Blit、RenderTargetIdentifier。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.