Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.
CloseFor some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.
Closert | RenderTexture or GraphicsTexture to set as active render target. |
mipLevel | Mipmap level to render into (use 0 if not mipmapped). |
face | Cubemap face to render into (use Unknown if not a cubemap). |
depthSlice | Depth slice to render into (use 0 if not a 3D or 2DArray render target). |
colorBuffer | Color buffer to render into. |
depthBuffer | Depth buffer to render into. |
colorBuffers | Color buffers to render into (for multiple render target effects). |
setup | Full render target setup information. |
Sets current render target.
This function sets which RenderTexture, GraphicsTexture, or a RenderBuffer combination will be
rendered into next. Use it when implementing custom rendering algorithms, where
you need to render something into a render target texture manually.
Variants with mipLevel and face arguments enable rendering into a specific mipmap level
of a texture, or specific cubemap face of a cubemap RenderTexture/GraphicsTexture.
Variants with depthSlice allow rendering into a specific slice of a 3D or 2DArray render texture.
The function call with colorBuffers array enables techniques that use
Multiple Render Targets (MRT), where fragment shader can output more
than one final color.
Calling SetRenderTarget with just a RenderTexture or GraphicsTexture argument is the same as setting the RenderTexture.active and GraphicsTexture.active property.
To set a GraphicsTexture as the render target, it must have GraphicsTextureDescFlags.RenderTarget enabled in GraphicsTexture.descriptor.flags.
Note that in Linear color space, it is important to have the correct sRGB<->Linear color conversion
state set. Depending on what was rendered previously, the current state might not be the one you expect.
You should consider setting GL.sRGBWrite as you need it before doing SetRenderTarget or any other
manual rendering.
Additional resources: RenderTexture, GraphicsTexture, 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.