rt | 要设置为激活渲染目标的 RenderTexture。 |
mipLevel | 要渲染到的 Mipmap 级别(如果不是 Mipmap,则使用 0)。 |
face | 要渲染到的立方体贴图面(如果不是立方体贴图,则使用 Unknown)。 |
depthSlice | 要渲染到的深度切片(如果不是 3D 或 2DArray 渲染目标,则使用 0)。 |
colorBuffer | 要渲染到的颜色缓冲区。 |
depthBuffer | 要渲染到的深度缓冲区。 |
colorBuffers | 要渲染到的颜色缓冲区(用于多个渲染目标效果)。 |
setup | 完整渲染目标设置信息。 |
设置当前渲染目标。
该函数设置下一个将渲染到的 RenderTexture 或 RenderBuffer
组合。在实现自定义渲染算法(需要手动将某些内容渲染到渲染纹理中)时,
您可以使用该函数。
具有 mipLevel 和面参数的变体可渲染为特定 Mipmap 级别的渲染纹理,
或渲染为立方体贴图 RenderTexture 的特定立方体贴图面。
具有 depthSlice 的变体渲染到 3D 或 2DArray 渲染纹理的特定切片中。
使用 colorBuffers 数组的函数调用启用了使用
多渲染目标 (MRT) 的技术,其中片元着色器可以输出多种
最终颜色。
在仅提供 RenderTexture 参数的情况下调用 SetRenderTarget 与设置 RenderTexture.active 属性的效果相同。
请注意,在线性颜色空间中,设置正确的 sRGB<-> 线性颜色转换
状态非常重要。受之前渲染的内容的影响,当前状态可能不是您预期的状态。
您应考虑在执行 SetRenderTarget 或任何其他手动渲染之前,将 GL.sRGBWrite 设置为
需要的值。
另请参阅:RenderTexture、Graphics.activeColorBuffer、Graphics.activeDepthBuffer、SystemInfo.supportedRenderTargetCount。
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.