Workaround for broken cameraViewToClip

This commit is contained in:
FakeMichau
2025-08-16 16:49:17 +02:00
parent 0d6444684e
commit e5e60af76d
2 changed files with 10 additions and 4 deletions
+2
View File
@@ -79,6 +79,8 @@ void IFGFeature::SetCameraValues(float nearValue, float farValue, float vFov, fl
_cameraVFov = vFov;
_cameraAspectRatio = aspectRatio;
_meterFactor = meterFactor;
LOG_TRACE("farValue: {}, nearValue: {}, vFov: {}, aspectRatio: {}", farValue, nearValue, vFov, aspectRatio);
}
void IFGFeature::SetCameraData(float cameraPosition[3], float cameraUp[3], float cameraRight[3], float cameraForward[3])
@@ -447,13 +447,19 @@ bool Sl_Inputs_Dx12::dispatchFG()
return true;
};
LOG_TRACE("Pre camera recalc near: {}, far: {}", slConstsRef.cameraNear, slConstsRef.cameraFar);
static bool dontRecalc = false;
LOG_TRACE("Camera from SL pre recalc near: {}, far: {}", slConstsRef.cameraNear, slConstsRef.cameraFar);
// UE seems to not be passing the correct cameraViewToClip
// and we can't use it to calculate cameraNear and cameraFar.
if (engineType != sl::EngineType::eUnreal)
if (engineType != sl::EngineType::eUnreal && !dontRecalc)
loadCameraMatrix();
// Workaround for more games with broken cameraViewToClip
if (!dontRecalc && (slConstsRef.cameraNear < 0.0f || slConstsRef.cameraFar < 0.0f))
dontRecalc = true;
infiniteDepth = false;
if (slConstsRef.cameraNear != 0.0f && slConstsRef.cameraFar == 0.0f)
{
@@ -465,8 +471,6 @@ bool Sl_Inputs_Dx12::dispatchFG()
slConstsRef.cameraFar = slConstsRef.cameraNear + 1.0f;
}
LOG_TRACE("Post camera recalc near: {}, far: {}", slConstsRef.cameraNear, slConstsRef.cameraFar);
fgOutput->SetCameraValues(slConstsRef.cameraNear, slConstsRef.cameraFar, slConstsRef.cameraFOV,
slConstsRef.cameraAspectRatio, 0.0f);