I am now trying to make perspective projection effect in slate directly, so I need the ViewRect to do deprojection. While in deprojection I have these to normalize the position :
float NormalizedScreenSpaceX = (FMath::TruncToInt(ScreenPosition.X) - ViewRect.Min.X) / ((float)ViewRect.Width());
float NormalizedScreenSpaceY = (FMath::TruncToInt(ScreenPosition.Y) - ViewRect.Min.Y) / ((float)ViewRect.Height());
So I need get true ViewRect.Min to ensure calculation is correct. But all the way I get ViewRect.Min is (0,0), while width and height are correct.
I get the ViewRect in these codes( in UWidget.cpp ):
FSceneViewFamilyContext ViewFamily(FSceneViewFamily::ConstructionValues(
LP->ViewportClient->Viewport,
GetWorld()->Scene,
LP->ViewportClient->EngineShowFlags)
.SetRealtimeUpdate(true));
FVector ViewLocation;
FRotator ViewRotation;
FSceneView* SceneView = LP->CalcSceneView(&ViewFamily, /*out*/ ViewLocation, /*out*/ ViewRotation, LP->ViewportClient->Viewport);
FSceneViewProjectionData ProjectionData;
LP->GetProjectionData(LP->ViewportClient->Viewport, eSSP_FULL, /*out*/ ProjectionData);
ViewProjectionMatrix = ProjectionData.ComputeViewProjectionMatrix();
ViewRect = ProjectionData.GetViewRect();
ViewRect = SceneView->UnconstrainedViewRect;
ViewRect = SceneView->UnscaledViewRect;
None of these ways get the correct ViewRect
So, the question is How Could I Get the REAL ViewRect which means that ViewRect.Min is the correct position in the scrren such as this: