# CopyTexture

> Adds a command to copy pixel data from one texture to another.

## Definition

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

## CopyTexture(RenderTargetIdentifier, RenderTargetIdentifier)

Adds a command to copy pixel data from one texture to another.

```csharp
public void CopyTexture(RenderTargetIdentifier src, RenderTargetIdentifier dst)
```

### Parameters

**** (\[RenderTargetIdentifier]\(/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier)): The source texture or [RenderTargetIdentifier](/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier.md).**** (\[RenderTargetIdentifier]\(/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier)): The destination texture or [RenderTargetIdentifier](/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier.md).

### Remarks

This method adds a command to copy pixel data from one texture to another on the GPU. If you set [Texture.isReadable](/engine/6000.0/script-reference/unityengine/texture/isreadable.md) to `true` for both `src` and `dst` textures, the method also copies pixel data on the CPU.

If you set [Texture.isReadable](/engine/6000.0/script-reference/unityengine/texture/isreadable.md) to `false`, `CopyTexture` is one of the fastest ways to copy a texture. But to use `CopyTexture`, the following must be the same in both the source and destination texture areas:

* Format. You can also use two compatible formats - for example, [TextureFormat.ARGB32](/engine/6000.0/script-reference/unityengine/textureformat/argb32.md) and [RenderTextureFormat.ARGB32](/engine/6000.0/script-reference/unityengine/rendertextureformat/argb32.md).
* Size.
* [RenderTexture.antiAliasing](/engine/6000.0/script-reference/unityengine/rendertexture/antialiasing.md) values, if the textures are render textures.

You might be able to copy between incompatible formats depending on your graphics API. For example, on some APIs you can copy between formats with the same bit width.

Depending on your graphics API, you might not be able to copy between different types of textures. For more information on compatibility, see [SystemInfo.copyTextureSupport](/engine/6000.0/script-reference/unityengine/systeminfo/copytexturesupport.md) and [CopyTextureSupport](/engine/6000.0/script-reference/unityengine/rendering/copytexturesupport.md).

If `src` is a depth-only render texture, you must copy the whole texture, not part of it. A depth-only render texture has its color buffer set to a [color format](/engine/6000.0/script-reference/unityengine/rendertexture/graphicsformat.md) of `None` and its depth buffer set to a valid [RenderTexture.depthStencilFormat](/engine/6000.0/script-reference/unityengine/rendertexture/depthstencilformat.md).

Compressed texture formats add some restrictions to the CopyTexture with a region variant. For example, PVRTC formats are not supported since they are not block-based (for these formats you can only copy whole texture or whole mipmap level). For block-based formats (for instance, DXT, ETC), the region size and coordinates must be a multiple of compression block size (4 pixels for DXT).

Even if you set `Texture.isReadable` to true, this method doesn't copy pixel data on the CPU if you copy only a region of a compressed texture.

Additional Resources: [Graphics.CopyTexture](/engine/6000.0/script-reference/unityengine/graphics/copytexture.md), [CopyTextureSupport](/engine/6000.0/script-reference/unityengine/rendering/copytexturesupport.md).

## CopyTexture(RenderTargetIdentifier, int, RenderTargetIdentifier, int)

Adds a command to copy pixel data from one texture to another.

```csharp
public void CopyTexture(RenderTargetIdentifier src, int srcElement, RenderTargetIdentifier dst, int dstElement)
```

### Parameters

**** (\[RenderTargetIdentifier]\(/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier)): The source texture or [RenderTargetIdentifier](/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier.md).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The element in the source texture to copy from. For example, the [CubemapFace](/engine/6000.0/script-reference/unityengine/cubemapface.md) in a Cubemap or the slice in a texture array. Set the value to `0` if `src` is a 2D texture.**** (\[RenderTargetIdentifier]\(/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier)): The destination texture or [RenderTargetIdentifier](/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier.md).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The element in the source texture to copy to. For example, the [CubemapFace](/engine/6000.0/script-reference/unityengine/cubemapface.md) in a Cubemap or the slice in a texture array. Set the value to `0` if `dst` is a 2D texture.

### Remarks

This method adds a command to copy pixel data from one texture to another on the GPU. If you set [Texture.isReadable](/engine/6000.0/script-reference/unityengine/texture/isreadable.md) to `true` for both `src` and `dst` textures, the method also copies pixel data on the CPU.

If you set [Texture.isReadable](/engine/6000.0/script-reference/unityengine/texture/isreadable.md) to `false`, `CopyTexture` is one of the fastest ways to copy a texture. But to use `CopyTexture`, the following must be the same in both the source and destination texture areas:

* Format. You can also use two compatible formats - for example, [TextureFormat.ARGB32](/engine/6000.0/script-reference/unityengine/textureformat/argb32.md) and [RenderTextureFormat.ARGB32](/engine/6000.0/script-reference/unityengine/rendertextureformat/argb32.md).
* Size.
* [RenderTexture.antiAliasing](/engine/6000.0/script-reference/unityengine/rendertexture/antialiasing.md) values, if the textures are render textures.

You might be able to copy between incompatible formats depending on your graphics API. For example, on some APIs you can copy between formats with the same bit width.

Depending on your graphics API, you might not be able to copy between different types of textures. For more information on compatibility, see [SystemInfo.copyTextureSupport](/engine/6000.0/script-reference/unityengine/systeminfo/copytexturesupport.md) and [CopyTextureSupport](/engine/6000.0/script-reference/unityengine/rendering/copytexturesupport.md).

If `src` is a depth-only render texture, you must copy the whole texture, not part of it. A depth-only render texture has its color buffer set to a [color format](/engine/6000.0/script-reference/unityengine/rendertexture/graphicsformat.md) of `None` and its depth buffer set to a valid [RenderTexture.depthStencilFormat](/engine/6000.0/script-reference/unityengine/rendertexture/depthstencilformat.md).

Compressed texture formats add some restrictions to the CopyTexture with a region variant. For example, PVRTC formats are not supported since they are not block-based (for these formats you can only copy whole texture or whole mipmap level). For block-based formats (for instance, DXT, ETC), the region size and coordinates must be a multiple of compression block size (4 pixels for DXT).

Even if you set `Texture.isReadable` to true, this method doesn't copy pixel data on the CPU if you copy only a region of a compressed texture.

Additional Resources: [Graphics.CopyTexture](/engine/6000.0/script-reference/unityengine/graphics/copytexture.md), [CopyTextureSupport](/engine/6000.0/script-reference/unityengine/rendering/copytexturesupport.md).

## CopyTexture(RenderTargetIdentifier, int, int, RenderTargetIdentifier, int, int)

Adds a command to copy pixel data from one texture to another.

```csharp
public void CopyTexture(RenderTargetIdentifier src, int srcElement, int srcMip, RenderTargetIdentifier dst, int dstElement, int dstMip)
```

### Parameters

**** (\[RenderTargetIdentifier]\(/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier)): The source texture or [RenderTargetIdentifier](/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier.md).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The element in the source texture to copy from. For example, the [CubemapFace](/engine/6000.0/script-reference/unityengine/cubemapface.md) in a Cubemap or the slice in a texture array. Set the value to `0` if `src` is a 2D texture.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The mipmap level to copy from. The range is `0` through the texture's [Texture.mipmapCount](/engine/6000.0/script-reference/unityengine/texture/mipmapcount.md). The default value is `0`.**** (\[RenderTargetIdentifier]\(/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier)): The destination texture or [RenderTargetIdentifier](/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier.md).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The element in the source texture to copy to. For example, the [CubemapFace](/engine/6000.0/script-reference/unityengine/cubemapface.md) in a Cubemap or the slice in a texture array. Set the value to `0` if `dst` is a 2D texture.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The mipmap level to write to. The range is `0` through the texture's [Texture.mipmapCount](/engine/6000.0/script-reference/unityengine/texture/mipmapcount.md). The default value is `0`.

### Remarks

This method adds a command to copy pixel data from one texture to another on the GPU. If you set [Texture.isReadable](/engine/6000.0/script-reference/unityengine/texture/isreadable.md) to `true` for both `src` and `dst` textures, the method also copies pixel data on the CPU.

If you set [Texture.isReadable](/engine/6000.0/script-reference/unityengine/texture/isreadable.md) to `false`, `CopyTexture` is one of the fastest ways to copy a texture. But to use `CopyTexture`, the following must be the same in both the source and destination texture areas:

* Format. You can also use two compatible formats - for example, [TextureFormat.ARGB32](/engine/6000.0/script-reference/unityengine/textureformat/argb32.md) and [RenderTextureFormat.ARGB32](/engine/6000.0/script-reference/unityengine/rendertextureformat/argb32.md).
* Size.
* [RenderTexture.antiAliasing](/engine/6000.0/script-reference/unityengine/rendertexture/antialiasing.md) values, if the textures are render textures.

You might be able to copy between incompatible formats depending on your graphics API. For example, on some APIs you can copy between formats with the same bit width.

Depending on your graphics API, you might not be able to copy between different types of textures. For more information on compatibility, see [SystemInfo.copyTextureSupport](/engine/6000.0/script-reference/unityengine/systeminfo/copytexturesupport.md) and [CopyTextureSupport](/engine/6000.0/script-reference/unityengine/rendering/copytexturesupport.md).

If `src` is a depth-only render texture, you must copy the whole texture, not part of it. A depth-only render texture has its color buffer set to a [color format](/engine/6000.0/script-reference/unityengine/rendertexture/graphicsformat.md) of `None` and its depth buffer set to a valid [RenderTexture.depthStencilFormat](/engine/6000.0/script-reference/unityengine/rendertexture/depthstencilformat.md).

Compressed texture formats add some restrictions to the CopyTexture with a region variant. For example, PVRTC formats are not supported since they are not block-based (for these formats you can only copy whole texture or whole mipmap level). For block-based formats (for instance, DXT, ETC), the region size and coordinates must be a multiple of compression block size (4 pixels for DXT).

Even if you set `Texture.isReadable` to true, this method doesn't copy pixel data on the CPU if you copy only a region of a compressed texture.

Additional Resources: [Graphics.CopyTexture](/engine/6000.0/script-reference/unityengine/graphics/copytexture.md), [CopyTextureSupport](/engine/6000.0/script-reference/unityengine/rendering/copytexturesupport.md).

## CopyTexture(RenderTargetIdentifier, int, int, int, int, int, int, RenderTargetIdentifier, int, int, int, int)

Adds a command to copy pixel data from one texture to another.

```csharp
public void CopyTexture(RenderTargetIdentifier src, int srcElement, int srcMip, int srcX, int srcY, int srcWidth, int srcHeight, RenderTargetIdentifier dst, int dstElement, int dstMip, int dstX, int dstY)
```

### Parameters

**** (\[RenderTargetIdentifier]\(/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier)): The source texture or [RenderTargetIdentifier](/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier.md).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The element in the source texture to copy from. For example, the [CubemapFace](/engine/6000.0/script-reference/unityengine/cubemapface.md) in a Cubemap or the slice in a texture array. Set the value to `0` if `src` is a 2D texture.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The mipmap level to copy from. The range is `0` through the texture's [Texture.mipmapCount](/engine/6000.0/script-reference/unityengine/texture/mipmapcount.md). The default value is `0`.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The starting x coordinate of `src` to copy from. `0` is the left of the texture.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The starting y coordinate of `src` to copy from. `0` is the bottom of the texture.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The width of `src` to copy.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The height of `src` to copy.**** (\[RenderTargetIdentifier]\(/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier)): The destination texture or [RenderTargetIdentifier](/engine/6000.0/script-reference/unityengine/rendering/rendertargetidentifier.md).**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The element in the source texture to copy to. For example, the [CubemapFace](/engine/6000.0/script-reference/unityengine/cubemapface.md) in a Cubemap or the slice in a texture array. Set the value to `0` if `dst` is a 2D texture.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The mipmap level to write to. The range is `0` through the texture's [Texture.mipmapCount](/engine/6000.0/script-reference/unityengine/texture/mipmapcount.md). The default value is `0`.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The x coordinate of `dst` to copy to.**** (\[int]\(https\://learn.microsoft.com/dotnet/api/system.int32)): The y coordinate to `dst` to copy to.

### Remarks

This method adds a command to copy pixel data from one texture to another on the GPU. If you set [Texture.isReadable](/engine/6000.0/script-reference/unityengine/texture/isreadable.md) to `true` for both `src` and `dst` textures, the method also copies pixel data on the CPU.

If you set [Texture.isReadable](/engine/6000.0/script-reference/unityengine/texture/isreadable.md) to `false`, `CopyTexture` is one of the fastest ways to copy a texture. But to use `CopyTexture`, the following must be the same in both the source and destination texture areas:

* Format. You can also use two compatible formats - for example, [TextureFormat.ARGB32](/engine/6000.0/script-reference/unityengine/textureformat/argb32.md) and [RenderTextureFormat.ARGB32](/engine/6000.0/script-reference/unityengine/rendertextureformat/argb32.md).
* Size.
* [RenderTexture.antiAliasing](/engine/6000.0/script-reference/unityengine/rendertexture/antialiasing.md) values, if the textures are render textures.

You might be able to copy between incompatible formats depending on your graphics API. For example, on some APIs you can copy between formats with the same bit width.

Depending on your graphics API, you might not be able to copy between different types of textures. For more information on compatibility, see [SystemInfo.copyTextureSupport](/engine/6000.0/script-reference/unityengine/systeminfo/copytexturesupport.md) and [CopyTextureSupport](/engine/6000.0/script-reference/unityengine/rendering/copytexturesupport.md).

If `src` is a depth-only render texture, you must copy the whole texture, not part of it. A depth-only render texture has its color buffer set to a [color format](/engine/6000.0/script-reference/unityengine/rendertexture/graphicsformat.md) of `None` and its depth buffer set to a valid [RenderTexture.depthStencilFormat](/engine/6000.0/script-reference/unityengine/rendertexture/depthstencilformat.md).

Compressed texture formats add some restrictions to the CopyTexture with a region variant. For example, PVRTC formats are not supported since they are not block-based (for these formats you can only copy whole texture or whole mipmap level). For block-based formats (for instance, DXT, ETC), the region size and coordinates must be a multiple of compression block size (4 pixels for DXT).

Even if you set `Texture.isReadable` to true, this method doesn't copy pixel data on the CPU if you copy only a region of a compressed texture.

Additional Resources: [Graphics.CopyTexture](/engine/6000.0/script-reference/unityengine/graphics/copytexture.md), [CopyTextureSupport](/engine/6000.0/script-reference/unityengine/rendering/copytexturesupport.md).
