Requirements
I want to clear the texture render target with specific color, when capture the scene.
Problem
I am using SceneCaptureComponent2D with TextureRenderTarget2D.
I added only one PrimitiveComponent into the ShowOnlyComponents array in SceneCaptureComponent2D.
After then, I set the ‘ClearColor’ property of the TextureTarget as FLinearColor::Black. But it doesn’t seem to be clear properly.
Instead, it seams that SceneCapture clears the render target using gradation colors (like sky sphere)
I expected that the ClearColor defines the color of clear function(like glClear), am I wrong?
I decided to explore the engine sources.
When I call the CaptureScene() of the SceneCaptureComponent2D manually, the brief call chain is something like below.
USceneCaptureComponent2D::CaptureScene()
=> FScene::UpdateSceneCaptureContents(…)
=> ENQUEUE_UNIQUE_RENDER_COMMAND_THREEPARAMETER (UpdateSceneCaptureContents at SceneCaptureRendering.cpp:526)
=> UpdateSceneCaptureContentDeferred_RenderThread
=> UpdateSceneCaptureContentDeferred_RenderThread
=> RHICmdList.ClearColorTexture(Target->GetRenderTargetTexture(), FLinearColor::Black, ViewRect) (at SceneCaptureRendering.cpp:218)
Yes, when I call CaptureScene, ClearColorTexture command is followed.
Even though it does not clear the texture using ClearColor property, the texture render target should be cleared.
I don’t want to add another dummy actors to represent background. It is not the absolute solution.
I am appreciate your help.
alleysark.