x

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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Render Text on texture

Hi!

I need to render a texture with some text added dynamically. Once I have this I must render the result on geometry but I can't find the way. I tried to use some Text Render Components but they have a bad performance and drop down my fps.

Thanks!

Product Version: UE 4.10
Tags:
more ▼

asked Nov 13 '15 at 08:04 AM in Rendering

avatar image

jsole_blit
13 3 4 7

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

2 answers: sort voted first

I'd have just dropped a CPP/H file I have but the cpp file got blocked. Fairly simple though in essence.

You'll need a render target:

 UTextureRenderTarget2D* RenderTexture = 0

Which needs to be created in one of your constructors

 UTextTexture::UTextTexture(const class FObjectInitializer& PCIP)
     : Super(PCIP)
 {
     RenderTexture = PCIP.CreateDefaultSubobject<UTextureRenderTarget2D>(this, TEXT("RenderTexture"));

It will need to be setup with a height and width

         RenderTexture->ClearColor = FLinearColor::Black;
         RenderTexture->InitAutoFormat(iWidth, iHeight);
         RenderTexture->UpdateResourceImmediate();

And then you can draw to it

     FCanvasTextItem txtItem(FVector2D(0.0f, 0.0f), txt, &rFontToUse, FLinearColor::Black);


     FCanvas Canvas(RenderTexture->GameThread_GetRenderTargetResource(), NULL, 0.0f, 0.0f, 0.0f, GMaxRHIFeatureLevel);    //UE4.5 GMaxRHIFeatureLevelValue);
     Canvas.Clear(FLinearColor::White);
     Canvas.DrawItem(txtItem, FVector2D(kMarginX, kMarginY));
     Canvas.Flush_GameThread(true);








more ▼

answered Nov 14 '15 at 02:43 AM

avatar image

theonecalledtom
1.3k 60 65 269

avatar image jsole_blit Nov 16 '15 at 10:10 AM

Thanks! It works!

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

I do this in c++ - if this is usefully you i can paste the code here.

more ▼

answered Nov 13 '15 at 07:22 PM

avatar image

theonecalledtom
1.3k 60 65 269

avatar image JesusS Nov 13 '15 at 07:42 PM

I will be very greatfull! Thanks!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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