How to cast RenderTarget to Texture2D

So I’m using the following Blueprint:


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?

any luck with this?

I have the same q

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(...);

I get a UTexture2D,But it’s black

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

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).