Legacy Documentation: Version 4.5.0

Script language:

  • JS
  • C#
  • Boo
Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

Graphics.SetRenderTarget

static function SetRenderTarget(rt: RenderTexture): void;
static void SetRenderTarget(RenderTexture rt);
static def SetRenderTarget(rt as RenderTexture) as void
static function SetRenderTarget(rt: RenderTexture, mipLevel: int): void;
static void SetRenderTarget(RenderTexture rt, int mipLevel);
static def SetRenderTarget(rt as RenderTexture, mipLevel as int) as void
static function SetRenderTarget(rt: RenderTexture, mipLevel: int, face: CubemapFace): void;
static void SetRenderTarget(RenderTexture rt, int mipLevel, CubemapFace face);
static def SetRenderTarget(rt as RenderTexture, mipLevel as int, face as CubemapFace) as void
static function SetRenderTarget(colorBuffer: RenderBuffer, depthBuffer: RenderBuffer): void;
static void SetRenderTarget(RenderBuffer colorBuffer, RenderBuffer depthBuffer);
static def SetRenderTarget(colorBuffer as RenderBuffer, depthBuffer as RenderBuffer) as void
static function SetRenderTarget(colorBuffers: RenderBuffer[], depthBuffer: RenderBuffer): void;
static void SetRenderTarget(RenderBuffer[] colorBuffers, RenderBuffer depthBuffer);
static def SetRenderTarget(colorBuffers as RenderBuffer[], depthBuffer as RenderBuffer) as void

Description

Sets current render target.

This function sets which RenderTexture 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 texture manually. Requires Unity Pro.

Variants with mipLevel and face arguments enable rendering into a specific mipmap level of a RenderTexture, or specific cubemap face of a cubemap RenderTexture.

The function call with colorBuffers array enables techniques that use Multiple Render Targets (MRT), where fragment shader can output more than one final color.

See Also: RenderTexture, Graphics.activeColorBuffer, Graphics.activeDepthBuffer, SystemInfo.supportedRenderTargetCount.