Legacy Documentation: Version 5.0
Language: English
  • C#
  • JS

Script language

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

Graphics.SetRenderTarget

Switch to Manual
public static function SetRenderTarget(rt: RenderTexture): void;
public static function SetRenderTarget(rt: RenderTexture, mipLevel: int): void;
public static function SetRenderTarget(rt: RenderTexture, mipLevel: int, face: CubemapFace): void;
public static function SetRenderTarget(colorBuffer: RenderBuffer, depthBuffer: RenderBuffer): void;
public static function SetRenderTarget(colorBuffers: RenderBuffer[], depthBuffer: RenderBuffer): void;
public static function SetRenderTarget(colorBuffer: RenderBuffer, depthBuffer: RenderBuffer, mipLevel: int): void;
public static function SetRenderTarget(colorBuffer: RenderBuffer, depthBuffer: RenderBuffer, mipLevel: int, face: CubemapFace): void;

Parameters

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.

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.

Calling SetRenderTarget with just a RenderTexture argument is the same as setting RenderTexture.active property.

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