How to dynamically create many textures from RenderTarget2D

Hello.

I have a default material with two texture parameters (which is used to create a Dynamic Material Instance).

I need to create two textures, from differents USceneCaptureComponent2D, and blend them together in my dynamic material instance. Each of these capture components have an associated TextRenderComponent.

What I believe is needed to be done:

  • Set the text into the TextRenderComponent
  • Wait a frame (one) for the geometry to be built by the engine
  • Create the textures
  • Copy the color data from the USceneCaptureComponent2D into the created textures
  • Assign the created textures as texture parameters into the Material Instance Dynamic.

To wait the frames I’m using a Tick event callback. I could achieve the creation of many actors with different texts as their textures using one USceneCaptureComponent2D. When I added the second one, the game just turns all the “text textures” into the same one.

I have certified myself that I’m using a different material instance for each actor.

Am I missing something? Should I use another method?

Background for the project:
I’m creating an online card game that contains many cards with different texts on it. My project already has a server implemented and all the card information is on a SQL Database.

Hello,

Solved my issue. Still don’t know exactly how the render pipeline works with said components in my question, but I can provide the required steps necessary to achieve the texture generation with USceneCaptureComponent2D:

  • Make sure the texture parameters in the material are being found with the correct name (With this method)
  • You do have to wait between frame renders after generating text geometry and flushing the scene capture component data into a texture. This is the part where I don’t know much about, but my code worked having the geometry, each texture and material parameter assignment working in different ticks with a “dummy” tick between them.
  • Do not capture every frame with the Scene Capture Component. I set this member to false in my blueprint and passed it as an argument to my initializer methods (I use two Scene Capture Components, as I blend two textures in different ways in a material), so I could invoke them later in C++.
  • Used this code to capture my render target data into a texture.
  • Used this method for both scene capture components after text geometry generation and before flushing the render target content into the texture (only for the appropriate scene capture component).

There is a significant fps drop while rendering the textures, but this is a problem for another question.