# Transparency in Render Target 2D shows up black

**URL:** <https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466>\
**Category:** Rendering\
**Tags:** rendertarget, stereo-layers, unreal-engine, transparency, Rendering, question\
**Created:** [January 10, 2017, 6:36pm UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466 "2017-01-10T18:36:31Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_fdd9bf78](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_fdd9bf78](https://forums.unrealengine.com/u/anonymous_user_fdd9bf78)\
**Post date:** [January 10, 2017, 6:36pm UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/1 "2017-01-10T18:36:31Z")

</div>

Hi,

I’m trying to render a 3d widget onto a 2d texture, using a render target 2d asset created from within the editor and the FWidgetRenderer class at runtime, from within C++. But any transparency in the widget shows up as black in the resulting texture (I’m using this in the context of stereo layers for VR).

Is there anything I need to do to enable transparency when rendering or displaying the rendered texture?

**UPDATE:**

I just did some tests and it seams the deal is that I cannot set the clear color of the texture to “Transparent” from within the editor. That is, if in C++ I grab a reference to the texture I created in the editor and at runtime do `Texture->ClearColor = FLinearColor::Transparent;` then from that point onwards transparency does work.

So I guess the question is how does one set the clear color of a render target texture from within the editor?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_48f2118e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_48f2118e](https://forums.unrealengine.com/u/anonymous_user_48f2118e)\
**Post date:** [January 10, 2017, 8:11pm UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/2 "2017-01-10T20:11:30Z")

</div>

According to the 4.14 release notes:

The “SceneColor (HDR) in RGB, Inv Opacity in A” option can be used to render objects with translucency into a texture which can then be alpha-blended over a scene or widget blueprint.

Not sure if that’s any help. It’s under the “New: Scene Capture Improvements on Mobile” section of the [release notes for 4.14.](https://forums.unrealengine.com/showthread.php?128759-4-14-Released!)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_fdd9bf78](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_fdd9bf78](https://forums.unrealengine.com/u/anonymous_user_fdd9bf78)\
**Post date:** [January 10, 2017, 8:59pm UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/3 "2017-01-10T20:59:59Z")

</div>

@CleanCut Thanks for the info. I’ll check it out. However, I updated my question since it looks like it’s about the texture’s clear color; I don’t know how to set it to transparent from within the editor (I only know how to from C++).

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_48f2118e](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_48f2118e](https://forums.unrealengine.com/u/anonymous_user_48f2118e)\
**Post date:** [January 11, 2017, 12:33am UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/4 "2017-01-11T00:33:16Z")

</div>

Maybe they renamed ClearColor to ChromaKeyColor in blueprints?

![121542-screen+shot+2017-01-10+at+5.31.46+pm.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/3/7/737e14c560bbce51bb425fa18b07e012dea86cc4.png)

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_60812773](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_60812773](https://forums.unrealengine.com/u/anonymous_user_60812773)\
**Post date:** [March 2, 2017, 3:34pm UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/5 "2017-03-02T15:34:18Z")

</div>

ChromaKeyColor is a separate property.

You could try exposing **FLinearColor ClearColor** in _TextureRenderTarget2D.h_?

---

<div class="post-metadata">

**Author:** ![DeathUman](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DeathUman](https://forums.unrealengine.com/u/DeathUman)\
**Post date:** [March 3, 2017, 9:27am UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/6 "2017-03-03T09:27:30Z")

</div>

You can use “Clear Render Target 2D” in blueprint: [https://puu.sh/us8HR/c2732b52e0.jpg](https://puu.sh/us8HR/c2732b52e0.jpg)  
I’m using this to fix blackness on StereoLayer when rendering a 2D UMG .

---

<div class="post-metadata">

**Author:** ![Jonas\_Molgaard](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jonas\_Molgaard](https://forums.unrealengine.com/u/Jonas_Molgaard)\
**Post date:** [August 31, 2017, 8:08am UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/7 "2017-08-31T08:08:07Z")

</div>

@DeathUman the picture you posted is missing. Can you repost your solution by chance? I got the same problem with blackness on my StereoLayer using a color (0,0,0,1) if i call clear with (0,0,0,0) then all subsequent draws are not showing up, even with a material that has an alpha map.

Thanks.

---

<div class="post-metadata">

**Author:** ![Jonas\_Molgaard](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jonas\_Molgaard](https://forums.unrealengine.com/u/Jonas_Molgaard)\
**Post date:** [August 31, 2017, 8:24am UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/8 "2017-08-31T08:24:52Z")

</div>

This is my setup btw… it works in PIE, but once i package it, it turns black. Im on 4.17 btw.

 ![211714-capture.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/f/5/2f5303a71ec0fda35c94a82f6552eaa960c6e507.jpeg)

---

<div class="post-metadata">

**Author:** ![Geodesix](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Geodesix](https://forums.unrealengine.com/u/Geodesix)\
**Post date:** [January 2, 2018, 9:59am UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/9 "2018-01-02T09:59:22Z")

</div>

This works for me

```
	Instructions_RT = NewObject<UCanvasRenderTarget2D>(this);
	Instructions_RT->InitAutoFormat(ViewSize.X / 2, ViewSize.Y);
	Instructions_RT->ClearColor = FLinearColor(0.0f, 0.0f, 0.0f, 0.0f);
	Instructions_RT->UpdateResource();
```

---

<div class="post-metadata">

**Author:** ![S-ed](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/s-ed/32/1194558_2.png) [@S-ed](https://forums.unrealengine.com/u/S-ed)\
**Post date:** [August 20, 2018, 11:11pm UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/10 "2018-08-20T23:11:31Z")

</div>

@DeathUman This is the reason why I hate people linking images for 3rd party sites. -\_-

---

<div class="post-metadata">

**Author:** ![JasonCappVR](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JasonCappVR](https://forums.unrealengine.com/u/JasonCappVR)\
**Post date:** [October 15, 2019, 9:58pm UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/11 "2019-10-15T21:58:12Z")

</div>

@DenisDubinin Can you expand on this. My Stereo Layer can’t show transparent when I have Support Depth on, the transparent parts just show up as black. But it works fine when it’s off.  
I’ve tried all sorts of ways to change my clear colour, BP and C++ but neither seems to work. Could you please expand on what you did?

---

<div class="post-metadata">

**Author:** ![JasonCappVR](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@JasonCappVR](https://forums.unrealengine.com/u/JasonCappVR)\
**Post date:** [October 15, 2019, 10:01pm UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/12 "2019-10-15T22:01:01Z")

</div>

@saldavonschwartz  
I’ve seen your update and you say you’ve got it working?  
My stereo Layer shows as black in the (whats supposed to be) transparent parts only while I’ve got Support Depth on.  
I did what you said and got a reference to the Texture (I assume you meant render target of the Widget?) and set the ClearColor but that didn’t seem to help.  
Can you give any other context for how you fixed it? I’ve been trying to fix this for about 10 hours now and I’m losing my mind.

---

<div class="post-metadata">

**Author:** ![PleshivtsevS](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@PleshivtsevS](https://forums.unrealengine.com/u/PleshivtsevS)\
**Post date:** [June 5, 2024, 3:52pm UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/13 "2024-06-05T15:52:31Z")

</div>

Hello, can you tell me if it was possible to fix this problem? If yes. then please tell us how you did it. Thanks

---

<div class="post-metadata">

**Author:** ![Kalikovision](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Kalikovision](https://forums.unrealengine.com/u/Kalikovision)\
**Post date:** [August 6, 2024, 3:21pm UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/14 "2024-08-06T15:21:10Z")

</div>

Idk what the deal is. If you set the clear color to straight alpha 0, the whole image won’t render. Ever. Even you render something with full alpha on top of it.

But in case it helps someone in the future. I just made a custom rendertarget function that allows you to set some additional parameters.

```auto
#include "Engine/CanvasRenderTarget2D.h"

	UFUNCTION(BlueprintCallable, Category = "Canvas Render Target 2D", meta = (WorldContext = "WorldContextObject"))
	static UCanvasRenderTarget2D* CreateCustomCanvasRenderTarget2D(UObject* WorldContextObject, TSubclassOf<UCanvasRenderTarget2D> CanvasRenderTarget2DClass, int32 Width = 1024, int32 Height = 1024, FLinearColor clearColor = FLinearColor(0,0,0,1), EPixelFormat pixelFormat = EPixelFormat::PF_A16B16G16R16, bool forceGamma = false);

```

cpp

```auto
UCanvasRenderTarget2D* UGameUtilities::CreateCustomCanvasRenderTarget2D(UObject* WorldContextObject, TSubclassOf<UCanvasRenderTarget2D> CanvasRenderTarget2DClass, int32 Width, int32 Height, FLinearColor clearColor, EPixelFormat pixelFormat, bool forceGamma)
{
	if ((Width > 0) && (Height > 0) && (CanvasRenderTarget2DClass != NULL))
	{
		UCanvasRenderTarget2D* NewCanvasRenderTarget = UCanvasRenderTarget2D::CreateCanvasRenderTarget2D(WorldContextObject, CanvasRenderTarget2DClass, Width, Height);
		if (NewCanvasRenderTarget)
		{
			NewCanvasRenderTarget->ClearColor = clearColor;
			NewCanvasRenderTarget->InitCustomFormat(Width, Height, pixelFormat, forceGamma);
			return NewCanvasRenderTarget;
		}
	}

	return nullptr;
}

```

good luck to everyone. I’m content with a .5 alpha on my particular project, but I don’t feel like digging anymore into source to find out why alpha clear of 0 just negates all future renders

EDIT: I’m actually wondering if the Canvas is the bigger problem with the clear. I’m not sure. It gets a little too advanced for me at those depths and I don’t have the patience to navigate them right now

EDIT2: Setting my decal to AlphaComposite allowed me to clear to transparent black without the following calls also being disregarded. However, I am still unable to render something black (full alpha) on top of it without it being discarded. Maybe someone more patient than me can figure out the right set of settings.

---

<div class="post-metadata">

**Author:** ![elmo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@elmo](https://forums.unrealengine.com/u/elmo)\
**Post date:** [March 17, 2026, 3:37pm UTC](https://forums.unrealengine.com/t/transparency-in-render-target-2d-shows-up-black/381466/15 "2026-03-17T15:37:18Z")

</div>

Not sure if this is the issue you’re running into, but when rendering transparent UI to a render target the alpha channel can sometimes end up inverted. This can make it look like nothing is rendering at all, because the output becomes fully transparent. In cases like that it can help to clear with `FLinearColor::Black`, since the clear itself may behave inverted as well.
