# SetRenderTarget

> Sets current render target.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.0/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

## SetRenderTarget(RenderTexture, int, CubemapFace, int)

Sets current render target.

```csharp
public static void SetRenderTarget(RenderTexture rt, int mipLevel, CubemapFace face, int depthSlice)
```

### Parameters

**** (\[RenderTexture]\(/engine/6000.0/script-reference/unityengine/rendertexture)): [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md) or [GraphicsTexture](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture.md) to set as active render target.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Mipmap level to render into (use 0 if not mipmapped).**** (\[CubemapFace]\(/engine/6000.0/script-reference/unityengine/cubemapface)): Cubemap face to render into (use Unknown if not a cubemap).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Depth slice to render into (use 0 if not a 3D or 2DArray render target).

### Remarks

This function sets which [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md), [GraphicsTexture](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture.md), or a [RenderBuffer](/engine/6000.0/script-reference/unityengine/renderbuffer.md) 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](/engine/6000.0/script-reference/unityengine/rendertexture/active.md) and [GraphicsTexture.active](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture/active.md) property. To set a GraphicsTexture as the render target, it must have RenderTarget enabled in [flags](/engine/6000.0/script-reference/unityengine/rendering/graphicstexturedescriptor/flags.md).

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](/engine/6000.0/script-reference/unityengine/gl/srgbwrite.md) as you need it before doing SetRenderTarget or any other manual rendering.

Additional Resources: [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md), [GraphicsTexture](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture.md), [Graphics.activeColorBuffer](/engine/6000.0/script-reference/unityengine/graphics/activecolorbuffer.md), [Graphics.activeDepthBuffer](/engine/6000.0/script-reference/unityengine/graphics/activedepthbuffer.md), [SystemInfo.supportedRenderTargetCount](/engine/6000.0/script-reference/unityengine/systeminfo/supportedrendertargetcount.md).

## SetRenderTarget(GraphicsTexture, int, CubemapFace, int)

Sets current render target.

```csharp
public static void SetRenderTarget(GraphicsTexture rt, int mipLevel, CubemapFace face, int depthSlice)
```

### Parameters

**** (\[GraphicsTexture]\(/engine/6000.0/script-reference/unityengine/rendering/graphicstexture)): [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md) or [GraphicsTexture](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture.md) to set as active render target.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Mipmap level to render into (use 0 if not mipmapped).**** (\[CubemapFace]\(/engine/6000.0/script-reference/unityengine/cubemapface)): Cubemap face to render into (use Unknown if not a cubemap).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Depth slice to render into (use 0 if not a 3D or 2DArray render target).

### Remarks

This function sets which [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md), [GraphicsTexture](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture.md), or a [RenderBuffer](/engine/6000.0/script-reference/unityengine/renderbuffer.md) 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](/engine/6000.0/script-reference/unityengine/rendertexture/active.md) and [GraphicsTexture.active](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture/active.md) property. To set a GraphicsTexture as the render target, it must have RenderTarget enabled in [flags](/engine/6000.0/script-reference/unityengine/rendering/graphicstexturedescriptor/flags.md).

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](/engine/6000.0/script-reference/unityengine/gl/srgbwrite.md) as you need it before doing SetRenderTarget or any other manual rendering.

Additional Resources: [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md), [GraphicsTexture](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture.md), [Graphics.activeColorBuffer](/engine/6000.0/script-reference/unityengine/graphics/activecolorbuffer.md), [Graphics.activeDepthBuffer](/engine/6000.0/script-reference/unityengine/graphics/activedepthbuffer.md), [SystemInfo.supportedRenderTargetCount](/engine/6000.0/script-reference/unityengine/systeminfo/supportedrendertargetcount.md).

## SetRenderTarget(RenderBuffer, RenderBuffer, int, CubemapFace, int)

Sets current render target.

```csharp
public static void SetRenderTarget(RenderBuffer colorBuffer, RenderBuffer depthBuffer, int mipLevel, CubemapFace face, int depthSlice)
```

### Parameters

**** (\[RenderBuffer]\(/engine/6000.0/script-reference/unityengine/renderbuffer)): Color buffer to render into.**** (\[RenderBuffer]\(/engine/6000.0/script-reference/unityengine/renderbuffer)): Depth buffer to render into.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Mipmap level to render into (use 0 if not mipmapped).**** (\[CubemapFace]\(/engine/6000.0/script-reference/unityengine/cubemapface)): Cubemap face to render into (use Unknown if not a cubemap).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): Depth slice to render into (use 0 if not a 3D or 2DArray render target).

### Remarks

This function sets which [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md), [GraphicsTexture](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture.md), or a [RenderBuffer](/engine/6000.0/script-reference/unityengine/renderbuffer.md) 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](/engine/6000.0/script-reference/unityengine/rendertexture/active.md) and [GraphicsTexture.active](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture/active.md) property. To set a GraphicsTexture as the render target, it must have RenderTarget enabled in [flags](/engine/6000.0/script-reference/unityengine/rendering/graphicstexturedescriptor/flags.md).

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](/engine/6000.0/script-reference/unityengine/gl/srgbwrite.md) as you need it before doing SetRenderTarget or any other manual rendering.

Additional Resources: [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md), [GraphicsTexture](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture.md), [Graphics.activeColorBuffer](/engine/6000.0/script-reference/unityengine/graphics/activecolorbuffer.md), [Graphics.activeDepthBuffer](/engine/6000.0/script-reference/unityengine/graphics/activedepthbuffer.md), [SystemInfo.supportedRenderTargetCount](/engine/6000.0/script-reference/unityengine/systeminfo/supportedrendertargetcount.md).

## SetRenderTarget(RenderBuffer\[], RenderBuffer)

Sets current render target.

```csharp
public static void SetRenderTarget(RenderBuffer[] colorBuffers, RenderBuffer depthBuffer)
```

### Parameters

**** (\[RenderBuffer\[]]\(/engine/6000.0/script-reference/unityengine/renderbuffer)): Color buffers to render into (for multiple render target effects).**** (\[RenderBuffer]\(/engine/6000.0/script-reference/unityengine/renderbuffer)): Depth buffer to render into.

### Remarks

This function sets which [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md), [GraphicsTexture](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture.md), or a [RenderBuffer](/engine/6000.0/script-reference/unityengine/renderbuffer.md) 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](/engine/6000.0/script-reference/unityengine/rendertexture/active.md) and [GraphicsTexture.active](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture/active.md) property. To set a GraphicsTexture as the render target, it must have RenderTarget enabled in [flags](/engine/6000.0/script-reference/unityengine/rendering/graphicstexturedescriptor/flags.md).

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](/engine/6000.0/script-reference/unityengine/gl/srgbwrite.md) as you need it before doing SetRenderTarget or any other manual rendering.

Additional Resources: [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md), [GraphicsTexture](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture.md), [Graphics.activeColorBuffer](/engine/6000.0/script-reference/unityengine/graphics/activecolorbuffer.md), [Graphics.activeDepthBuffer](/engine/6000.0/script-reference/unityengine/graphics/activedepthbuffer.md), [SystemInfo.supportedRenderTargetCount](/engine/6000.0/script-reference/unityengine/systeminfo/supportedrendertargetcount.md).

## SetRenderTarget(RenderTargetSetup)

Sets current render target.

```csharp
public static void SetRenderTarget(RenderTargetSetup setup)
```

### Parameters

**** (\[RenderTargetSetup]\(/engine/6000.0/script-reference/unityengine/rendertargetsetup)): Full render target setup information.

### Remarks

This function sets which [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md), [GraphicsTexture](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture.md), or a [RenderBuffer](/engine/6000.0/script-reference/unityengine/renderbuffer.md) 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](/engine/6000.0/script-reference/unityengine/rendertexture/active.md) and [GraphicsTexture.active](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture/active.md) property. To set a GraphicsTexture as the render target, it must have RenderTarget enabled in [flags](/engine/6000.0/script-reference/unityengine/rendering/graphicstexturedescriptor/flags.md).

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](/engine/6000.0/script-reference/unityengine/gl/srgbwrite.md) as you need it before doing SetRenderTarget or any other manual rendering.

Additional Resources: [RenderTexture](/engine/6000.0/script-reference/unityengine/rendertexture.md), [GraphicsTexture](/engine/6000.0/script-reference/unityengine/rendering/graphicstexture.md), [Graphics.activeColorBuffer](/engine/6000.0/script-reference/unityengine/graphics/activecolorbuffer.md), [Graphics.activeDepthBuffer](/engine/6000.0/script-reference/unityengine/graphics/activedepthbuffer.md), [SystemInfo.supportedRenderTargetCount](/engine/6000.0/script-reference/unityengine/systeminfo/supportedrendertargetcount.md).
