Okay, I’ll run you over what I can tell just by looking at that section.
All of the code in that section is run within an overriden PostInitializeComponents from a class derived from AActor.
UTexture2D::CreateTrasient(int32 InSizeX, int32 InSizeY, EPixelFormat InFormat) returns a pointer to a empty UTexture2D.
mDynamicTexture is a pointer member variable in which they’re storing the empty texture into.
The “CompressionSettings” is a public variable which they’re setting to TC_VectorDisplacementMap to disable compression.
The “SRGB” is a public variable they’re setting to 0 to disable gamma correction which skews data.
The “AddToRoot” function is called to make the texture a root object and prevents it from being GCed.
The textureToReadFrom variable seems to be a pointer to the texture they created at the start of the article. I don not know how they’re supplying the value to the function, but I assume it is a pointer member variable.
The “GetSizeX” and GetSizeY" functions are really self explanatory.
“FTexture2DMipMap& readMip = textureToReadFrom->PlatformData->Mips” This seems a little confusing, but all they’re doing is referencing the first mipmap inside of the texture.
mDataSize and mDataSqrtSize are used by UpdateTextureRegions.
However, it openly assumes that width and height are equal and powers of 2.
mDataSize is a member variable of type int32 (should probably be uint32) which they’re calculating from the width * height * 4 of the textureToReadFrom.
mDataSqrtSize is another member variable of type int32 (should probably be uin32), but its formula is wrong. It should be (width * 4) / 2 to actually be the square root.
Now, the “readMip.BulkData.GetCopy((void**)&mTextureColors)” has a lot of terrible dark magic, but all it does is copy the mip map’s data to a member variable called mTextureColors.
mTextureColors has to be an array and it is probably an array of uint8 since mDynamicColors is.
mTextureColors is probably set through more dark magic in the actor’s constructor.
mDynamicColors IS an array of uint8 which is equal to mDataSize.
FMemory::Memcpy(mDynamicColors, mTextureColors, mDataSize) copies all of the color information in mTextureColors to mDynamicColors. So, mTextureColors definitely has to be an uint8 array.
mUpdateTextureRegion is a pointer member variable which contains the update region of the texture.
Last, but not least, the "mDynamicMaterials->SetTextureParamaterValue(“DynamicTextureParam”, mDynamicTexture) updates the material’s “DynamicTextureParam” to the newly generated dynamic texture.