Issues with creating textures dynamically

I am attempting to generate textures at runtime, and assign them to a SpriteComponent. the textures themselves are being correctly generated, but when the sprites render in game, it appears that they only sample the pixel at (0,0) and spread it across the whole area of the sprite. I think I am missing something during either the initialization of the texture, or the sprite.

here’s how I initialize the texture:
void ABloodSplatter::InitSplatter() {
int32 Width = 32;
int32 Height = 32;

splatter_texture = UTexture2D::CreateTransient(Width, Height, PF_B8G8R8A8);
splatter_texture->PostLoad();

// Ensure no compression and proper settings
splatter_texture->MipGenSettings = TMGS_NoMipmaps;
splatter_texture->CompressionSettings = TC_VectorDisplacementmap;
splatter_texture->SRGB = false;
splatter_texture->Filter = TF_Nearest;

splatter_texture->AddToRoot();
splatter_texture->UpdateResource();

// Lock the texture to be able to modify it
FTexture2DMipMap& Mip = splatter_texture->GetPlatformData()->Mips[0];
void* Data = Mip.BulkData.Lock(LOCK_READ_WRITE);

// Initialize the texture data

FMemory::Memset(Data, 0, Mip.BulkData.GetBulkDataSize());

// Unlock the texture
Mip.BulkData.Unlock();
splatter_texture->UpdateResource();

}

here is how I initialize the sprite and assign the texture:

void ABloodSplatter::PlaceSplatter() {

// Create a new sprite
FSpriteAssetInitParameters params = FSpriteAssetInitParameters();



params.SetTextureAndFill(splatter_texture);
params.Dimension[0] = 32;
params.Dimension[1] = 32;
params.SetPixelsPerUnrealUnit(1);


UPaperSprite* NewSprite = NewObject<UPaperSprite>();



NewSprite->SetPivotMode(ESpritePivotMode::Center_Center, {0,0});

NewSprite->RebuildRenderData();


NewSprite->InitializeSprite(params);

SpriteComponent->SetSprite(NewSprite);
//SpriteComponent->UpdateBounds();


SpriteComponent->MarkPackageDirty();

}

Solved!! the problem was that CreateTransient does not get initialized with a source, therefore the source dimensions which are used later to set the sprite UV are read as {0,0}. the solution was to initialize the “source image” manually in the code, by calling this line after CreateTransient:

my_transient_texture->Source.Init(Width, Height, 1, 0, ETextureSourceFormat::TSF_BGRA8);

I am almost positive this is not the intended fix, but it does work!