Hi everybody, I capture a scene with OpenCV and I want to write pixel value of captured image to UTexture2D but I can’t I already setup a material which has a texture parameter and I also created an instance Material of that then I create a C++ class but when I trying to change pixel value it does not work properly it’s change just top part of mesh, and I already read Ginku’s wiki but I don’t understant that it’s to messy, here is my function code.
void ADynamicTexture::capture()
{
cv::Mat img = cv::imread("D:\\img.jpg");
UTexture2D *ut2 = UTexture2D::CreateTransient(img.size().width, img.size().height);
ut2->CompressionSettings = TextureCompressionSettings::TC_VectorDisplacementmap;
ut2->SRGB = 0;
ut2->AddToRoot();
ut2->UpdateResource();
FTexture2DMipMap &mip = ut2->PlatformData->Mips[0];
void *data = mip.BulkData.Lock(LOCK_READ_WRITE);
FMemory::Memcpy(data, img.data, img.size().width * img.size().height);
mip.BulkData.Unlock();
ut2->UpdateResource();
matInst->SetTextureParameterValue(FName("DTexture"), ut2);
mesh->SetMaterial(0, matInst);
}