# How to cast RenderTarget to Texture2D

**URL:** <https://forums.unrealengine.com/t/how-to-cast-rendertarget-to-texture2d/306356>\
**Category:** Asset Creation\
**Tags:** unreal-engine, cast, question\
**Created:** [February 8, 2015, 6:36pm UTC](https://forums.unrealengine.com/t/how-to-cast-rendertarget-to-texture2d/306356 "2015-02-08T18:36:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![somethingand7](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@somethingand7](https://forums.unrealengine.com/u/somethingand7)\
**Post date:** [February 8, 2015, 6:36pm UTC](https://forums.unrealengine.com/t/how-to-cast-rendertarget-to-texture2d/306356/1 "2015-02-08T18:36:49Z")

</div>

So I’m using the following Blueprint:

 ![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/d/a/6dac6d783d31fcadd494221b6ec35ccdb6e0dafd.png)  
I need a Texture2D to use in the GetColor function (which is a self-written function), but the SceneCapture2D (from which I get the texture) only gives me a TextureRenderTarget2D and the cast to Texture2D fails apparently.

How do I fix this?

---

<div class="post-metadata">

**Author:** ![rpottorff](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@rpottorff](https://forums.unrealengine.com/u/rpottorff)\
**Post date:** [January 1, 2016, 8:43pm UTC](https://forums.unrealengine.com/t/how-to-cast-rendertarget-to-texture2d/306356/2 "2016-01-01T20:43:45Z")

</div>

any luck with this?

---

<div class="post-metadata">

**Author:** ![joeysnow](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@joeysnow](https://forums.unrealengine.com/u/joeysnow)\
**Post date:** [October 11, 2016, 2:37am UTC](https://forums.unrealengine.com/t/how-to-cast-rendertarget-to-texture2d/306356/3 "2016-10-11T02:37:58Z")

</div>

I have the same q

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e93164e4](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e93164e4](https://forums.unrealengine.com/u/anonymous_user_e93164e4)\
**Post date:** [October 11, 2016, 4:46pm UTC](https://forums.unrealengine.com/t/how-to-cast-rendertarget-to-texture2d/306356/4 "2016-10-11T16:46:35Z")

</div>

You cant simply cast from one to another because these two are inherited from completele different objects and blueprints do not seem to have any functionality for this. But in c++ you can archieve what you want with the following function

```
UTextureRenderTarget2D* AnyTarg; // This is already initialized... only for example
UTexture2D* Texture = AnyTarg->ConstructTexture2D(...);

```

---

<div class="post-metadata">

**Author:** ![joeysnow](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@joeysnow](https://forums.unrealengine.com/u/joeysnow)\
**Post date:** [October 13, 2016, 9:46am UTC](https://forums.unrealengine.com/t/how-to-cast-rendertarget-to-texture2d/306356/5 "2016-10-13T09:46:16Z")

</div>

I get a UTexture2D,But it’s black

---

<div class="post-metadata">

**Author:** ![yanglong](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@yanglong](https://forums.unrealengine.com/u/yanglong)\
**Post date:** [August 22, 2017, 8:14am UTC](https://forums.unrealengine.com/t/how-to-cast-rendertarget-to-texture2d/306356/6 "2017-08-22T08:14:51Z")

</div>

my UTexture2D from UTextureRenderTarget2D is black,too…I don’t know how to fix it

---

<div class="post-metadata">

**Author:** ![theonecalledtom](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@theonecalledtom](https://forums.unrealengine.com/u/theonecalledtom)\
**Post date:** [October 4, 2017, 6:47pm UTC](https://forums.unrealengine.com/t/how-to-cast-rendertarget-to-texture2d/306356/7 "2017-10-04T18:47:24Z")

</div>

That function only works for POW2 textures, and won’t work on Android.

Otherwise it looks like it _should_ work. I have similar code that does work (not on Android).
