浏览代码

Fix the bug with animated materials

/main
Evgenii Golubev 7 年前
当前提交
41b3bcf7
共有 2 个文件被更改,包括 30 次插入5 次删除
  1. 33
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs
  2. 2
      ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderVariables.hlsl

33
ScriptableRenderPipeline/HDRenderPipeline/HDRP/HDRenderPipeline.cs


// Use to detect frame changes
int m_FrameCount;
float m_TimeSinceLevelLoad;
float m_TimeSinceStartup;
public int GetCurrentShadowCount() { return m_LightLoop.GetCurrentShadowCount(); }
public int GetShadowAtlasCount() { return m_LightLoop.GetShadowAtlasCount(); }

{
using (new ProfilingSample(cmd, "Push Global Parameters", CustomSamplerId.PushGlobalParameters.GetSampler()))
{
float ct = Time.timeSinceLevelLoad;
float pt = (m_TimeSinceLevelLoad > 0) ? m_TimeSinceLevelLoad : ct;
bool animateMaterials = true;
#if UNITY_EDITOR
if (hdCamera.camera.cameraType == CameraType.Game)
{
animateMaterials = Application.isPlaying;
}
else
{
animateMaterials = false;
// Determine whether the "Animated Materials" checkbox of the current view is checked.
foreach (UnityEditor.SceneView sv in Resources.FindObjectsOfTypeAll(typeof(UnityEditor.SceneView)))
{
if (sv.camera == hdCamera.camera && sv.sceneViewState.showMaterialUpdate)
{
animateMaterials = true;
break;
}
}
}
#endif
// Do not use 'Time.timeSinceLevelLoad' - it ticks in the Scene View for a fraction of a second
// after you select an object even if the "Animated Materials" option is disabled.
float ct = animateMaterials ? Time.realtimeSinceStartup : 0;
float pt = (m_TimeSinceStartup > 0) ? m_TimeSinceStartup : ct;
float dt = Time.deltaTime;
float sdt = Time.smoothDeltaTime;

if (m_FrameSettings.enableStereo) hdCamera.SetupGlobalStereoParams(cmd);
// Update the current time.
m_TimeSinceLevelLoad = ct;
m_TimeSinceStartup = ct;
}
}

2
ScriptableRenderPipeline/HDRenderPipeline/HDRP/ShaderVariables.hlsl


float4 unity_ShadowColor;
// Time (t = time since current level load) values from Unity.
// t = animateMaterials ? Time.realtimeSinceStartup : 0.
float4 _CurrentTime; // { t/20, t, t*2, t*3 }
float4 _PreviousTime; // { t/20, t, t*2, t*3 }
float4 _DeltaTime; // { dt, 1/dt, smoothdt, 1/smoothdt }

正在加载...
取消
保存