# zedMat to Unity Render Texture

**URL:** <https://community.stereolabs.com/t/zedmat-to-unity-render-texture/2048>\
**Category:** C#\
**Created:** [January 25, 2023, 10:56am UTC](https://community.stereolabs.com/t/zedmat-to-unity-render-texture/2048 "2023-01-25T10:56:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hyunas1996](https://community.stereolabs.com/user_avatar/community.stereolabs.com/hyunas1996/32/672_2.png) [@hyunas1996](https://community.stereolabs.com/u/hyunas1996)\
**Post date:** [January 25, 2023, 10:56am UTC](https://community.stereolabs.com/t/zedmat-to-unity-render-texture/2048/1 "2023-01-25T10:56:58Z")

</div>

Hi

I’d like to convert zedMat to Unity Render Texture type  
Is there a tutorial for this?

Thank you in advance

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [January 25, 2023, 12:48pm UTC](https://community.stereolabs.com/t/zedmat-to-unity-render-texture/2048/2 "2023-01-25T12:48:55Z")

</div>

Hi,

You can do it like this ;

```auto
Texture2D texture = new Texture2D(mat.GetWidth(), mat.GetHeight(), TextureFormat.RGBA32, false);

texture.LoadRawTextureData(mat.GetPtr(), mat.GetHeight() * mat.GetWidth()* mat.GetChannels());

texture.Apply();

```

Make sure the format of the Texture matches the format of the ZEDMat.

Best,  
Benjamin Vallon

Stereolabs Support

---

<div class="post-metadata">

**Author:** ![hyunas1996](https://community.stereolabs.com/user_avatar/community.stereolabs.com/hyunas1996/32/672_2.png) [@hyunas1996](https://community.stereolabs.com/u/hyunas1996)\
**Post date:** [January 26, 2023, 10:21am UTC](https://community.stereolabs.com/t/zedmat-to-unity-render-texture/2048/3 "2023-01-26T10:21:28Z")

</div>

Thank you so much.  
By the way, what I want to do is get the zed camera frame to the texture 2D.  
So I created zedMat from the camera.

But are there other options that I can do it?

Thank you always!

---

<div class="post-metadata">

**Author:** ![BenjaminV](https://community.stereolabs.com/user_avatar/community.stereolabs.com/benjaminv/32/3863_2.png) [@BenjaminV](https://community.stereolabs.com/u/BenjaminV)\
**Post date:** [January 26, 2023, 10:32am UTC](https://community.stereolabs.com/t/zedmat-to-unity-render-texture/2048/4 "2023-01-26T10:32:05Z")

</div>

The left and right images of the zed are available as a texture here: [https://github.com/stereolabs/zed-unity/blob/master/ZEDCamera/Assets/ZED/SDK/Helpers/Scripts/Display/ZEDRenderingPlane.cs#L110](https://github.com/stereolabs/zed-unity/blob/master/ZEDCamera/Assets/ZED/SDK/Helpers/Scripts/Display/ZEDRenderingPlane.cs#L110) .  
This component is present on the “left eye” and “right eye” game objects, in the ZED\_Rig\_Stereo prefab/.

This texture is getting updated with the new images of the zed automatically.

Stereolabs Support
