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"

Render Widget to Render Texture 2D with alpha

Hi again!

I was able to make a c++ class that renders a widget to a render target texture by using WidgetRenderer->DrawWidget method. However, the issue is that the final result of rendering doesn't include transparency, and that transparency was the whole point of what I was trying to do... Here's the code:

 void APlayerPawnBase::RenderWidgetToTexture(UUserWidget *const Widget, FVector2D const &DrawSize, float DeltaTime)
 {
     if (!IsValid(widgetRenderTargetTexture))
     {
         return;
     }
     if (!IsValid(Widget))
     {
         return;
     }
     if (DrawSize == FVector2D(0, 0))
     {
         return;
     }
 
     TSharedRef<SWidget> ref = Widget->TakeWidget();
 
     WidgetRenderer->DrawWidget(widgetRenderTargetTexture, ref, DrawSize, DeltaTime);
 }

I tried clearing render texture before rendering widgets with a clear color, and as long as I don't draw widget over it it has alpha, but after rendering widget, alpha goes away. This is my RT setup: alt text This is how I render the widget in BP: alt text This is my widget in editor (just to show you guys that there should be transparency) alt text And finally, this is the material I use (you can see on the left what's the result) alt text

Any thoughts?

Product Version: UE 4.20
Tags:
capture.png (41.6 kB)
capture1.png (111.0 kB)
capture2.png (11.4 kB)
capture3.png (466.0 kB)
more ▼

asked Oct 02 '18 at 09:24 AM in C++ Programming

avatar image

Dovlahkin
78 2 6 10

avatar image Sam54123 Dec 17 '18 at 12:31 AM

Did you ever figure this out?

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

2 answers: sort voted first

Just set the background of the widget to be a color that's not in use and then mask that same color in the material editor.

more ▼

answered Feb 26 '19 at 09:59 AM

avatar image

lewisscrivs
26 1 2 6

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

Try Set ClearColor's Alpha to 0 in RenderTarget

more ▼

answered Mar 20 '19 at 07:05 AM

avatar image

xyf2016
1

(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