Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Why does my Dynamic 2D Texture Show Up Blank?

I've been trying to load up a dynamically created texture on a custom actor created as a plugin. Currently I can create a cube, load up my custom material and it shows up in the editor and game. If I then load up a 2D texture created dynamically (filled with noise so it is obvious it is being used) and set it on my material'a texture property it gets set but shows up as a blank grey or off-white. I'm using the method from the wiki to create and update the texture: https://wiki.unrealengine.com/Dynamic_Textures

Below is the relevant portion of the header:

 UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = StaticMeshComponents) TSubobjectPtr<UStaticMeshComponent> schwein;
 UPROPERTY(EditDefaultsOnly, Category = Materials) UMaterialInterface *MasterMaterialRef;
 UPROPERTY() UTexture2D *DynamicTexture;
 UPROPERTY() UMaterialInstanceDynamic* RV_MatInst;

Below is the relevant portion of the actor implementation:

 // create cube
 schwein = PCIP.CreateDefaultSubobject<UStaticMeshComponent>(this, TEXT("schwein"));
 // load material
 static ConstructorHelpers::FObjectFinder<UStaticMesh>StaticMesh(TEXT("StaticMesh'/Game/Shapes/Shape_Cube.Shape_Cube'"));
 static ConstructorHelpers::FObjectFinder<UMaterial> goldMaterial(TEXT("Material'/Game/Ibex/DesktopMaterial'"));
 // create my custom material
 MasterMaterialRef = goldMaterial.Object;
 RootComponent = schwein;
 // create random noise for texture
 const int SizeX = 1024;
 const int SizeY = 1024;
 static uint8 data[SizeX * SizeY * 4] = { 0 };
 for (int i = 0; i < SizeX * SizeY * 4; ++i) {
     data[i] = rand() % 255;
 // create dynamic texture
 DynamicTexture = UTexture2D::CreateTransient(SizeX, SizeY);
 // update dynamic texture
 FUpdateTextureRegion2D r(0, 0, 0, 0, SizeX, SizeY);
 UpdateTextureRegions(DynamicTexture, (int32)0, (uint32)1, &r, (uint32)(4 * SizeX), (uint32)4, data, false); // Using the UpdateTextureRegions from https://wiki.unrealengine.com/Dynamic_Textures
 // update texture property on material and set object to use material
 RV_MatInst->SetTextureParameterValue(FName("T2DTexture"), DynamicTexture);
 schwein->SetMaterial(0, RV_MatInst);

Product Version: Not Selected
more ▼

asked Jun 12 '14 at 02:06 PM in C++ Programming

avatar image

187 11 21 171

avatar image druidsbane Jun 12 '14 at 11:37 PM

Interestingly enough it works now! I had code inside my actor's tick class that got called once to initialize the texture with


If I just run the function on each update it works which means that the world wasn't initialized on the first tick. Is there a recommended way of checking to know when one can start creating and updating textures?

avatar image tkchen Jul 13 '14 at 09:14 PM

I'm having the same problem. Can you provide a bit more detail about how you were able to solve this? TIA.

Are you saying you called: https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UTexture2D/UpdateTextureRegions/index.html

In your tick function? Or are you saying you called the function defined in: https://wiki.unrealengine.com/Dynamic_Textures

avatar image GerardD Jul 21 '14 at 04:29 AM

I have been working with this Dynamic Textures function. I made a slight modification to the code to ensure that the texture is ready to use:

 if (Texture && Texture->Resource)


 if (Texture->Resource)

I found this removes some of the instability and ensures that the update function is only doing work when there is a texture to work upon

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question