Hi,
I’m having trouble creating / applying a dynamic texture at runtime.
This is my test code:
_width = 2;
_height = 2;
uint8 pixels] = {
255, 0, 0, 255,
0, 0, 255, 255,
255, 0, 0, 255,
0, 0, 255, 255
};
_texture = UTexture2D::CreateTransient(_width, _height, PF_R8G8B8A8);
FTexture2DMipMap& mip = _texture->PlatformData->Mips[0];
void* mipdata = mip.BulkData.Lock(LOCK_READ_WRITE);
FMemory::Memcpy(mipdata, pixels, _width * _height * sizeof(uint8) * 4);
mip.BulkData.Unlock();
_texture->UpdateResource();
In this test, I am creating a 2x2 texture and manually specifying 4 RGBA pixels, alternating the colors between red and blue.
I have a simple cube in the scene with 0-1 uv layout on all sides.
I would expect to see a checkered coloured cube. I get cube with just the first pixel’s (or maybe a mix), color, quite a weak color.
I do believe the above code is having an effect. In our “real” case I am sending over quite large amounts of image data, 1024x1024 etc, and still just getting a single color (though again, different textures do produce differing results).
Am I to assume it is the way the shader is set up in Unreal (this I have no experience of)?
It’s the baseImage i am setting the texture on.
Any help/advice much appreciated!