- Home /
Reading texture2D without artifacts
Hi, I am using a plugin to write a front cam data of iOS Devices on to a unity texture2D and rendering it in realtime via a plane with material. But on reading the data the output seems to have artifacts. It looks like it is outputting the 3 RGB channels in a squashed side by side interlaced format. Below is the plugin write code. Any help to fix this will be helpful.
void _BindTexture(int textureHandle) {
int width = [engine getFrameWidth], height = [engine getFrameHeight];
uint8_t* tempPixels = [engine getFrame];
uint8_t* pixels = (uint8_t*) malloc( (int)(width * height * 3 ));
for(int i = 0; i < width * height; i++)
{
int temp = *(tempPixels + i);
pixels[i * 3 + 0] = temp;
pixels[i * 3 + 1] = temp;
pixels[i * 3 + 2] = temp;
}
glBindTexture(GL_TEXTURE_2D, textureHandle);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels);
free(pixels);
free(tempPixels);
}
Thank you
Your answer
![](https://koobas.hobune.stream/wayback/20220613160336im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Create Texture2D and assign image to it through a script 1 Answer
Two flat textures interfere with each other when both on z=0 2 Answers
How do you create animated textures with Texture2D.Apply with any regularity? 1 Answer
Reloading texture2d from code 1 Answer
Unlit/Transparent texture leaves dark lines on the transparent edges 1 Answer