Fix incorrect blending math

Signed-off-by: puvvadar <puvvadar@amazon.com>
This commit is contained in:
puvvadar
2021-07-29 13:35:32 -07:00
parent 496a0f686f
commit 8612d7bce2
3 changed files with 6 additions and 5 deletions
@@ -157,7 +157,7 @@ namespace Multiplayer
{
// Client blends from previous frame to target so here we subtract blend factor to get to that state
const float blendFactor = AZStd::min(AZStd::max(0.f, input.GetHostBlendFactor()), 1.f);
const AZ::TimeMs blendMs = AZ::TimeMs(static_cast<float>(static_cast<AZ::TimeMs>(cl_InputRateMs)) * blendFactor);
const AZ::TimeMs blendMs = AZ::TimeMs(static_cast<float>(static_cast<AZ::TimeMs>(cl_InputRateMs)) * (1.f - blendFactor));
m_clientBankedTime = AZStd::min(m_clientBankedTime + clientInputRateSec, (double)sv_MaxBankTimeWindowSec); // clamp to boundary
{
ScopedAlterTime scopedTime(input.GetHostFrameId(), input.GetHostTimeMs() - blendMs, input.GetHostBlendFactor(), invokingConnection->GetConnectionId());
@@ -861,12 +861,12 @@ namespace Multiplayer
{
m_tickFactor += deltaTime / serverRateSeconds;
// Linear close to the origin, but asymptote at y = 1
const float renderBlendFactor = AZStd::clamp(1.0f - (std::pow(cl_renderTickBlendBase, m_tickFactor)), 0.0f, 1.0f);
m_renderBlendFactor = AZStd::clamp(1.0f - (std::pow(cl_renderTickBlendBase, m_tickFactor)), 0.0f, 1.0f);
AZLOG
(
NET_Blending,
"Computed blend factor of %0.3f using a tick factor of %0.3f, a frametime of %0.3f and a serverTickRate of %0.3f",
renderBlendFactor,
m_renderBlendFactor,
m_tickFactor,
deltaTime,
serverRateSeconds
@@ -913,7 +913,7 @@ namespace Multiplayer
for (NetBindComponent* netBindComponent : gatheredEntities)
{
netBindComponent->NotifyPreRender(deltaTime, renderBlendFactor);
netBindComponent->NotifyPreRender(deltaTime, m_renderBlendFactor);
}
}
else
@@ -925,7 +925,7 @@ namespace Multiplayer
NetBindComponent* netBindComponent = entity->FindComponent<NetBindComponent>();
if (netBindComponent != nullptr)
{
netBindComponent->NotifyPreRender(deltaTime, renderBlendFactor);
netBindComponent->NotifyPreRender(deltaTime, m_renderBlendFactor);
}
}
}
@@ -156,6 +156,7 @@ namespace Multiplayer
HostFrameId m_lastReplicatedHostFrameId = HostFrameId(0);
double m_serverSendAccumulator = 0.0;
float m_renderBlendFactor = 0.0f;
float m_tickFactor = 0.0f;
#if !defined(AZ_RELEASE_BUILD)