While I’ve been making a custom SVE render pass in UE5.7 and tried to reconstruct world-space positions from depth and project all of that as quads in a vertex shader, I’ve encountered an issue that I think is worth sharing:
What: All projections render in one flat cuboid cluster at the world origin.
Why: GetTranslatedViewProjectionMatrix() returns TranslatedWorldToClip, not a standard world-to-clip matrix. It expects positions to be already offset by PreViewTranslation in Translated World Space. And passing absolute world positions displaces every vertex by the full camera-to-world-origin offset, which results in a cuboid cluster.
Fix:
float3 TranslatedWorldPos = WorldPosAbs + PreViewTranslation.xyz;
float4 ClipPos = mul(float4(TranslatedWorldPos, 1.0), WorldToClip);
Pass PreViewTranslation as a FVector4f shader parameter from C++:
FVector3f PreTrans = (FVector3f)View.ViewMatrices.GetPreViewTranslation();
Params->PreViewTranslation = FVector4f(PreTrans.X, PreTrans.Y, PreTrans.Z, 0.0f);
Don’t try to subtract CameraPos manually, coordinates will drift far from the origin due to the LWC precision issue, so pass PreViewTranslation directly.
The matrix name gives zero indication that any of this is required, hopefully it will help someone.