# \[C++\] \[5.0.1\] How do I Properly Render Canvas Elements (textures, materials, etc.) to a UCanvasRenderTarget2D whilst retaining the Alpha Values of said Elements?

**URL:** <https://forums.unrealengine.com/t/c-5-0-1-how-do-i-properly-render-canvas-elements-textures-materials-etc-to-a-ucanvasrendertarget2d-whilst-retaining-the-alpha-values-of-said-elements/553215>\
**Category:** Rendering\
**Tags:** unreal-engine, UE5-0, Rendering, question\
**Created:** [May 10, 2022, 1:12am UTC](https://forums.unrealengine.com/t/c-5-0-1-how-do-i-properly-render-canvas-elements-textures-materials-etc-to-a-ucanvasrendertarget2d-whilst-retaining-the-alpha-values-of-said-elements/553215 "2022-05-10T01:12:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![YoShuffles](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@YoShuffles](https://forums.unrealengine.com/u/YoShuffles)\
**Post date:** [May 10, 2022, 1:12am UTC](https://forums.unrealengine.com/t/c-5-0-1-how-do-i-properly-render-canvas-elements-textures-materials-etc-to-a-ucanvasrendertarget2d-whilst-retaining-the-alpha-values-of-said-elements/553215/1 "2022-05-10T01:12:07Z")

</div>

I’m trying to render textures, materials, and text to a UCanvasRenderTarget2D via c++. Everything works fine except for the alpha of the render target. When you examine the UCanvasRenderTarget2D in a User Interface material, the alpha of the entire texture is that of the clear color. For example, setting UCanvasRenderTarget2D#ClearColor to (0, 0, 0, 0) will result in the render target being completely translucent. The RGB values of the render target are correct, however. When drawing to the UCanvas in AHUD, it represents the alpha properly. Only when using the UCanvas in UCanvasRenderTarget2D is there an issue with the alpha.

I’ve tried several blend modes, each to no avail. I’m really not sure where to go next with this issue.

---

<div class="post-metadata">

**Author:** ![YoShuffles](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@YoShuffles](https://forums.unrealengine.com/u/YoShuffles)\
**Post date:** [May 18, 2022, 12:38am UTC](https://forums.unrealengine.com/t/c-5-0-1-how-do-i-properly-render-canvas-elements-textures-materials-etc-to-a-ucanvasrendertarget2d-whilst-retaining-the-alpha-values-of-said-elements/553215/2 "2022-05-18T00:38:08Z")

</div>

Update: I discovered a workaround by rendering the FCanvasItems to two separate render targets. One records color, and the other alpha using the SE\_BLEND\_TranslucentAlphaOnlyWriteAlpha blend mode. This only works for rendering textures, however, as materials and text don’t properly record their alpha even in this blend mode. You also cannot have overlapping translucent textures, as each subsequent element overwrites the previous one’s alpha.

Considering that SE\_BLEND\_TranslucentAlphaOnlyWriteAlpha writes to the alpha channel and SE\_BLEND\_Translucent does not, I can only assume this is a bug with canvas render targets and translucent blending. Does anyone have any experience with this, or can weigh in on whether this is intended behavior or not?
