TextureRenderTarget2D ClearColor does not working

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)

118793-clearcolor_not_working.png

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.

I finally found that the AtmosphericFog makes the gradation background.

But I cannot find how could I disable this bloody AtmosphericFog at c++ code.
I think the ShowFlags in USceneCaptureComponent is the way to go to the solution.

Am I right?

Yeah, using something like CameraComponent->ShowFlags.SetAtmosphericFog(false); will disable rendering the fog in the background.

As an added bonus, you can use the ShowFlags.Set... commands to selectively turn off entire render passes, which I’ve used before to make the cameras less prohibitively expensive to use.

Ooh… Thanks!
Actually, I’ve already solved my problem like what you advice!
Now I can have confidence in this way with your comment :smiley:

also i recommend you to look at this topic - https://answers.unrealengine.com/questions/447769/fog-rendering-too-thick-with-scene-capture.html
here is screen how to remove fog from render target without c++