Can I Change The X Size And Y Size Render Target at Runtime?

I want to change the render target during runtime
Is there a good way?
It doesn’t matter if it’s a blueprint or c ++, so I’d be honored if you could reply.

Conserving the info? or just resize?

Resizing is easy, inside the UTextureRenderTarget2D you have a function InitAutoFormat(), check how the CreateRenderTarget2D function is made UKismetRenderingLibrary::CreateRenderTarget2D:

	NewRenderTarget2D->RenderTargetFormat = Format;
	NewRenderTarget2D->ClearColor = ClearColor;
	NewRenderTarget2D->bAutoGenerateMips = bAutoGenerateMipMaps;
	NewRenderTarget2D->InitAutoFormat(Width, Height);	
	NewRenderTarget2D->UpdateResourceImmediate(true);

Now if you want to resize and keep the texture data, that is a different story, you will need to create first a temporary texture, copy your texture there, resize your original texture and copy back, It should be trivial to do with DrawMaterialToRenderTarget.

3 Likes

Hi, ZkarmaKun!
Thank you for answering my question.
First, I just want to change the size of the Render Texture captured by SceneCapture2D with Runtime.
Second, Oh… Actually, I haven’t dealt with C ++ so much, and I would appreciate it if you could tell me the procedure how to write the code.
Sorry for the lack of explanation, but thank you for your reply. m(_ _)m

Shino888