Hi,
I added serveral pass after basepass and all these passes have same code snippet which is to reconstruct world position from scene depth. Now I am developing rain and wet effects, Specifically, when creating a wetness shadowmap to distinguish areas that have been rained on. The wetness shadowmap is rendered by SceneCaptureComponent, I found that when it called CaptureScene, all my passes in the same frame would have errors of world position reconstruction. If you uncheck ‘Render in Main renderer’, it will no longer cause errors. So I would like to ask if this is an officially known side effect caused by using the Main renderer to capture, or is it an unknown bug? Also, how should I handle this situation? Should I maintain a correct ViewUniformBuffer data for all my passes, or should I no longer use SceneCaptureComponent and add a DepthPass to draw the Wetness Shadowmap.
Code for world position reconstruction.
float2 ScreenUV = UVAndScreenPos.xy; float2 ScreenPos = UVAndScreenPos.zw; float3 ScreenVector = mul(float3(ScreenPos, 1), DFToFloat3x3(PrimaryView.ScreenToWorld)).xyz; float3 OffsetWorldPos = ScreenVector * SceneDepth; float3 worldPos = OffsetWorldPos + CameraPostion;
P1 is the correct world position reconstruction result.
P2 is the result of same pixel shader while ScenceCaptureComponent->CaptureScene is called.
P3 is the wetness shadow map that I needed, comes from a depth map from SceneCapture.
[Image Removed]
[Image Removed]
[Image Removed]
Hello,
Thank you for reaching out.
I’ve been assigned this issue, and we will be looking into the behavior of SceneCaptureComponent2D Render in Main Renderer for you.
Hello,
We have been unable to reproduce this issue.
Can you please send us a minimal test project that demonstrates the world position reconstruction issues in the SceneCaptureComponent2D with Render in Main Renderer?
The guide for test projects:
[Content removed]
Hi,
Sorry for the delay. I’m trying to create a project that can reproduce this issue. Due to the need to view the effect within the Pass inserted into the engine rendering pipeline, it is somewhat troublesome.And during the production of the replication project, I also encountered some issues that I had not previously discovered.
When creating a replication project, I cut the engine source code repository to the 2d53fcab0066b1f16dd956b227720841cad0f6f7 branch and created a new PostProcessPass for viewing the effect of restoring the world coordinate space from depth.In the default view of the engine, the result appears correct(P1), but when switching to full screen mode through F11, it seems that the ViewUniformBuffer data is incorrect (P2). When running the project, even in the default view, the result is incorrect (P3).
I hung a SceneCaptureWidget2D on the character and set it to Capture On Movement. When it is updated, it can be observed that the View changes again, which should have been the question I originally wanted to ask. However, it is strange that this phenomenon is triggered regardless of whether Render In Main renderer is selected or not, which is inconsistent with the issues I have observed in our project.
I put code files that I created or modified in engine together in the zip file(P4),Put them in the corresponding positions in the picture and they should work properly.All modifications are based on 2d53fcab0066b1f16dd956b227720841cad0f6f7 branch.
[Image Removed]
Hello,
It looks like you did not take Screen Percentage into account in your post-process shader.
The functions “SvPositionToScreenPosition(…)” and “SvPositionToBufferUV(…)” are designed to work based on the size of the GBuffer, which is not necessarily the same size as the color target of your post-processing pass. This is leading to a size and UV mismatch, where the ScreenPosition and the ScreenUV are incorrectly calculated.
Here are custom versions of these functions that have been modified to take the Screen Percentage into account:
`float4 SvPositionToScreenPosition_Custom(float4 SvPosition)
{
float ScreenScale = View.ResolutionFractionAndInv.x;
float2 PixelPos = SvPosition.xy - View.ViewRectMin.xy * ScreenScale;
float3 NDCPos = float3( (PixelPos * (View.ViewSizeAndInvSize.zw * ScreenScale) - 0.5f) * float2(2, -2), SvPosition.z);
return float4(NDCPos.xyz, 1) * SvPosition.w;
}
float2 SvPositionToBufferUV_Custom(float4 SvPosition)
{
return SvPosition.xy * (View.BufferSizeAndInvSize.zw * View.ResolutionFractionAndInv.x);
}`Keep in mind that the scaling factor “View.ResolutionFractionAndInv.x” might not work when using depth texture from a Scene Capture, due to it’s render target size potentially being different than the GBuffer.
Please let us know if this helps.
Hi,
Thank you very much for your answer. I would like to ask some detailed questions about ScreenPercentage.Is the resolution of GBuffer Final Resolution * ScreenPercentage, and SceneColor Final Resolution?Can the output of the result to GBuffer Pass directly use the ViewUniformBuffer data in PrimaryView without considering the impact of ScreenPercentage?Also, what I initially inquired about is whether the error in ViewUniformBuffer data caused by SceneCapture Component ->Capture is also related to my Pass not considering ScreenPercentage?
Hello,
You are correct, GBuffer Resolution = Final Resolution * ScreenPercentage.
For post processing, the SceneColor (SceneColorSlice) sizes can vary depending on the ordering of the pass.
Please see the “Post Process Material after Temporal Upscale” section in this documentation page:
https://dev.epicgames.com/documentation/en\-us/unreal\-engine/screen\-percentage\-with\-temporal\-upscale\-in\-unreal\-engine\#postprocessmaterialaftertemporalupsample
Additionally you can look at AddPostProcessingPasses() in PostProcessing.cpp.
Shaders running in the prior to upscaling, such as the Base Pass shaders, can use the values in ViewUniformBuffer directly without accounting for ScreenPercentage.
The error is very likely the same error affecting your Scene Capture pass. However, consider the render target resolution of the Scene Capture in this case.
We are not able to offer more specific advice since your test project does not show how you are using a Scene Capture Component.
Please let us know if this helps.