# Render Widget to Render Texture 2D with alpha

**URL:** <https://forums.unrealengine.com/t/render-widget-to-render-texture-2d-with-alpha/434878>\
**Category:** UI\
**Tags:** alpha, unreal-engine, render-target, Rendering, Widget, question\
**Created:** [October 2, 2018, 9:24am UTC](https://forums.unrealengine.com/t/render-widget-to-render-texture-2d-with-alpha/434878 "2018-10-02T09:24:53Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dovlahkin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Dovlahkin](https://forums.unrealengine.com/u/Dovlahkin)\
**Post date:** [October 2, 2018, 9:24am UTC](https://forums.unrealengine.com/t/render-widget-to-render-texture-2d-with-alpha/434878/1 "2018-10-02T09:24:53Z")

</div>

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:

 ![255352-capture.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/7/7/777a8b5c179ef6012a39f5e618314e5ef0d3d344.png)

This is how I render the widget in BP:

 ![255353-capture1.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/b/0/0/b00d9a724a3a9b465ae55419306f77f4af7b4a32.png)

This is my widget in editor (just to show you guys that there should be transparency)

![255354-capture2.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/5/6/75651511c88d6aa2ef3fe127c0a148e58c00ba7c.png)

And finally, this is the material I use (you can see on the left what’s the result)

 ![255355-capture3.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/f/f/effecc6279fdedf0b99a071333b124ae3ed4fd05.jpeg)

Any thoughts?

---

<div class="post-metadata">

**Author:** ![Sam54123](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Sam54123](https://forums.unrealengine.com/u/Sam54123)\
**Post date:** [December 17, 2018, 12:31am UTC](https://forums.unrealengine.com/t/render-widget-to-render-texture-2d-with-alpha/434878/2 "2018-12-17T00:31:01Z")

</div>

Did you ever figure this out?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_195613a7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_195613a7](https://forums.unrealengine.com/u/anonymous_user_195613a7)\
**Post date:** [February 26, 2019, 9:59am UTC](https://forums.unrealengine.com/t/render-widget-to-render-texture-2d-with-alpha/434878/3 "2019-02-26T09:59:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![xyf2016](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@xyf2016](https://forums.unrealengine.com/u/xyf2016)\
**Post date:** [March 20, 2019, 7:05am UTC](https://forums.unrealengine.com/t/render-widget-to-render-texture-2d-with-alpha/434878/4 "2019-03-20T07:05:32Z")

</div>

Try Set ClearColor’s Alpha to 0 in RenderTarget

---

<div class="post-metadata">

**Author:** ![wsdxyhh](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@wsdxyhh](https://forums.unrealengine.com/u/wsdxyhh)\
**Post date:** [April 25, 2022, 9:50am UTC](https://forums.unrealengine.com/t/render-widget-to-render-texture-2d-with-alpha/434878/5 "2022-04-25T09:50:54Z")

</div>

thank you

---

<div class="post-metadata">

**Author:** ![Caliber\_1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Caliber\_1](https://forums.unrealengine.com/u/Caliber_1)\
**Post date:** [March 15, 2024, 4:17pm UTC](https://forums.unrealengine.com/t/render-widget-to-render-texture-2d-with-alpha/434878/6 "2024-03-15T16:17:55Z")

</div>

What did the header (.h) end up looking like for this?
