浏览代码

Add more reliable detection of the start of the new frame

/main
Evgenii Golubev 7 年前
当前提交
cfc871a0
共有 1 个文件被更改,包括 31 次插入9 次删除
  1. 40
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs

40
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


base.Render(renderContext, cameras);
RenderPipeline.BeginFrameRendering(cameras);
if (m_FrameCount != Time.frameCount)
// New frame.
HDCamera.CleanUnused();
// SRP.Render() can be called several times per frame.
// Also, most Time variables do not consistently update in the Scene View.
// This makes reliable detection of the start of the new frame VERY hard.
// One of the exceptions is 'Time.realtimeSinceStartup'.
// Therefore, outside of the Play Mode we update the time at 60 fps,
// and in the Player, we rely on 'Time.frameCount'.
float t = Time.realtimeSinceStartup;
int c = Time.frameCount;
m_FrameCount = Time.frameCount;
bool newFrame;
// Do not use 'Time.timeSinceLevelLoad' - it does not tick all the time as expected.
float t = Time.realtimeSinceStartup;
if (Application.isPlaying)
{
newFrame = m_FrameCount != c;
// Make sure both are never 0.
m_PreviousTime = (m_CurrentTime > 0) ? m_CurrentTime : t;
m_CurrentTime = t;
if (newFrame) m_FrameCount = c;
}
#if UNITY_EDITOR
else
{
newFrame = ((t - m_CurrentTime) * 1000.0f) > 16.6;
if (newFrame) m_FrameCount++;
}
#endif
if (newFrame)
{
HDCamera.CleanUnused();
// Make sure both are never 0.
m_PreviousTime = (m_CurrentTime > 0) ? m_CurrentTime : t;
m_CurrentTime = t;
}
}
// TODO: Render only visible probes

正在加载...
取消
保存