Hi, I’m trying to create a dynamic texture with the pixel format PF_R8_UINT in C++, and then use that in as a texture object parameter through a dynamic material. Below is a tiny code snippet where I create the texture:
int Width = 2592;
int Height = 1936;
m_Texture = UTexture2D::CreateTransient(Width, Height, PF_R8_UINT);
m_Texture->UpdateResource();
And this is a snapshot of a material blueprint I’m starting out with:
Executing the program, however, often results in an error message that says my types aren’t configured correctly:
failed assertion `MTLPixelFormat of texture [Texture2D_0 (MTLPixelFormatR8Uint)] bound at index 0 is incompatible with texture parameter [MTLDataTypeFloat ps0[0]]. MTLPixelFormatR8Uint is compatible with texture data types type(s) (
uint,
ushort
).'
Changing PF_R8_UINT to something like PF_R32_FLOAT works, though I’d rather not take that route.
Anyone else have success creating an dynamic texture of 8bit uints or chars?
Any insight is greatly appreciated! Thanks!