A quick way to set an array of bytes to a texture2d unit

In unity 3D, I get the image from the camera (color camera device) as an array of bytes from the plugin, and I want to display the image in real time on the screen.

If I use Texture2D.SetPixels32 to create a texture, it drastically reduces fps (from 80 to 10).

 //First convert byte[] to color[] colorr = GetColor(imageBuffer); imageColor.SetPixels32(colorr); imageColor.Apply(); // fps reduced here 

I think I need to do this with a shader on the GPU.

So what is the solution to make it faster? If the answer uses a shader, it can give a sample.

thanks.

+6
source share
2 answers

I did this using openGL. Just write a plugin for unity and get Texture2D NativeID from one and send it to the plugin then use openGL to set bytes to the texture! That was awesome! FPS increased from 10 to 50 !!! you also need to know that you need to run games in OpenGL mode using "-force-opengl" to use opengl functions.

+5
source
0
source

All Articles