How change RenderTarget with ENQUEUE_RENDER_COMMAND?

I want change landscape’s render target.

My Ref is unreal engine4 - How do you update a UTextureRenderTarget2D dynamically in C++? - Stack Overflow

And use public modules (“Core”, “CoreUObject”, “Engine”, “InputCore”, “UMG”, “GameplayTasks”, “Landscape”, “RHI”, “RenderCore”).

Why printed assertion failed log?

How fix assertion failed problem?

Please, teachers.

problem code:

void AWorldCreator::BeginPlay()
{
Super::BeginPlay();
    if (RenderTarget != nullptr) {
    RenderTarget->InitCustomFormat(Width, Height, PF_B8G8R8A8, true);

    auto region = FUpdateTextureRegion2D(0, 0, 0, 0, Width, Height);

    FTexture2DRHIRef TextureRHI = RenderTarget->GameThread_GetRenderTargetResource()->GetRenderTargetTexture();

    ENQUEUE_RENDER_COMMAND(UpdateTextureRegionsData)(
	[=](FRHICommandListImmediate& RHICmdList)
	{
		check(TextureRHI.IsValid());  // Assertion failed line
    });
    }
}
1 Like