-
For a synchronized update, this can be used:
TArray<FColor> ColorData; // Init Data // Create texture if it doesn't exist FTexture2DMipMap& Mip = Texture->PlatformData->Mips[0]; void* TextureData = Mip.BulkData.Lock( LOCK_READ_WRITE ); FMemory::Memcpy( TextureData, ColorData.GetData(), (X * Y * sizeof(FColor))); // can just loop through values as well Mip.BulkData.Unlock( ); Texture->UpdateResource();
By David Gilbert on 2020-07-02T09:24:04 (imported from GitLab)
Edited by Jan Delember -
Yeah. The code I ended up with in the end is based on the usage I found in the engine itself - pretty sure it could be improved:
FUpdateTextureRegion2D* Region = new FUpdateTextureRegion2D( InitialTextureMarker.X, InitialTextureMarker.Y, InitialTextureMarker.X, InitialTextureMarker.Y, Line.Num(), 1); // Copy for now - no need to do that generally TArray<FVector4>* TextureData = new TArray<FVector4>(RawLineData); // Moving the raw arraw data instead of a copy is a lot quicker, if your data structure allows that: TArray<FVector4>* TextureData = new TArray<FVector4>(MoveTemp(RawLineData)); PositionTexture->UpdateTextureRegions(0, 1, Region, TextureWidth * sizeof(FVector4), sizeof(FVector4), (uint8*)TextureData->GetData(), [](auto InTextureData, auto InRegions) { delete InTextureData; delete InRegions; });
By David Gilbert on 2020-07-02T09:54:17 (imported from GitLab)
Please register or sign in to comment